def getAuxMatrix(A): ''' return D, L, U matrices for Jacobi or Gauss-Seidel D: array L, U: matrices ''' # m = A.shape[0] D = csr_matrix.diagonal(A) L = -tril(A, k=-1) U = -triu(A, k=1) return D, L, U
def gauss_seidel(A): L_D = ex.tril(A, 1) return lambda u: splin.spsolve(L_D, u)
def test_tril(self): for A in self.cases: B = A.toarray() for k in [-3, -2, -1, 0, 1, 2, 3]: assert_equal(extract.tril(A, k=k).toarray(), np.tril(B, k=k))
def test_tril(self): for A in self.cases: B = A.toarray() for k in [-3,-2,-1,0,1,2,3]: assert_equal(extract.tril(A,k=k).toarray(), np.tril(B,k=k))