From 68e7de7088ff268a21a7df05435120f328ad7eae Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Fri, 20 May 2016 18:05:58 +0100 Subject: [PATCH] We need to emulate LocCliffOp.conjugate() -- WIP --- examples/scale.py | 12 ++++++++++++ examples/screenshot.py | 16 ++++++++++++++++ scripts/investigate_rightphase.py | 13 +++++++++++++ tests/test_conjugation.py | 15 +++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 examples/scale.py create mode 100644 examples/screenshot.py create mode 100644 scripts/investigate_rightphase.py create mode 100644 tests/test_conjugation.py diff --git a/examples/scale.py b/examples/scale.py new file mode 100644 index 0000000..9c81393 --- /dev/null +++ b/examples/scale.py @@ -0,0 +1,12 @@ +from abp import GraphState + +N = int(1e6) +g = GraphState() +g.add_nodes(xrange(N)) + +for i in range(N): + g.act_hadamard(i) + +for i in range(N): + g.act_cz(i, (i+1) % N) + diff --git a/examples/screenshot.py b/examples/screenshot.py new file mode 100644 index 0000000..6a251f5 --- /dev/null +++ b/examples/screenshot.py @@ -0,0 +1,16 @@ +from abp.fancy import GraphState +from abp.util import xyz +import numpy as np + +N = 100 +g = GraphState() +for i in range(N): + theta = 2*np.pi*i/30 + pos = xyz(5*np.cos(theta), 5*np.sin(theta), i/10.) + g.add_node(i, position = pos, vop=0) + +for i in range(N): + g.act_cz(i, (i+1) % N) + g.act_local_rotation(i, 12) + g.act_local_rotation(i, 10) + diff --git a/scripts/investigate_rightphase.py b/scripts/investigate_rightphase.py new file mode 100644 index 0000000..0da9752 --- /dev/null +++ b/scripts/investigate_rightphase.py @@ -0,0 +1,13 @@ +from anders_briegel import graphsim + +for i in range(4): + for j in range(24): + a = graphsim.LocCliffOp(i) + b = graphsim.LocCliffOp(j) + print + print i, j + print i, j, a.op, b.op + output = a.conjugate(b) + print i, j, a.op, b.op, output.ph + + diff --git a/tests/test_conjugation.py b/tests/test_conjugation.py new file mode 100644 index 0000000..bf9250d --- /dev/null +++ b/tests/test_conjugation.py @@ -0,0 +1,15 @@ +from anders_briegel import graphsim +import itertools + +#//! replaces op by trans * op * trans^dagger and returns a phase, +#/*! either +1 or -1 (as RightPhase(0) or RightPhase(2)) */ +#RightPhase conjugate (const LocCliffOp trans); + +def test_conjugation(): + """ Test that clifford.conugate() agrees with graphsim.LocCliffOp.conjugate """ + for i, j in it.product(range(4), range(24)): + a = graphsim.LocCliffOp(i) + b = graphsim.LocCliffOp(j) + output = a.conjugate(b) + print i, j, a.op, b.op, output.ph +