Quellcode durchsuchen

QTIP, not much

master
Pete Shadbolt vor 8 Jahren
Ursprung
Commit
ea0033379c
2 geänderte Dateien mit 37 neuen und 18 gelöschten Zeilen
  1. +28
    -18
      tests/test_against_circuit_model.py
  2. +9
    -0
      tests/test_qi_vs_qtip.py

+ 28
- 18
tests/test_against_circuit_model.py Datei anzeigen

@@ -29,21 +29,31 @@ def test_hadamard_only_multiqubit(n=6):

def test_all_multiqubit(n=4):
""" A multi qubit test with arbitrary local rotations """
for qqq in range(REPEATS):
g = GraphState(range(n))
c = CircuitModel(n)
for i in range(10):
qubit = np.random.randint(0, n - 1)
rotation = np.random.randint(0, 24 - 1)
g.act_local_rotation(qubit, rotation)
c.act_local_rotation(qubit, clifford.unitaries[rotation])

assert g.to_state_vector() == c

for i in range(1):
a, b = np.random.randint(0, n-1, 2)
if a != b:
g.act_cz(a, b)
c.act_cz(a, b)

assert g.to_state_vector() == c
g = GraphState(range(n))
c = CircuitModel(n)
for i in range(10):
qubit = np.random.randint(0, n - 1)
rotation = np.random.randint(0, 24 - 1)
g.act_local_rotation(qubit, rotation)
c.act_local_rotation(qubit, clifford.unitaries[rotation])

assert g.to_state_vector() == c

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)
assert np.allclose(np.sum(np.abs(c.state)**2), 1)
assert np.allclose(np.sum(np.abs(g.to_state_vector().state)**2), 1)

if not g.to_state_vector() == c:
print g
print a, b
print "Circuit:"
print g.to_state_vector()
print "Graph:"
print c
raise ValueError

assert g.to_state_vector() == c

+ 9
- 0
tests/test_qi_vs_qtip.py Datei anzeigen

@@ -0,0 +1,9 @@
from abp import qi
from qutip import *
import numpy as np

def test_1():
q = QubitCircuit(4)
q.add_gate("CPHASE", 1, 2, arg_value=np.pi)
#print gate_sequence_product(q.propagators())


Laden…
Abbrechen
Speichern