Browse Source

Building and storing tables

master
Pete Shadbolt 8 years ago
parent
commit
62633d40ff
4 changed files with 16 additions and 16 deletions
  1. +11
    -16
      clifford.py
  2. +1
    -0
      ct.txt
  3. +3
    -0
      tests/test_clifford.py
  4. +1
    -0
      tt.txt

+ 11
- 16
clifford.py View File

@@ -12,6 +12,7 @@ Following the prescription of Anders (thesis pg. 26):
"""

from numpy import *
from tqdm import tqdm

def find_up_to_phase(u):
""" Find the index of a given u within a list of unitaries, up to a global phase """
@@ -22,27 +23,21 @@ def find_up_to_phase(u):
return i, phase
raise IndexError

def construct_tables():
""" Constructs multiplication and conjugation tables """
permutations = (id, ha, ph, ha*ph, ha*ph*ha, ha*ph*ha*ph)
signs = (id, px, py, pz)
unitaries = [p*s for p in permutations for s in signs]
conjugation_table = [find_up_to_phase(u.H)[0] for i, u in enumerate(unitaries)]
times_table = [[find_up_to_phase(u*v)[0] for v in unitaries]
for u in tqdm(unitaries, "Building times-table")]

id = 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)
ha = matrix([[1, 1], [1, -1]], dtype=complex) / sqrt(2)
ph= matrix([[1, 0], [0, 1j]], dtype=complex)

permutations = (id, ha, ph, ha*ph, ha*ph*ha, ha*ph*ha*ph)
signs = (id, px, py, pz)
unitaries = [p*s for p in permutations for s in signs]

conjugation_table = []

for i, u in enumerate(unitaries):
i, phase = find_up_to_phase(u.H)
conjugation_table.append(i)
ph = matrix([[1, 0], [0, 1j]], dtype=complex)


# TODO:
# - check that we re-generate the table
# - do conjugation
# - do times table
# - write tests


+ 1
- 0
ct.txt View File

@@ -0,0 +1 @@
[0, 1, 2, 3, 4, 7, 6, 5, 11, 9, 10, 8, 20, 22, 23, 21, 17, 16, 18, 19, 12, 15, 13, 14]

+ 3
- 0
tests/test_clifford.py View File

@@ -61,3 +61,6 @@ def test_conjugation_table():
""" Check that the table of Hermitian conjugates is okay """
assert len(set(lc.conjugation_table))==24

def test_times_table():
""" Check the times table """
assert lc.times_table[0][4]==4

+ 1
- 0
tt.txt View File

@@ -0,0 +1 @@
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], [1, 0, 3, 2, 7, 6, 5, 4, 10, 11, 8, 9, 15, 14, 13, 12, 17, 16, 19, 18, 22, 23, 20, 21], [2, 3, 0, 1, 6, 7, 4, 5, 9, 8, 11, 10, 13, 12, 15, 14, 19, 18, 17, 16, 23, 22, 21, 20], [3, 2, 1, 0, 5, 4, 7, 6, 11, 10, 9, 8, 14, 15, 12, 13, 18, 19, 16, 17, 21, 20, 23, 22], [4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, 21, 20, 23, 22, 17, 16, 19, 18], [5, 4, 7, 6, 3, 2, 1, 0, 14, 15, 12, 13, 11, 10, 9, 8, 20, 21, 22, 23, 19, 18, 17, 16], [6, 7, 4, 5, 2, 3, 0, 1, 13, 12, 15, 14, 9, 8, 11, 10, 22, 23, 20, 21, 18, 19, 16, 17], [7, 6, 5, 4, 1, 0, 3, 2, 15, 14, 13, 12, 10, 11, 8, 9, 23, 22, 21, 20, 16, 17, 18, 19], [8, 9, 10, 11, 21, 20, 23, 22, 3, 2, 1, 0, 17, 16, 19, 18, 15, 14, 13, 12, 4, 5, 6, 7], [9, 8, 11, 10, 22, 23, 20, 21, 1, 0, 3, 2, 18, 19, 16, 17, 14, 15, 12, 13, 6, 7, 4, 5], [10, 11, 8, 9, 23, 22, 21, 20, 2, 3, 0, 1, 16, 17, 18, 19, 12, 13, 14, 15, 7, 6, 5, 4], [11, 10, 9, 8, 20, 21, 22, 23, 0, 1, 2, 3, 19, 18, 17, 16, 13, 12, 15, 14, 5, 4, 7, 6], [12, 13, 14, 15, 16, 17, 18, 19, 7, 6, 5, 4, 20, 21, 22, 23, 11, 10, 9, 8, 0, 1, 2, 3], [13, 12, 15, 14, 19, 18, 17, 16, 5, 4, 7, 6, 23, 22, 21, 20, 10, 11, 8, 9, 2, 3, 0, 1], [14, 15, 12, 13, 18, 19, 16, 17, 6, 7, 4, 5, 21, 20, 23, 22, 8, 9, 10, 11, 3, 2, 1, 0], [15, 14, 13, 12, 17, 16, 19, 18, 4, 5, 6, 7, 22, 23, 20, 21, 9, 8, 11, 10, 1, 0, 3, 2], [16, 17, 18, 19, 12, 13, 14, 15, 20, 21, 22, 23, 7, 6, 5, 4, 1, 0, 3, 2, 10, 11, 8, 9], [17, 16, 19, 18, 15, 14, 13, 12, 22, 23, 20, 21, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11], [18, 19, 16, 17, 14, 15, 12, 13, 21, 20, 23, 22, 6, 7, 4, 5, 2, 3, 0, 1, 9, 8, 11, 10], [19, 18, 17, 16, 13, 12, 15, 14, 23, 22, 21, 20, 5, 4, 7, 6, 3, 2, 1, 0, 11, 10, 9, 8], [20, 21, 22, 23, 11, 10, 9, 8, 19, 18, 17, 16, 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15], [21, 20, 23, 22, 8, 9, 10, 11, 17, 16, 19, 18, 3, 2, 1, 0, 5, 4, 7, 6, 14, 15, 12, 13], [22, 23, 20, 21, 9, 8, 11, 10, 18, 19, 16, 17, 1, 0, 3, 2, 7, 6, 5, 4, 15, 14, 13, 12], [23, 22, 21, 20, 10, 11, 8, 9, 16, 17, 18, 19, 2, 3, 0, 1, 6, 7, 4, 5, 13, 12, 15, 14]]

Loading…
Cancel
Save