diff --git a/abp/clifford.py b/abp/clifford.py index 7875515..97a9877 100644 --- a/abp/clifford.py +++ b/abp/clifford.py @@ -17,12 +17,9 @@ decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz", "xzx", "xzxxx", "xzzzx", "xxxzx", "xzz", "zzx", "xxx", "x", "zzzx", "xxzx", "zx", "zxxx", "xxxz", "xzzz", "xz", "xzxx") - #{"UUUU", "UU", "VVUU", "VV", - #"VUU", "V", "VVV", "UUV", - #"UVU", "UVUUU", "UVVVU", "UUUVU", - #"UVV", "VVU", "UUU", "U", - #"VVVU", "UUVU", "VU", "VUUU", - #"UUUV", "UVVV", "UV", "UVUU"}; + #{"UUUU", "UU", "VVUU", "VV", #"VUU", "V", "VVV", "UUV", + #"UVU", "UVUUU", "UVVVU", "UUUVU", #"UVV", "VVU", "UUU", "U", + #"VVVU", "UUVU", "VU", "VUUU", #"UUUV", "UVVV", "UV", "UVUU"}; #string LocCliffOp::get_name (void) const #{ @@ -30,7 +27,9 @@ decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz", #return string (paulinames[op & 0x03]) + (char) ('A' + op / 4); #} -ab_names = {0: "IA"} +def get_name(i): + """ Get the human-readable name of this clifford """ + return "IXYZ"[i & 0x03] + "ABCDEF"[i / 4] def find_clifford(needle, haystack): diff --git a/abp/graphstate.py b/abp/graphstate.py index 29ba448..c2a89b6 100644 --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -172,7 +172,7 @@ class GraphState(object): rows = [] for key, vop in self.vops.items(): ngbh = " ".join(map(str, sorted(self.ngbh[key]))) - vop = clifford.ab_names.get(vop, vop) + vop = clifford.get_name(vop) s = "Vertex {}: VOp {}, neighbors {}".format(key, vop, ngbh) rows.append(s) return " \n".join(rows)+ " \n" diff --git a/tests/test_against_anders_and_briegel.py b/tests/test_against_anders_and_briegel.py new file mode 100644 index 0000000..d74b260 --- /dev/null +++ b/tests/test_against_anders_and_briegel.py @@ -0,0 +1,19 @@ +from abp.graphstate import GraphState +from anders_briegel import graphsim + +def test_1(): + N=10 + + a = graphsim.GraphRegister(N) + b = GraphState() + + for i in range(N): + a.hadamard(i) + b.add_vertex(i) + b.act_hadamard(i) + + for i in range(N-1): + a.cphase(i, i+1) + b.act_cz(i, i+1) + + assert a.get_adj_list() == b.adj_list() diff --git a/tests/test_clifford_names.py b/tests/test_clifford_names.py new file mode 100644 index 0000000..8d8c2ea --- /dev/null +++ b/tests/test_clifford_names.py @@ -0,0 +1,7 @@ +from abp import clifford + +def test_names(): + """ Test the naming scheme """ + for i in range(24): + clifford.get_name(i) + assert clifford.get_name(16)=="IE" diff --git a/tests/test_quantum.py b/tests/test_quantum.py new file mode 100644 index 0000000..a3a3e6a --- /dev/null +++ b/tests/test_quantum.py @@ -0,0 +1,8 @@ +from abp.graphstate import GraphState + +def test_logic_101(): + """ Some really simple tests """ + g = GraphState() + g.act_local_rotation_by_name(0, "hadamard") + #print g. +