def test_dense_solve_single_rhs(self): solver = QRMUMPSSolver((self.m, self.n, self.arow, self.acol, self.aval), verbose=False) solver.factorize() e = np.ones(self.n, dtype=np.float64) rhs = np.dot(self.A, e) x = solver.solve(rhs) assert np.allclose(np.dot(self.A,x), rhs, 1e-5)
def test_dense_solve_single_rhs(self): solver = QRMUMPSSolver(self.A, verbose=False) solver.factorize() e = np.ones(self.n, dtype=np.complex64) rhs = self.A * e x = solver.solve(rhs) assert np.allclose(x, e, 1e-5)
def test_dense_solve_multiple_rhs(self): solver = QRMUMPSSolver((self.m, self.n, self.arow, self.acol, self.aval), verbose=False) solver.factorize() B = np.ones([self.n, 3], dtype=np.complex64) B[: ,1] = 2 * B[:,1] B[: ,2] = 3 * B[:,2] rhs = np.dot(self.A,B) x = solver.solve(rhs) assert np.allclose(x, B, 1e-5)
def test_dense_solve_multiple_rhs(self): solver = QRMUMPSSolver(self.A, verbose=False) solver.factorize() B = np.ones([self.m, 3], dtype=np.float64) B[:, 1] = 2 * B[:, 1] B[:, 2] = 3 * B[:, 2] x = solver.solve(B) assert np.allclose(self.A * x[:, 0], B[:, 0], 1e-5) assert np.allclose(self.A * x[:, 1], B[:, 1], 1e-5) assert np.allclose(self.A * x[:, 2], B[:, 2], 1e-5)
def test_dense_solve_multiple_rhs(self): solver = QRMUMPSSolver(self.A, verbose=False) solver.factorize() B = np.ones([self.n, 3], dtype=np.complex64) B[:, 1] = 2 * B[:, 1] B[:, 2] = 3 * B[:, 2] rhs = np.ones([self.m, 3], dtype=np.complex64) rhs[:, 0] = self.A * B[:, 0] rhs[:, 1] = self.A * B[:, 1] rhs[:, 2] = self.A * B[:, 2] x = solver.solve(rhs) assert np.allclose(x, B, 1e-5)
import sys A = LLSparseMatrix(mm_filename=sys.argv[1], itype=types.INT32_T, dtype=types.COMPLEX128_T) (n, m) = A.shape print "A:" print A e = np.ones(n, dtype=np.complex128) rhs = A * e solver = QRMUMPSSolver(A, verbose=True) solver.analyze() solver.factorize() x = solver.solve(rhs) print "x should be 1-column vector:" print x print "=" * 80 rhs = np.ones([n, 3], dtype=np.complex128) rhs[:, 1] = 2 * rhs[:, 1] rhs[:, 2] = 3 * rhs[:, 2] x = solver.solve(rhs) print "x:" print x
def test_factorize(self): solver = QRMUMPSSolver(self.A, verbose=False) solver.factorize() assert solver.analyzed is True assert solver.factorized is True
aval = np.array([0.7,0.6,0.4,0.1,0.1,0.3,0.6,0.7,0.2,0.5,0.2,0.1,0.6], dtype=np.float64) print "A:" print A print "-"*80 print "Loop intantiating a solver and solving with one rhs" print "-"*80 for i in xrange(0,10): print " "+"-"*76 print " i = %d"%i print " "+"-"*76 solver = QRMUMPSSolver((m, n, arow, acol, aval), verbose=False) solver.factorize('scotch') print solver.factorization_statistics e = (i+1)*np.ones(n, dtype=np.float64) rhs = np.dot(A, e) print " rhs:" print rhs x = solver.solve(rhs) print " x:" print x print "-"*80 print "solving with multiple rhs"
def test_factorize(self): solver = QRMUMPSSolver((self.m, self.n, self.arow, self.acol, self.aval), verbose=False) solver.factorize() assert solver.analyzed==True assert solver.factorized==True