Browse Source

Trying to get permuters working good

master
Pete Shadbolt 8 years ago
parent
commit
c1b8e95437
2 changed files with 62 additions and 0 deletions
  1. +23
    -0
      clifford.py
  2. +39
    -0
      new.py

+ 23
- 0
clifford.py View File

@@ -46,6 +46,10 @@ pz = matrix([[1, 0], [0, -1]], dtype=complex)
h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
p = matrix([[1, 0], [0, 1j]], dtype=complex)
paulis = (px, py, pz)
# Some two-qubit matrices
i = matrix(eye(2, dtype=complex))
h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
p = matrix([[1, 0], [0, 1j]], dtype=complex)

# Basic single-qubit gates
s_gates = (("i", i), ("p", p), ("pp", p * p), ("ppp", p * p * p))
@@ -82,3 +86,22 @@ vop_by_name = {n: {"name":n, "index": i, "action": a, "gates": g, "unitary": u}
for n, i, a, g, u in zip(vop_names, xrange(24), vop_actions, vop_gates, vop_unitaries)}
vop_by_action = {a: {"name": n, "index": i, "action":a, "gates": g, "unitary": u}
for n, i, a, g, u in zip(vop_names, xrange(24), vop_actions, vop_gates, vop_unitaries)}

names, unitaries = [], []
for c_name, c_gate in c_gates:
for s_name, s_gate in s_gates:
names.append(s_name+c_name)
unitaries.append(s_gate * c_gate)
print s_gate * c_gate.round(2)
print

i = matrix(eye(2, dtype=complex))
px = matrix([[0, 1], [1, 0]], dtype=complex)
py = matrix([[0, -1j], [1j, 0]], dtype=complex)
pz = matrix([[1, 0], [0, -1]], dtype=complex)
h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
p = matrix([[1, 0], [0, 1j]], dtype=complex)

#for m in i, px, py, pz:
#print any([allclose(x, m) for x in unitaries])


+ 39
- 0
new.py View File

@@ -0,0 +1,39 @@
from numpy import *

# Some two-qubit matrices
i = matrix(eye(2, dtype=complex))
px = matrix([[0, 1], [1, 0]], dtype=complex)
py = matrix([[0, -1j], [1j, 0]], dtype=complex)
pz = matrix([[1, 0], [0, -1]], dtype=complex)
h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
p = matrix([[1, 0], [0, 1j]], dtype=complex)
paulis = (px, py, pz)

def identify_pauli(m):
""" Given a signed Pauli matrix, name it. """
for sign in (+1, -1):
for pauli_label, pauli in zip("xyz", paulis):
if allclose(sign * pauli, m):
return sign, pauli_label

def get_action(u):
""" What does this unitary operator do to the Paulis? """
return [identify_pauli(u * p * u.H) for p in paulis]

def format_action(action):
return "".join("{}{}".format("+" if s>=0 else "-", p) for s, p in action)

#print get_action(i)
#print get_action(px)
#print get_action(py)
#print get_action(pz)

permuters =

print format_action(get_action(i))
print format_action(get_action(h*p*h*pz))
print format_action(get_action(p*h*p*h))
print format_action(get_action(px*p))
print format_action(get_action(p*h))
print format_action(get_action(p*p*h*pz))


Loading…
Cancel
Save