|
@@ -4,9 +4,9 @@ from abp import clifford |
|
|
import numpy as np |
|
|
import numpy as np |
|
|
import random |
|
|
import random |
|
|
|
|
|
|
|
|
def multi_qubit_test(): |
|
|
|
|
|
""" A multi qubit test """ |
|
|
|
|
|
n = 6 |
|
|
|
|
|
|
|
|
def test_hadamard_only_multiqubit(): |
|
|
|
|
|
""" A multi qubit test with Hadamards only""" |
|
|
|
|
|
n = 4 |
|
|
g = GraphState(range(n)) |
|
|
g = GraphState(range(n)) |
|
|
c = CircuitModel(n) |
|
|
c = CircuitModel(n) |
|
|
|
|
|
|
|
@@ -27,3 +27,28 @@ def multi_qubit_test(): |
|
|
assert np.allclose(s1, s2) |
|
|
assert np.allclose(s1, s2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_all_multiqubit(): |
|
|
|
|
|
""" A multi qubit test with arbitrary local rotations """ |
|
|
|
|
|
n = 4 |
|
|
|
|
|
g = GraphState(range(n)) |
|
|
|
|
|
c = CircuitModel(n) |
|
|
|
|
|
|
|
|
|
|
|
for i in range(10): |
|
|
|
|
|
i = np.random.randint(0, n-1) |
|
|
|
|
|
j = np.random.randint(0, 24) |
|
|
|
|
|
print i, j |
|
|
|
|
|
g.act_local_rotation(i, j) |
|
|
|
|
|
c.act_local_rotation(i, clifford.unitaries[j]) |
|
|
|
|
|
|
|
|
|
|
|
assert np.allclose(g.to_state_vector().state, c.state) |
|
|
|
|
|
|
|
|
|
|
|
#for i in range(100): |
|
|
|
|
|
#a, b = np.random.randint(0, n-1, 2) |
|
|
|
|
|
#if a != b: |
|
|
|
|
|
#g.act_cz(a, b) |
|
|
|
|
|
#c.act_cz(a, b) |
|
|
|
|
|
|
|
|
|
|
|
#s1 = clifford.normalize_global_phase(g.to_state_vector().state) |
|
|
|
|
|
#s2 = clifford.normalize_global_phase(c.state) |
|
|
|
|
|
#assert np.allclose(s1, s2) |
|
|
|
|
|
|