Browse Source

Add remove_VOP method

master
Pete Shadbolt 8 years ago
parent
commit
3350f47286
2 changed files with 16 additions and 0 deletions
  1. +5
    -0
      clifford.py
  2. +11
    -0
      cz.py

+ 5
- 0
clifford.py View File

@@ -12,6 +12,7 @@ from functools import reduce
from util import cache_to_disk from util import cache_to_disk




# TODO: make this more efficient / shorter
def find_up_to_phase(u): def find_up_to_phase(u):
""" Find the index of a given u within a list of unitaries, up to a global phase """ """ Find the index of a given u within a list of unitaries, up to a global phase """
for i, t in enumerate(unitaries): for i, t in enumerate(unitaries):
@@ -44,9 +45,13 @@ decompositions = ("xxxx", "xx", "zzxx", "zz", "zxx", "z", "zzz", "xxz",
elements = {"x": qi.sqx, "z": qi.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()

# TODO: generate these global names automatically via search
sqx = 15 sqx = 15
msqz = 5 msqz = 5




if __name__ == '__main__': if __name__ == '__main__':
print find_up_to_phase(qi.sqx) print find_up_to_phase(qi.sqx)
print find_up_to_phase(qi.msqz) print find_up_to_phase(qi.msqz)


+ 11
- 0
cz.py View File

@@ -14,6 +14,17 @@ def local_complementation(g, vops, v):
for i in g[v]: for i in g[v]:
vops[i] = clifford.times_table[vops[i]][clifford.msqz] vops[i] = clifford.times_table[vops[i]][clifford.msqz]



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


if __name__ == '__main__': if __name__ == '__main__':
g, vops = graph() g, vops = graph()
add_edge(g, 0, 1) add_edge(g, 0, 1)


Loading…
Cancel
Save