From 3350f47286811a1be8dfd2db154f7936a3afa123 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 10 Mar 2016 18:35:15 +0000 Subject: [PATCH] Add remove_VOP method --- clifford.py | 5 +++++ cz.py | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/clifford.py b/clifford.py index 41032b5..b3c45e9 100644 --- a/clifford.py +++ b/clifford.py @@ -12,6 +12,7 @@ from functools import reduce from util import cache_to_disk +# TODO: make this more efficient / shorter def find_up_to_phase(u): """ Find the index of a given u within a list of unitaries, up to a global phase """ 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} unitaries = [compose_u(d) for d in decompositions] conjugation_table, times_table = construct_tables() + +# TODO: generate these global names automatically via search sqx = 15 msqz = 5 + + if __name__ == '__main__': print find_up_to_phase(qi.sqx) print find_up_to_phase(qi.msqz) diff --git a/cz.py b/cz.py index 8591dd3..89afd6a 100644 --- a/cz.py +++ b/cz.py @@ -14,6 +14,17 @@ def local_complementation(g, vops, v): for i in g[v]: 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__': g, vops = graph() add_edge(g, 0, 1)