def calc_x(Kp1, C, Cm1, rp1, lm2, Am1, A, Ap1, lm1_s, lm1_si, r_s, r_si, Vsh): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] x = np.zeros((Dm1, q * D - Dm1), dtype=A.dtype) x_part = np.zeros_like(x, order='C') x_subpart = np.empty_like(A[0], order='C') #assert not (C is None and not Kp1 is None) #existence of Kp1 implies existence of C if C is not None or Kp1 is not None: for s in xrange(q): if C is None: x_subpart.fill(0) else: x_subpart = eps_r_noop_inplace(rp1, C[s], Ap1, x_subpart) #~1st line if Kp1 is not None: x_subpart += A[s].dot(Kp1) #~3rd line x_part += x_subpart.dot(r_si.dot(Vsh[s])) x += lm1_s.dot(x_part) if Cm1 is not None: Cm1T = sp.transpose(Cm1, axes=(1, 0, 2, 3)) x_part.fill(0) for s in xrange(q): #~2nd line x_subpart = eps_l_noop_inplace(lm2, Am1, Cm1T[s, :], x_subpart) x_part += x_subpart.dot(r_s.dot(Vsh[s])) x += lm1_si.dot(x_part) return x
def calc_x(Kp1, C, Cm1, rp1, lm2, Am1, A, Ap1, lm1_s, lm1_si, r_s, r_si, Vsh): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] x = np.zeros((Dm1, q * D - Dm1), dtype=A.dtype) x_part = np.empty_like(x, order='C') x_subpart = np.empty_like(A[0], order='C') assert not (C is None and not Kp1 is None) #existence of Kp1 implies existence of C if not C is None: x_part.fill(0) for s in xrange(q): x_subpart = eps_r_noop_inplace(rp1, C[s], Ap1, x_subpart) #~1st line if not Kp1 is None: x_subpart += A[s].dot(Kp1) #~3rd line x_part += x_subpart.dot(r_si.dot(Vsh[s])) x += lm1_s.dot(x_part) if not lm2 is None: Cm1T = sp.transpose(Cm1, axes=(1, 0, 2, 3)) x_part.fill(0) for s in xrange(q): #~2nd line x_subpart = eps_l_noop_inplace(lm2, Am1, Cm1T[s, :], x_subpart) x_part += x_subpart.dot(r_s.dot(Vsh[s])) x += lm1_si.dot(x_part) return x
def calc_x_3s(Kp1, C, Cm1, Cm2, rp1, rp2, lm2, lm3, Am2Am1, Am1, A, Ap1, Ap1Ap2, lm1_s, lm1_si, r_s, r_si, Vsh): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] x = np.zeros((Dm1, q * D - Dm1), dtype=A.dtype) x_part = np.empty_like(x, order='C') assert not (C is None and not Kp1 is None) if not C is None: x_part.fill(0) for s in xrange(q): x_subpart = eps_r_op_2s_C12_AA34(rp2, C[s], Ap1Ap2) #~1st line if not Kp1 is None: x_subpart += A[s].dot(Kp1) #~3rd line x_part += x_subpart.dot(r_si.dot(Vsh[s])) x += lm1_s.dot(x_part) if not lm2 is None and not Cm1 is None: x_subpart = np.empty((Am1.shape[2], D), dtype=A.dtype) x_subsubpart = np.empty((Cm1[0, 0].shape[1], D), dtype=A.dtype, order='C') qm1 = Am1.shape[0] x_part.fill(0) for t in xrange(q): #~2nd line x_subpart.fill(0) for s in xrange(qm1): eps_r_noop_inplace(rp1, Cm1[s, t], Ap1, x_subsubpart) x_subpart += (lm2.dot(Am1[s])).conj().T.dot(x_subsubpart) x_part += x_subpart.dot(r_si.dot(Vsh[t])) x += lm1_si.dot(x_part) if not lm3 is None: x_part.fill(0) for u in xrange(q): #~2nd line x_subpart = eps_l_op_2s_AA12_C34(lm3, Am2Am1, Cm2[:, :, u]) x_part += x_subpart.dot(r_s.dot(Vsh[u])) x += lm1_si.dot(x_part) return x
def calc_x_l(Km1, C, Cm1, rp1, lm2, Am1, A, Ap1, lm1_s, lm1_si, r_s, r_si, Vsh): D = A.shape[2] Dm1 = A.shape[1] q = A.shape[0] x = sp.zeros((q * Dm1 - D, D), dtype=A.dtype) x_part = sp.empty_like(x, order='C') x_subpart = sp.empty_like(A[0], order='C') if not C is None: x_part.fill(0) for s in xrange(q): x_subpart = eps_r_noop_inplace(rp1, C[s], Ap1, x_subpart) #~1st line x_part += Vsh[s].dot(lm1_s.dot(x_subpart)) try: x += r_si.dot_left(x_part) except AttributeError: x += x_part.dot(r_si) x_part.fill(0) for s in xrange(q): #~2nd line x_subpart.fill(0) if not lm2 is None: x_subpart = eps_l_noop_inplace(lm2, Am1, Cm1[:, s], x_subpart) if not Km1 is None: x_subpart += Km1.dot(A[s]) #~3rd line x_part += Vsh[s].dot(lm1_si.dot(x_subpart)) try: x += r_s.dot_left(x_part) except AttributeError: x += x_part.dot(r_s) return x