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_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