Bladeren bron

Just learnt something about stabilizers ...

master
Pete Shadbolt 8 jaren geleden
bovenliggende
commit
31a4f52b2d
3 gewijzigde bestanden met toevoegingen van 31 en 17 verwijderingen
  1. +19
    -2
      abp.py
  2. +12
    -0
      tests/test_graph.py
  3. +0
    -15
      tests/test_stabilizer.py

+ 19
- 2
abp.py Bestand weergeven

@@ -6,11 +6,28 @@ Porting Anders and Briegel to Python

stab_rep = {None: "-", 0: "X", 1: "Y", 2: "Z"}


def rightphase(n):
""" This is dumb. TODO: get rid """
return n % 4


class Stabilizer(object):

def __init__(self, graph):
self.paulis = [[None for i in range(graph.nqubits)]
for j in range(graph.nqubits)]
n = graph.nqubits
self.paulis = [[None for i in range(n)] for j in range(n)]
self.signs = [None for i in range(n)]

for i in range(n):
signs[i] = 0
for j in range(n):
if i == j:
self.paulis[i][j] = lco_x
elif j in g.vertices[i].neighbors:
self.paulis[i][j] = lco_z
else:
self.paulis[i][j] = lco_id

def __str__(self):
return "\n".join(" ".join(stab_rep[x] for x in row) for row in self.paulis)


+ 12
- 0
tests/test_graph.py Bestand weergeven

@@ -14,3 +14,15 @@ def test_adding():
g.toggle_edge(3,2)
assert(len(g.edgelist()) == 3)

def setup_stab():
global g
g = abp.GraphRegister(10)
g.add_edge(0,1)
g.add_edge(1,2)
g.add_edge(2,0)

@with_setup(setup_stab)
def test_adding():
s = abp.Stabilizer(g)
print s


+ 0
- 15
tests/test_stabilizer.py Bestand weergeven

@@ -1,15 +0,0 @@
from nose import with_setup
import abp

def setup():
global g
g = abp.GraphRegister(10)
g.add_edge(0,1)
g.add_edge(1,2)
g.add_edge(2,0)

@with_setup(setup)
def test_adding():
s = abp.Stabilizer(g)
print s


Laden…
Annuleren
Opslaan