Browse Source

Even nicer stabilizer tables

master
Pete Shadbolt 7 years ago
parent
commit
8337af0c7e
3 changed files with 18 additions and 7 deletions
  1. +6
    -6
      abp/graphstate.py
  2. +1
    -1
      abp/stabilizer.py
  3. +11
    -0
      examples/stabilizers.py

+ 6
- 6
abp/graphstate.py View File

@@ -416,12 +416,12 @@ class GraphState(object):
>>> print g.to_stabilizer()
0 1 2 3 100 200
------------------------------
X Z Z X I I
Z X Z I I I
Z Z X I I I
- Z I I Z I I
I I I I X Z
I I I I Z X
X Z Z X
Z X Z
Z Z X
- Z Z
X Z
Z X

"""
return Stabilizer(self)


+ 1
- 1
abp/stabilizer.py View File

@@ -44,7 +44,7 @@ class Stabilizer(object):
sign = self.phases[i]
sign = {1: " ", -1: " -", 1j: " i", -1j: "-i"}[sign]
row = (self.tableau[i][j] for j in sorted(self.phases))
row = ("IXYZ"[i].ljust(w) for i in row)
row = (" XYZ"[i].ljust(w) for i in row)
row = " ".join(row)
s += "{} {}\n".format(sign, row)
return s


+ 11
- 0
examples/stabilizers.py View File

@@ -0,0 +1,11 @@
from abp import GraphState

edges = (0, 1), (1, 2), (2, 0), (0, 3), (100, 200)
g = GraphState([0, 1, 2, 3, 100, 200])
g.act_circuit((i, "hadamard") for i in g.node)
g.act_circuit((edge, "cz") for edge in edges)

g.act_local_rotation(3, 9)

print g.to_stabilizer()


Loading…
Cancel
Save