Commit f65837eb authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

bugfixes: remove useless assertion, fix basis change transformation

parent ba3614c6
......@@ -21,7 +21,7 @@ from guts import sm, misc
from guts.matrix import sigma_z
def find_modes(current):
"""Calculate the transformation to basis where current is sigma_z
"""Calculate the transformation to basis where current is sigma_z.
Returns matrix t such that t.H * m * t transforms matrix m to the desired
basis.
......@@ -39,7 +39,7 @@ def find_modes(current):
return t
def v_to_current(v, t):
"""Transform v to the current basis, specified by a transformation t
"""Transform v to the current basis, specified by a transformation t.
t is a list of square matrices with total dimension of these matrices
equal to dimension of v, the mode mixing matrix.
......@@ -57,10 +57,10 @@ def v_to_current(v, t):
x = np.array(range(n))
y = []
for i in t:
k, l = len(y), i.shape[0] // 2
y += range(k, k + l) + range(k + l, k + 2*l)
k, l = len(y) // 2, i.shape[0] // 2
y += range(k, k + l) + range(n//2 + k, n//2 + k + l)
y = np.array(y)
t2 = sp.coo_matrix((x, (x, y)), shape=(n, n))
t2 = sp.coo_matrix((np.array(n * [1]), (x, y)), shape=(n, n))
t1 = t1 * sp.csr_matrix(t2)
v1 = t1.H * v * t1
......
......@@ -80,8 +80,6 @@ class SMatrix(object):
This function does not use LU deconmposition for efficiency yet, so it
may be optimized.
"""
assert (self.t != None and self.tp != None and self.r != None and
self.rp != None)
(u, tran, vp) = la.svd(self.tp)
tran = tran**2
(u, vp) = (np.mat(u), np.mat(vp))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment