From 8337af0c7ef9a230fae4c65696ab49fa9a3a775a Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Wed, 3 Aug 2016 07:53:14 +0100 Subject: [PATCH] Even nicer stabilizer tables --- abp/graphstate.py | 12 ++++++------ abp/stabilizer.py | 2 +- examples/stabilizers.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 examples/stabilizers.py diff --git a/abp/graphstate.py b/abp/graphstate.py index 989e940..1ed614a 100644 --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -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) diff --git a/abp/stabilizer.py b/abp/stabilizer.py index 43ac6d2..d85a0a0 100644 --- a/abp/stabilizer.py +++ b/abp/stabilizer.py @@ -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 diff --git a/examples/stabilizers.py b/examples/stabilizers.py new file mode 100644 index 0000000..8b82f79 --- /dev/null +++ b/examples/stabilizers.py @@ -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() +