def calc_Vsh(self, n, sqrt_r): """Generates m.H(V[n][s]) for a given n, used for generating B[n][s] This is described on p. 14 of arXiv:1103.0936v2 [cond-mat.str-el] for left gauge fixing. Here, we are using right gauge fixing. Array slicing and reshaping is used to manipulate the indices as necessary. Each V[n] directly depends only on A[n] and r[n]. We return the conjugate m.H(V) because we use it in more places than V. """ R = sp.zeros((self.D[n], self.q[n], self.D[n-1]), dtype=self.typ, order='C') for s in xrange(self.q[n]): R[:,s,:] = m.mmul(sqrt_r, m.H(self.A[n][s])) R = R.reshape((self.q[n] * self.D[n], self.D[n-1])) V = m.H(ns.nullspace_qr(m.H(R))) #print (q[n]*D[n] - D[n-1], q[n]*D[n]) #print V.shape #print sp.allclose(mat(V) * mat(V).H, sp.eye(q[n]*D[n] - D[n-1])) #print sp.allclose(mat(V) * mat(Rh).H, 0) V = V.reshape((self.q[n] * self.D[n] - self.D[n - 1], self.D[n], self.q[n])) #this works with the above form for R #prepare for using V[s] and already take the adjoint, since we use it more often Vsh = sp.empty((self.q[n], self.D[n], self.q[n] * self.D[n] - self.D[n - 1]), dtype=self.typ, order=self.odr) for s in xrange(self.q[n]): Vsh[s] = m.H(V[:,:,s]) return Vsh
def calc_Vsh_l(A, lm1_sqrt, sanity_checks=False): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] if q * Dm1 - D <= 0: return None L = sp.zeros((D, q, Dm1), dtype=A.dtype, order='C') for s in xrange(q): L[:, s, :] = lm1_sqrt.dot(A[s]).conj().T L = L.reshape((D, q * Dm1)) V = ns.nullspace_qr(L) if sanity_checks: if not sp.allclose(L.dot(V), 0): log.warning("Sanity Fail in calc_Vsh_l!: LV != 0") if not sp.allclose(V.conj().T.dot(V), sp.eye(V.shape[1])): log.warning("Sanity Fail in calc_Vsh_l!: V H(V) != eye") V = V.reshape((q, Dm1, q * Dm1 - D)) Vsh = sp.transpose(V.conj(), axes=(0, 2, 1)) Vsh = sp.asarray(Vsh, order='C') if sanity_checks: M = eps_l_noop(lm1_sqrt, A, V) if not sp.allclose(M, 0): log.warning("Sanity Fail in calc_Vsh_l!: Bad Vsh") return Vsh
def calc_Vsh(A, r_s, sanity_checks=False): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] if q * D - Dm1 <= 0: return None R = sp.zeros((D, q, Dm1), dtype=A.dtype, order='C') for s in xrange(q): R[:, s, :] = r_s.dot(A[s].conj().T) R = R.reshape((q * D, Dm1)) Vconj = ns.nullspace_qr(R.conj().T).T if sanity_checks: if not sp.allclose(mm.mmul(Vconj.conj(), R), 0): log.warning("Sanity Fail in calc_Vsh!: VR != 0") if not sp.allclose(mm.mmul(Vconj, Vconj.conj().T), sp.eye(Vconj.shape[0])): log.warning("Sanity Fail in calc_Vsh!: V H(V) != eye") Vconj = Vconj.reshape((q * D - Dm1, D, q)) Vsh = Vconj.T Vsh = sp.asarray(Vsh, order='C') if sanity_checks: Vs = sp.transpose(Vsh, axes=(0, 2, 1)).conj() M = eps_r_noop(r_s, Vs, A) if not sp.allclose(M, 0): log.warning("Sanity Fail in calc_Vsh!: Bad Vsh") return Vsh
def calc_Vsh_l(A, lm1_sqrt, sanity_checks=False): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] if q * Dm1 - D <= 0: return None L = sp.zeros((D, q, Dm1), dtype=A.dtype, order='C') for s in xrange(q): L[:,s,:] = lm1_sqrt.dot(A[s]).conj().T L = L.reshape((D, q * Dm1)) V = ns.nullspace_qr(L) if sanity_checks: if not sp.allclose(L.dot(V), 0): log.warning("Sanity Fail in calc_Vsh_l!: LV != 0") if not sp.allclose(V.conj().T.dot(V), sp.eye(V.shape[1])): log.warning("Sanity Fail in calc_Vsh_l!: V H(V) != eye") V = V.reshape((q, Dm1, q * Dm1 - D)) Vsh = sp.transpose(V.conj(), axes=(0, 2, 1)) Vsh = sp.asarray(Vsh, order='C') if sanity_checks: M = eps_l_noop(lm1_sqrt, A, V) if not sp.allclose(M, 0): log.warning("Sanity Fail in calc_Vsh_l!: Bad Vsh") return Vsh
def calc_Vsh(A, r_s, sanity_checks=False): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] if q * D - Dm1 <= 0: return None R = sp.zeros((D, q, Dm1), dtype=A.dtype, order='C') for s in xrange(q): R[:,s,:] = r_s.dot(A[s].conj().T) R = R.reshape((q * D, Dm1)) Vconj = ns.nullspace_qr(R.conj().T).T if sanity_checks: if not sp.allclose(mm.mmul(Vconj.conj(), R), 0): log.warning("Sanity Fail in calc_Vsh!: VR != 0") if not sp.allclose(mm.mmul(Vconj, Vconj.conj().T), sp.eye(Vconj.shape[0])): log.warning("Sanity Fail in calc_Vsh!: V H(V) != eye") Vconj = Vconj.reshape((q * D - Dm1, D, q)) Vsh = Vconj.T Vsh = sp.asarray(Vsh, order='C') if sanity_checks: Vs = sp.transpose(Vsh, axes=(0, 2, 1)).conj() M = eps_r_noop(r_s, Vs, A) if not sp.allclose(M, 0): log.warning("Sanity Fail in calc_Vsh!: Bad Vsh") return Vsh
def calc_Vsh(self, n, sqrt_r): """Generates mm.H(V[n][s]) for a given n, used for generating B[n][s] This is described on p. 14 of arXiv:1103.0936v2 [cond-mat.str-el] for left gauge fixing. Here, we are using right gauge fixing. Array slicing and reshaping is used to manipulate the indices as necessary. Each V[n] directly depends only on A[n] and r[n]. We return the conjugate mm.H(V) because we use it in more places than V. """ R = sp.zeros((self.D[n], self.q[n], self.D[n-1]), dtype=self.typ, order='C') for s in xrange(self.q[n]): R[:,s,:] = mm.mmul(sqrt_r, mm.H(self.A[n][s])) R = R.reshape((self.q[n] * self.D[n], self.D[n-1])) Vconj = ns.nullspace_qr(mm.H(R)).T if self.sanity_checks: if not sp.allclose(mm.mmul(Vconj.conj(), R), 0): print "Sanity Fail in calc_Vsh!: VR_%u != 0" % (n) if not sp.allclose(mm.mmul(Vconj, mm.H(Vconj)), sp.eye(Vconj.shape[0])): print "Sanity Fail in calc_Vsh!: V H(V)_%u != eye" % (n) Vconj = Vconj.reshape((self.q[n] * self.D[n] - self.D[n - 1], self.D[n], self.q[n])) Vsh = Vconj.T Vsh = sp.asarray(Vsh, order='C') if self.sanity_checks: M = sp.zeros((self.q[n] * self.D[n] - self.D[n - 1], self.D[n]), dtype=self.typ) for s in xrange(self.q[n]): M += mm.mmul(mm.H(Vsh[s]), sqrt_r, mm.H(self.A[n][s])) if not sp.allclose(M, 0): print "Sanity Fail in calc_Vsh!: Bad Vsh_%u" % (n) return Vsh
def calc_Vsh(self, r_sqrt): R = np.zeros((self.D, self.q, self.D), dtype=self.typ, order='C') for s in xrange(self.q): R[:,s,:] = m.mmul(r_sqrt, m.H(self.A[s])) R = R.reshape((self.q * self.D, self.D)) Vconj = ns.nullspace_qr(m.H(R)).T #R can be pretty huge for large q and D. The decomp. can take a long time... if self.sanity_checks: if not np.allclose(np.dot(Vconj, m.H(Vconj)), np.eye(self.q*self.D - self.D)): print "Sanity check failed: V . H(V) not eye!" if not np.allclose(np.dot(Vconj.conj(), R), 0): print "Sanity check failed: V . R not zero!" Vconj = Vconj.reshape(((self.q - 1) * self.D, self.D, self.q)) #prepare for using V[s] and already take the adjoint, since we use it more often Vsh = Vconj.T Vsh = np.asarray(Vsh, order='C') return Vsh