|
@@ -1,7 +1,7 @@ |
|
|
#!/usr/bin/python |
|
|
#!/usr/bin/python |
|
|
# -*- coding: utf-8 -*- |
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
""" |
|
|
Generates and enumerates the 24 elements of the local Clifford group |
|
|
Generates and enumerates the 24 elements of the local Clifford group |
|
|
Following the prescription of Anders (thesis pg. 26): |
|
|
Following the prescription of Anders (thesis pg. 26): |
|
|
> Table 2.1: The 24 elements of the local Clifford group. The row index (here called the “sign symbol”) shows how the operator |
|
|
> Table 2.1: The 24 elements of the local Clifford group. The row index (here called the “sign symbol”) shows how the operator |
|
@@ -9,7 +9,7 @@ Following the prescription of Anders (thesis pg. 26): |
|
|
> symbol”) indicates the sign obtained under the conjugation: For operators U in the I column it is the sign of the permutation |
|
|
> symbol”) indicates the sign obtained under the conjugation: For operators U in the I column it is the sign of the permutation |
|
|
> (indicated on the left). For elements in the X, Y and Z columns, it is this sign only if the conjugated Pauli operator is the one |
|
|
> (indicated on the left). For elements in the X, Y and Z columns, it is this sign only if the conjugated Pauli operator is the one |
|
|
> indicated by the column header and the opposite sign otherwise. |
|
|
> indicated by the column header and the opposite sign otherwise. |
|
|
""" |
|
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
# TODO: |
|
|
# TODO: |
|
|
# - check that we re-generate the table |
|
|
# - check that we re-generate the table |
|
@@ -19,15 +19,24 @@ Following the prescription of Anders (thesis pg. 26): |
|
|
|
|
|
|
|
|
from numpy import * |
|
|
from numpy import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def identify_pauli(m): |
|
|
def identify_pauli(m): |
|
|
""" Given a signed Pauli matrix, name it. """ |
|
|
""" Given a signed Pauli matrix, name it. """ |
|
|
for sign in (+1, -1): |
|
|
for sign in (+1, -1): |
|
|
for pauli_label, pauli in zip("xyz", paulis): |
|
|
for pauli_label, pauli in zip("xyz", paulis): |
|
|
if allclose(sign*pauli, m): |
|
|
|
|
|
|
|
|
if allclose(sign * pauli, m): |
|
|
return sign, pauli_label |
|
|
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): |
|
|
def format_action(action): |
|
|
return "".join("{}{}".format("+" if s>=0 else "-", p) for s, p in action) |
|
|
|
|
|
|
|
|
""" Format an action as a string """ |
|
|
|
|
|
return "".join("{}{}".format("+" if s >= 0 else "-", p) for s, p in action) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Some two-qubit matrices |
|
|
# Some two-qubit matrices |
|
|
i = matrix(eye(2, dtype=complex)) |
|
|
i = matrix(eye(2, dtype=complex)) |
|
@@ -38,35 +47,38 @@ h = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2) |
|
|
p = matrix([[1, 0], [0, 1j]], dtype=complex) |
|
|
p = matrix([[1, 0], [0, 1j]], dtype=complex) |
|
|
paulis = (px, py, pz) |
|
|
paulis = (px, py, pz) |
|
|
|
|
|
|
|
|
# More two-qubit matrices |
|
|
|
|
|
s_rotations = [i, p, p*p, p*p*p] |
|
|
|
|
|
s_names = ["i", "p", "pp", "ppp"] |
|
|
|
|
|
c_rotations = [i, h, h*p, h*p*p, h*p*p*p, h*p*p*h] |
|
|
|
|
|
c_names = ["i", "h", "hp", "hpp", "hppp", "hpph"] |
|
|
|
|
|
|
|
|
# Basic single-qubit gates |
|
|
|
|
|
s_gates = (("i", i), ("p", p), ("pp", p * p), ("ppp", p * p * p)) |
|
|
|
|
|
c_gates = [("i", i), ("h", h), ("hp", h * p), ("hpp", h * p * p), |
|
|
|
|
|
("hppp", h * p * p * p), ("hpph", h * p * p * h)] |
|
|
|
|
|
|
|
|
# Build the table of VOPs according to Anders (verbatim from thesis) |
|
|
# Build the table of VOPs according to Anders (verbatim from thesis) |
|
|
table = (("a", "xyz", +1), ("b", "yxz", -1), ("c", "zyx", -1), |
|
|
table = (("a", "xyz", +1), ("b", "yxz", -1), ("c", "zyx", -1), |
|
|
("d", "xzy", -1), ("e", "yzx", +1), ("f", "zxy", +1)) |
|
|
|
|
|
|
|
|
("d", "xzy", -1), ("e", "yzx", +1), ("f", "zxy", +1)) |
|
|
|
|
|
|
|
|
# Build a big ol lookup table |
|
|
# Build a big ol lookup table |
|
|
vop_names = [] |
|
|
vop_names = [] |
|
|
vop_actions = [] |
|
|
vop_actions = [] |
|
|
vop_gates = [None]*24 |
|
|
|
|
|
vop_unitaries = [None]*24 |
|
|
|
|
|
|
|
|
vop_gates = [None] * 24 |
|
|
|
|
|
vop_unitaries = [None] * 24 |
|
|
|
|
|
|
|
|
for label, permutation, sign in table: |
|
|
for label, permutation, sign in table: |
|
|
for column, operator in zip("ixyz", "i"+permutation): |
|
|
|
|
|
effect = [((sign if (p==column or column=="i") else -sign), p) |
|
|
|
|
|
for p in permutation] |
|
|
|
|
|
vop_names.append(label+operator) |
|
|
|
|
|
|
|
|
for column, operator in zip("ixyz", "i" + permutation): |
|
|
|
|
|
effect = [((sign if (p == column or column == "i") else -sign), p) |
|
|
|
|
|
for p in permutation] |
|
|
|
|
|
vop_names.append(column + label) # think we can dump "operator" |
|
|
vop_actions.append(format_action(effect)) |
|
|
vop_actions.append(format_action(effect)) |
|
|
|
|
|
|
|
|
for s, sn in zip(s_rotations, s_names): |
|
|
|
|
|
for c, cn in zip(c_rotations, c_names): |
|
|
|
|
|
u = s*c |
|
|
|
|
|
action = format_action(identify_pauli(u*p*u.H) for p in paulis) |
|
|
|
|
|
|
|
|
for s_name, s_gate in s_gates: |
|
|
|
|
|
for c_name, c_gate in c_gates: |
|
|
|
|
|
u = s_gate * c_gate |
|
|
|
|
|
action = format_action(get_action(u)) |
|
|
index = vop_actions.index(action) |
|
|
index = vop_actions.index(action) |
|
|
vop_gates[index] = sn+cn |
|
|
|
|
|
|
|
|
vop_gates[index] = s_name + c_name |
|
|
vop_unitaries[index] = u |
|
|
vop_unitaries[index] = u |
|
|
|
|
|
|
|
|
# Add some more useful lookups |
|
|
# Add some more useful lookups |
|
|
|
|
|
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)} |