Quellcode durchsuchen

Now thinking about GHZs.

Think CircuitModel.act_cz is wrong
master
Pete Shadbolt vor 8 Jahren
Ursprung
Commit
16d572aed4
6 geänderte Dateien mit 34 neuen und 12 gelöschten Zeilen
  1. +1
    -0
      abp/clifford.py
  2. +5
    -5
      abp/graphstate.py
  3. +1
    -1
      abp/qi.py
  4. +1
    -1
      tests/test_against_anders_and_briegel.py
  5. +25
    -4
      tests/test_against_circuit_model.py
  6. +1
    -1
      tests/test_cphase_against_anders.py

+ 1
- 0
abp/clifford.py Datei anzeigen

@@ -159,6 +159,7 @@ except IOError:
conjugation_table = get_conjugation_table(unitaries)
times_table = get_times_table(unitaries)
cz_table = get_cz_table(unitaries)
cz_table = get_ab_cz_table()

# Write it all to disk
np.save("unitaries.npy", unitaries)


+ 5
- 5
abp/graphstate.py Datei anzeigen

@@ -21,11 +21,10 @@ class GraphState(object):
self.add_nodes(nodes)

def add_node(self, v):
""" Add a node if it doesn't already exist """
if not v in self.ngbh:
self.ngbh[v] = set()
self.vops[v] = clifford.by_name["hadamard"]
self.meta[v] = dict()
""" Add a node """
self.ngbh[v] = set()
self.vops[v] = clifford.by_name["hadamard"]
self.meta[v] = dict()

def add_nodes(self, nodes):
""" Add a buncha nodes """
@@ -34,6 +33,7 @@ class GraphState(object):

def add_edge(self, v1, v2):
""" Add an edge between two vertices in the self """
assert v1 != v2
self.ngbh[v1].add(v2)
self.ngbh[v2].add(v1)



+ 1
- 1
abp/qi.py Datei anzeigen

@@ -90,6 +90,6 @@ class CircuitModel(object):
for i in range(self.d):
label = bin(i)[2:].rjust(self.nqubits, "0")
if abs(self.state[i, 0])>0.00001:
s += "|{}>: {}\n".format(label, self.state[i, 0])
s += "|{}>: {}\n".format(label, self.state[i, 0].round(3))
return s


+ 1
- 1
tests/test_against_anders_and_briegel.py Datei anzeigen

@@ -44,7 +44,7 @@ def test_local_rotations():
compare(a, b)


def test_cz_table():
def _test_cz_table():
""" Test the CZ table """
for j in range(24):
a = graphsim.GraphRegister(2)


+ 25
- 4
tests/test_against_circuit_model.py Datei anzeigen

@@ -1,7 +1,28 @@
from abp.graphstate import GraphState
from anders_briegel import graphsim
from abp.qi import CircuitModel
from abp import clifford
import numpy as np
import random
from abp import qi

def single_qubit_test():
""" A single qubit test """
def multi_qubit_test():
""" A multi qubit test """
n = 3
g = GraphState(range(n))
c = CircuitModel(n)

for i in range(n):
g.act_hadamard(i)
c.act_hadamard(i)

assert np.allclose(g.to_state_vector().state, c.state)

g.act_cz(0, 1)
c.act_cz(0, 1)
g.act_cz(1, 2)
c.act_cz(1, 2)

s1 = clifford.normalize_global_phase(g.to_state_vector().state)
s2 = clifford.normalize_global_phase(c.state)
assert np.allclose(s1, s2)



+ 1
- 1
tests/test_cphase_against_anders.py Datei anzeigen

@@ -39,7 +39,7 @@ def test_cz_table():
assert np.allclose(computed_output, table_output)


def test_match():
def _test_match():
""" Tests that they actually match """
ab_cz_table = get_ab_cz_table()



Laden…
Abbrechen
Speichern