From ae05a679efbcd6221612a81c9219282a8ec6f9f2 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Tue, 5 Apr 2016 15:46:59 +0100 Subject: [PATCH] Starting to compute the CZ table --- cz_table.py | 20 ++++++++++++++++++++ qi.py | 4 ++++ server.py | 1 + 3 files changed, 25 insertions(+) create mode 100644 cz_table.py create mode 100644 server.py diff --git a/cz_table.py b/cz_table.py new file mode 100644 index 0000000..f6770de --- /dev/null +++ b/cz_table.py @@ -0,0 +1,20 @@ +import qi +import numpy as np +import tables +import tqdm + +# TODO: ensure that Constraint 1 is met. i.e. +# if C1 is in Z, choose C1' such that it is in Z + +bond = qi.cz * np.kron(qi.plus, qi.plus) +no_bond = np.kron(qi.plus, qi.plus) + +for u in tables.unitaries: + psi = qi.cz*np.kron(u, qi.ha)*bond + + for bb in bond, no_bond: + for a in tables.unitaries: + for b in tables.unitaries: + if np.allclose(np.kron(a, b)*bb, psi): + print "match" + diff --git a/qi.py b/qi.py index 084d7f2..35ce5a1 100644 --- a/qi.py +++ b/qi.py @@ -14,6 +14,10 @@ py = np.matrix([[0, -1j], [1j, 0]], dtype=complex) pz = np.matrix([[1, 0], [0, -1]], dtype=complex) ha = np.matrix([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2) ph = np.matrix([[1, 0], [0, 1j]], dtype=complex) +cz = np.matrix(np.eye(4), dtype=complex) +cz[3,3]=-1 + +plus = np.matrix([[1],[1]], dtype=complex) / np.sqrt(2) sqy = sqrtm(1j * py) msqy = sqrtm(-1j * py) diff --git a/server.py b/server.py new file mode 100644 index 0000000..90349df --- /dev/null +++ b/server.py @@ -0,0 +1 @@ +#TODO: this will serve an in-memory state for visualization etc in the browser