fix dot array alignment (#2705)

This commit is contained in:
Paul Nation 2019-06-28 17:08:18 -04:00 committed by GitHub
parent 3264d0fd90
commit 95163828d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 15 deletions

View File

@ -104,7 +104,7 @@ def decompose_two_qubit_product_gate(special_unitary_matrix):
# extract the left component # extract the left component
temp = np.kron(np.eye(2), R.T.conj()) temp = np.kron(np.eye(2), R.T.conj())
special_unitary_matrix.dot(temp, temp) temp = special_unitary_matrix.dot(temp)
L = temp[::2, ::2] L = temp[::2, ::2]
detL = L[0, 0]*L[1, 1] - L[0, 1]*L[1, 0] detL = L[0, 0]*L[1, 1] - L[0, 1]*L[1, 0]
if abs(detL) < 0.9: if abs(detL) < 0.9:
@ -198,35 +198,35 @@ class TwoQubitWeylDecomposition:
# Flip into Weyl chamber # Flip into Weyl chamber
if cs[0] > pi2: if cs[0] > pi2:
cs[0] -= 3*pi2 cs[0] -= 3*pi2
K1l.dot(_ipy, out=K1l) K1l = K1l.dot(_ipy)
K1r.dot(_ipy, out=K1r) K1r = K1r.dot(_ipy)
if cs[1] > pi2: if cs[1] > pi2:
cs[1] -= 3*pi2 cs[1] -= 3*pi2
K1l.dot(_ipx, out=K1l) K1l = K1l.dot(_ipx)
K1r.dot(_ipx, out=K1r) K1r = K1r.dot(_ipx)
conjs = 0 conjs = 0
if cs[0] > pi4: if cs[0] > pi4:
cs[0] = pi2-cs[0] cs[0] = pi2-cs[0]
K1l.dot(_ipy, out=K1l) K1l = K1l.dot(_ipy)
_ipy.dot(K2r, out=K2r) K2r = _ipy.dot(K2r)
conjs += 1 conjs += 1
if cs[1] > pi4: if cs[1] > pi4:
cs[1] = pi2-cs[1] cs[1] = pi2-cs[1]
K1l.dot(_ipx, out=K1l) K1l = K1l.dot(_ipx)
_ipx.dot(K2r, out=K2r) K2r = _ipx.dot(K2r)
conjs += 1 conjs += 1
if cs[2] > pi2: if cs[2] > pi2:
cs[2] -= 3*pi2 cs[2] -= 3*pi2
K1l.dot(_ipz, out=K1l) K1l = K1l.dot(_ipz)
K1r.dot(_ipz, out=K1r) K1r = K1r.dot(_ipz)
if conjs == 1: if conjs == 1:
cs[2] = pi2-cs[2] cs[2] = pi2-cs[2]
K1l.dot(_ipz, out=K1l) K1l = K1l.dot(_ipz)
_ipz.dot(K2r, out=K2r) K2r = _ipz.dot(K2r)
if cs[2] > pi4: if cs[2] > pi4:
cs[2] -= pi2 cs[2] -= pi2
K1l.dot(_ipz, out=K1l) K1l = K1l.dot(_ipz)
K1r.dot(_ipz, out=K1r) K1r = K1r.dot(_ipz)
self.a = cs[1] self.a = cs[1]
self.b = cs[0] self.b = cs[0]
self.c = cs[2] self.c = cs[2]