def test_non_destructive_measurement():
    q_sim = EQSN()
    id1 = str(1)
    q_sim.new_qubit(id1)
    q_sim.H_gate(id1)
    m = q_sim.measure(id1, non_destructive=True)
    m2 = q_sim.measure(id1)
    assert m == m2
    q_sim.stop_all()
Example #2
0
def test_custom_controlled_gate():
    eqsn = EQSN()
    gate = np.array([[0, 1],[1,0]], dtype=np.csingle)
    eqsn.new_qubit('1')
    eqsn.new_qubit('2')
    eqsn.H_gate('1')
    eqsn.custom_controlled_gate('2', '1', gate)
    res1 = eqsn.measure('1')
    res2 = eqsn.measure('2')
    eqsn.stop_all()
    assert res1 == res2
def test_non_destructive_measurement():
    q_sim = EQSN()
    id1 = str(1)
    q_sim.new_qubit(id1)
    q_sim.H_gate(id1)
    m = q_sim.measure(id1, non_destructive=True)
    m2 = q_sim.measure(id1)
    print("Measured %d." % m)
    assert m == m2
    print("Test was successfull!")
    q_sim.stop_all()
    print("Stopped succesfully!")
    exit(0)
Example #4
0
def test_5_qubits_gate():
    q_sim = EQSN()
    ids = [str(x) for x in range(5)]
    for i in ids:
        q_sim.new_qubit(i)
    for i in ids:
        q_sim.H_gate(i)
    q_sim.cnot_gate(ids[1], ids[0])
    q_sim.cnot_gate(ids[2], ids[1])
    q_sim.cnot_gate(ids[3], ids[2])
    q_sim.cnot_gate(ids[4], ids[3])
    for i in ids:
        q_sim.measure(i)
    q_sim.stop_all()
Example #5
0
from eqsn import EQSN

if __name__ == "__main__":
    eqsn = EQSN()
    eqsn.new_qubit('A')
    eqsn.new_qubit('B')
    eqsn.H_gate('A')
    eqsn.cnot_gate('B', 'A')
    m1 = eqsn.measure('A')
    m2 = eqsn.measure('B')
    print("Measured entangled pair with results %d and %d." % (m1, m2))