瀏覽代碼

Lotsa stuff

master
Pete Shadbolt 8 年之前
父節點
當前提交
6676fe49e7
共有 3 個文件被更改,包括 8 次插入9 次删除
  1. +1
    -1
      clifford.py
  2. +5
    -6
      cz.py
  3. +2
    -2
      viz.py

+ 1
- 1
clifford.py 查看文件

@@ -29,7 +29,7 @@ def compose_u(decomposition):

def name_of(vop):
""" Get the formatted name of a VOP """
return get_name[vop].title() if vop in get_name else "VOP%d" % vop
return "%s" % get_name[vop] if vop in get_name else "VOP%d" % vop


@cache_to_disk("tables.pkl")


+ 5
- 6
cz.py 查看文件

@@ -9,12 +9,10 @@ import clifford

def remove_vop(g, vops, a, avoid):
""" Reduces VOP[a] to the identity, avoiding (if possible) the use of vertex b as a swapping partner """
other_neighbours = g[a] - {avoid}
c = avoid if len(other_neighbours) == 0 else other_neighbours.pop()
d = clifford.decompositions[vops[a]]
for v in reversed(d):
target = a if v == "x" else c
local_complementation(g, vops, target)
others = g[a] - {avoid}
swap_qubit = others.pop() if others else avoid
for v in reversed(clifford.decompositions[vops[a]]):
local_complementation(g, vops, a if v == "x" else swap_qubit)


def local_complementation(g, vops, v):
@@ -38,4 +36,5 @@ if __name__ == '__main__':

pos = viz.draw(g, vops, "out.pdf")
remove_vop(g, vops, 0, 1)
remove_vop(g, vops, 1, 2)
viz.draw(g, vops, "out2.pdf", pos)

+ 2
- 2
viz.py 查看文件

@@ -19,11 +19,11 @@ def draw(graph, vops, filename="out.pdf", pos=None, ns=500):
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_edges(g, pos, edge_color="gray")
nx.draw_networkx_labels(g, pos)
nx.draw_networkx_labels(g, pos, font_family="FreeSans")

labels = {i: clifford.name_of(vops[i]) for i in g.nodes()}
pos = {k: v + np.array([0, -.1]) for k, v in pos.items()}
nx.draw_networkx_labels(g, pos, labels)
nx.draw_networkx_labels(g, pos, labels, font_family="FreeSans")
plt.axis('off')
plt.savefig(filename)
return pos


Loading…
取消
儲存