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)
     assert_array_almost_equal(a*x, b)
 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).T
     x = linsolve.spsolve(a, b)
     assert_array_almost_equal(a*x, self.b)
 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)
     assert_array_almost_equal(a * x, b)
 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).T
     x = linsolve.spsolve(a, b)
     assert_array_almost_equal(a * x, self.b)
Exemple #5
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'))
     assert_array_almost_equal(a*x, b, decimal=4)
 def test_solve_complex_long_umfpack(self):
     # Solve with UMFPACK: double precision complex, long indices
     linsolve.use_solver(useUmfpack=True)
     a = _to_int64(self.a.astype('D'))
     b = self.b
     x = linsolve.spsolve(a, b)
     assert_array_almost_equal(a * x, b)
 def test_solve_complex_long_umfpack(self):
     # Solve with UMFPACK: double precision complex, long indices
     linsolve.use_solver(useUmfpack=True)
     a = _to_int64(self.a.astype('D'))
     b = self.b
     x = linsolve.spsolve(a, b)
     assert_array_almost_equal(a*x, b)
Exemple #8
0
def Presolve3d(nvec,nwells,baseKx,baseKy):
    t1=time();  nx,ny,nz=nvec; nxyz = nx*ny*nz;
    A = HydroMatrix3d(nvec,nwells,baseKx,baseKy)
    WellLocations = GenWellLocs3d(nvec,nwells)
############# set up RHS vector(s) ######################
    b=zeros((nxyz,1))
    for i in range(nx*ny):                   # check this well!
        b[i] = 0.4;
        b[nxyz-nx*ny+i] = 0.55
    b0 = zeros((nxyz,nwells))
############### solve! #####################
    xsol = zeros((nxyz,nwells+1))
    for i in range(nwells):
        b0[WellLocations[i],i]=1
        xsol[:,i] = linsolve.spsolve(A,b0[:,i],use_umfpack=False);
    xsol[:,nwells] = linsolve.spsolve(A,b,use_umfpack=False);
    return xsol
Exemple #9
0
def LinSolve(A,b,x0,method):
    if method=='bicg':
        x,info = bicg(A,b,x0)
    if method=='cgs':
        x,info = cgs(A,b,x0)
    if method=='bicgstab':
        x,info = bicgstab(A,b,x0)
        if (info): print 'INFO=',info
    if method=='superLU':
        x = linsolve.spsolve(A,b,use_umfpack=False) 
    if method=='umfpack':
        x = linsolve.spsolve(A,b,use_umfpack=True) 
    if method=='gmres':
        x,info = gmres(A,b,x0) 
    if method=='lgmres':
        x,info = lgmres(A,b,x0) 
    return x
 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)
 def test_solve_complex_without_umfpack(self):
     """Solve: single precision complex"""
     linsolve.use_solver(useUmfpack=False)
     a = self.a.astype('F')
     b = self.b
     x = linsolve.spsolve(a, b)
     # print x
     # print "Error: ", a*x-b
     assert_array_almost_equal(a*x, b, decimal=4)
Exemple #12
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 )
     x = linsolve.spsolve(a, b)
     #print x
     #print "Error: ", a*x-b
     assert_array_almost_equal(a*x, self.b)
Exemple #13
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)
Exemple #14
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
     assert_array_almost_equal(a*x, b, decimal=4)
Exemple #15
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 )
     x = linsolve.spsolve(a, b)
     #print x
     #print "Error: ", a*x-b
     assert_array_almost_equal(a*x, self.b)