| @@ -7,7 +7,7 @@ unitaries = [p*s for p in permutations for s in signs] | |||||
| import numpy as np | import numpy as np | ||||
| from tqdm import tqdm | from tqdm import tqdm | ||||
| from qi import * | |||||
| import qi | |||||
| from functools import reduce | from functools import reduce | ||||
| from util import cache_to_disk | from util import cache_to_disk | ||||
| @@ -41,6 +41,13 @@ def construct_tables(): | |||||
| decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz", | decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz", | ||||
| "xzx", "xzxxx", "xzzzx", "xxxzx", "xzz", "zzx", "xxx", "x", | "xzx", "xzxxx", "xzzzx", "xxxzx", "xzz", "zzx", "xxx", "x", | ||||
| "zzzx", "xxzx", "zx", "zxxx", "xxxz", "xzzz", "xz", "xzxx") | "zzzx", "xxzx", "zx", "zxxx", "xxxz", "xzzz", "xz", "xzxx") | ||||
| elements = {"x": sqx, "z": msqz} | |||||
| elements = {"x": qi.sqx, "z": qi.msqz} | |||||
| unitaries = [compose_u(d) for d in decompositions] | unitaries = [compose_u(d) for d in decompositions] | ||||
| conjugation_table, times_table = construct_tables() | conjugation_table, times_table = construct_tables() | ||||
| sqx = 15 | |||||
| msqz = 5 | |||||
| if __name__ == '__main__': | |||||
| print find_up_to_phase(qi.sqx) | |||||
| print find_up_to_phase(qi.msqz) | |||||
| @@ -1,14 +1,19 @@ | |||||
| from matplotlib import pyplot as plt | from matplotlib import pyplot as plt | ||||
| from graph import * | from graph import * | ||||
| from viz import draw | from viz import draw | ||||
| import itertools as it | |||||
| import clifford | |||||
| def local_complementation(g, vops, v): | def local_complementation(g, vops, v): | ||||
| """ As defined in LISTING 1 of Anders & Briegel """ | |||||
| for i, j in it.combinations(g[v], 2): | |||||
| toggle_edge(g, i, j) | |||||
| # Update VOPs | |||||
| vops[v] = clifford.times_table[vops[v]][clifford.sqx] | |||||
| for i in g[v]: | for i in g[v]: | ||||
| for j in g[v]: | |||||
| if i<j: | |||||
| toggle_edge(g, i, j) | |||||
| # vops[i] = times_table[vop[i]][sqrtmiz] | |||||
| # vops[v] = times_table[vop[v]][sqrtix] | |||||
| vops[i] = clifford.times_table[vops[i]][clifford.msqz] | |||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| g, vops = graph(10) | g, vops = graph(10) | ||||
| @@ -18,9 +23,8 @@ if __name__ == '__main__': | |||||
| add_edge(g, 3, 0) | add_edge(g, 3, 0) | ||||
| add_edge(g, 2, 0) | add_edge(g, 2, 0) | ||||
| add_edge(g, 0, 5) | add_edge(g, 0, 5) | ||||
| vops[0]=1 | |||||
| vops[0] = 1 | |||||
| draw(g, vops) | draw(g, vops) | ||||
| plt.clf() | plt.clf() | ||||
| local_complementation(g, vops, 0) | local_complementation(g, vops, 0) | ||||
| draw(g, vops, "out2.pdf") | draw(g, vops, "out2.pdf") | ||||
| @@ -12,7 +12,7 @@ def draw(graph, vops, filename="out.pdf", ns=500): | |||||
| """ Draw a graph with networkx layout """ | """ Draw a graph with networkx layout """ | ||||
| g = nx.from_edgelist(edgelist(graph)) | g = nx.from_edgelist(edgelist(graph)) | ||||
| pos = nx.spring_layout(g) | pos = nx.spring_layout(g) | ||||
| colors = [VOP_COLORS[vop] for vop in vops] | |||||
| colors = [VOP_COLORS[vop % len(VOP_COLORS)] for vop in vops] | |||||
| nx.draw_networkx_nodes(g, pos, node_color="white", node_size=ns) | nx.draw_networkx_nodes(g, pos, node_color="white", node_size=ns) | ||||
| nx.draw_networkx_nodes(g, pos, node_color=colors, node_size=ns, alpha=.4) | nx.draw_networkx_nodes(g, pos, node_color=colors, node_size=ns, alpha=.4) | ||||
| nx.draw_networkx_labels(g, pos) | nx.draw_networkx_labels(g, pos) | ||||