Browse Source

Now updates VOPs in local_complementation

master
Pete Shadbolt 8 years ago
parent
commit
200dd9ac47
3 changed files with 21 additions and 10 deletions
  1. +9
    -2
      clifford.py
  2. +11
    -7
      cz.py
  3. +1
    -1
      viz.py

+ 9
- 2
clifford.py View File

@@ -7,7 +7,7 @@ unitaries = [p*s for p in permutations for s in signs]

import numpy as np
from tqdm import tqdm
from qi import *
import qi
from functools import reduce
from util import cache_to_disk

@@ -41,6 +41,13 @@ def construct_tables():
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")
elements = {"x": sqx, "z": msqz}
elements = {"x": qi.sqx, "z": qi.msqz}
unitaries = [compose_u(d) for d in decompositions]
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)


+ 11
- 7
cz.py View File

@@ -1,14 +1,19 @@
from matplotlib import pyplot as plt
from graph import *
from viz import draw
import itertools as it
import clifford


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 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__':
g, vops = graph(10)
@@ -18,9 +23,8 @@ if __name__ == '__main__':
add_edge(g, 3, 0)
add_edge(g, 2, 0)
add_edge(g, 0, 5)
vops[0]=1
vops[0] = 1
draw(g, vops)
plt.clf()
local_complementation(g, vops, 0)
draw(g, vops, "out2.pdf")


+ 1
- 1
viz.py View File

@@ -12,7 +12,7 @@ def draw(graph, vops, filename="out.pdf", ns=500):
""" Draw a graph with networkx layout """
g = nx.from_edgelist(edgelist(graph))
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=colors, node_size=ns, alpha=.4)
nx.draw_networkx_labels(g, pos)


Loading…
Cancel
Save