diff --git a/pymatsolver/iterative.py b/pymatsolver/iterative.py index 00f99bf..65165b2 100644 --- a/pymatsolver/iterative.py +++ b/pymatsolver/iterative.py @@ -8,13 +8,20 @@ SolverCG = WrapIterative(cg, name="SolverCG") SolverBiCG = WrapIterative(bicgstab, name="SolverBiCG") +import scipy +_rtol_call = False +scipy_major, scipy_minor, scipy_patch = scipy.__version__.split(".") +if int(scipy_major) >= 1 and int(scipy_minor) >= 12: + _rtol_call = True + class BiCGJacobi(Base): """Bicg Solver with Jacobi preconditioner""" _factored = False solver = None maxiter = 1000 - tol = 1E-6 + rtol = 1E-6 + atol = 0.0 def __init__(self, A, symmetric=True): self.A = A @@ -30,13 +37,21 @@ def factor(self): self.M = sp.linalg.interface.aslinearoperator(Ainv) self._factored = True + @property + def _tols(self): + if _rtol_call: + return {'rtol': self.rtol, 'atol': self.atol} + else: + return {'tol': self.rtol, 'atol': self.atol} + + def _solve1(self, rhs): self.factor() sol, info = self.solver( self.A, rhs, - atol=self.tol, maxiter=self.maxiter, - M=self.M + M=self.M, + **self._tols, ) return sol @@ -45,7 +60,8 @@ def _solveM(self, rhs): sol = [] for icol in range(rhs.shape[1]): sol.append(self.solver(self.A, rhs[:, icol].flatten(), - atol=self.tol, maxiter=self.maxiter, M=self.M)[0]) + maxiter=self.maxiter, M=self.M, + **self._tols,)[0]) out = np.hstack(sol) out.shape return out diff --git a/setup.py b/setup.py index 4310485..14b8e9a 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup( name="pymatsolver", version="0.2.0", - packages=find_packages(exclude=["*mumps", "tests"]), + packages=find_packages(exclude=["tests"]), install_requires=[ 'numpy>=1.7', 'scipy>=0.13', diff --git a/tests/test_BicgJacobi.py b/tests/test_BicgJacobi.py index 24e41a5..29b04ea 100644 --- a/tests/test_BicgJacobi.py +++ b/tests/test_BicgJacobi.py @@ -46,7 +46,7 @@ def test_T(self): Ainv.clean() -class TestPardisoComplex(unittest.TestCase): +class TestBicgJacobiComplex(unittest.TestCase): def setUp(self): nSize = 100