Example #1
0
 def test_solve_sparse_rhs(self):
     """Solve with UMFPACK: double precision, sparse rhs"""
     linsolve.use_solver( useUmfpack = True )
     a = self.a.astype('d')
     b = csc_matrix( self.b.reshape((5,1)) )
     x = linsolve.spsolve(a, b)
     #print x
     #print "Error: ", a*x-b
     assert_array_almost_equal(a*x, self.b)
Example #2
0
 def test_solve_umfpack(self):
     """Solve with UMFPACK: double precision"""
     linsolve.use_solver( useUmfpack = True )
     a = self.a.astype('d')
     b = self.b
     x = linsolve.spsolve(a, b)
     #print x
     #print "Error: ", a*x-b
     assert_array_almost_equal(a*x, b)
Example #3
0
    def test_factorized_umfpack(self):
        """Prefactorize (with UMFPACK) matrix for solving with multiple rhs"""
        linsolve.use_solver( useUmfpack = True )
        a = self.a.astype('d')
        solve = linsolve.factorized( a )

        x1 = solve( self.b )
        assert_array_almost_equal(a*x1, self.b)
        x2 = solve( self.b2 )
        assert_array_almost_equal(a*x2, self.b2)
Example #4
0
 def test_solve_without_umfpack(self):
     """Solve: single precision"""
     linsolve.use_solver( useUmfpack = False )
     a = self.a.astype('f')
     b = self.b
     x = linsolve.spsolve(a, b.astype('f'))
     #print x
     #print "Error: ", a*x-b
     # single precision: be more generous...
     assert_array_almost_equal(a*x, b, decimal = 5)
Example #5
0
 def test_solve_complex_without_umfpack(self):
     """Solve: single precision complex"""
     linsolve.use_solver( useUmfpack = False )
     a = self.a
     a.data = a.data.astype('F',casting='unsafe')
     b = self.b
     b = b.astype('F')
     x = linsolve.spsolve(a, b)
     #print x
     #print "Error: ", a*x-b
     assert_array_almost_equal(a*x, b)