Преглед изворни кода

Add remove_VOP method

master
Pete Shadbolt пре 8 година
родитељ
комит
3350f47286
2 измењених фајлова са 16 додато и 0 уклоњено
  1. +5
    -0
      clifford.py
  2. +11
    -0
      cz.py

+ 5
- 0
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)


+ 11
- 0
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)


Loading…
Откажи
Сачувај