Ver código fonte

Even nicer stabilizer tables

master
Pete Shadbolt 8 anos atrás
pai
commit
8337af0c7e
3 arquivos alterados com 18 adições e 7 exclusões
  1. +6
    -6
      abp/graphstate.py
  2. +1
    -1
      abp/stabilizer.py
  3. +11
    -0
      examples/stabilizers.py

+ 6
- 6
abp/graphstate.py Ver arquivo

@@ -416,12 +416,12 @@ class GraphState(object):
>>> print g.to_stabilizer() >>> print g.to_stabilizer()
0 1 2 3 100 200 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) return Stabilizer(self)


+ 1
- 1
abp/stabilizer.py Ver arquivo

@@ -44,7 +44,7 @@ class Stabilizer(object):
sign = self.phases[i] sign = self.phases[i]
sign = {1: " ", -1: " -", 1j: " i", -1j: "-i"}[sign] sign = {1: " ", -1: " -", 1j: " i", -1j: "-i"}[sign]
row = (self.tableau[i][j] for j in sorted(self.phases)) 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) row = " ".join(row)
s += "{} {}\n".format(sign, row) s += "{} {}\n".format(sign, row)
return s return s


+ 11
- 0
examples/stabilizers.py Ver arquivo

@@ -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()


Carregando…
Cancelar
Salvar