Пример #1
0
def testZ():
    compare = Q.Register(2)
    compare.injectState([1, 0, 0, 0])

    base = Q.Register(2)
    base.Z(1)
    if base != compare:
        raise Exception("Failed X Gate test: ", str(base), " != ",
                        str(compare))
Пример #2
0
def testHadamard():
    sqrt2 = 1 / (2**.5)
    compare = Q.Register(2)
    compare.injectState([sqrt2, sqrt2, 0, 0])

    base = Q.Register(2)
    base.hadamard(0)
    if base != compare:
        raise Exception("Failed X Gate test: ", str(base), " != ",
                        str(compare))
Пример #3
0
def testTooLarge():
    try:
        base = Q.Register(500)
    except:
        return True

    raise Exception("Failed to Raise exception on too large Register")
Пример #4
0
import quantum as Q

base = Q.Register(2)
base.hadamard(1)
base.cnot(1, 0)
print(base)
Пример #5
0
def testInitial():
    base = Q.Register(2)
    compare = Q.Register(2)
    compare.injectState([1, 0, 0, 0])
    if base != compare:
        raise Exception("Failed Register Initialize test")