Skip to content

Commit

Permalink
Merge pull request scipy#5910 from pv/gcrotmk
Browse files Browse the repository at this point in the history
ENH: sparse.linalg: add GCROT(m,k)
  • Loading branch information
rgommers authored Aug 24, 2017
2 parents cab477d + 50c3bf0 commit 84fd3a5
Show file tree
Hide file tree
Showing 9 changed files with 708 additions and 140 deletions.
13 changes: 11 additions & 2 deletions benchmarks/benchmarks/sparse_linalg_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

try:
from scipy import linalg, sparse
from scipy.sparse.linalg import cg, minres, spsolve
from scipy.sparse.linalg import cg, minres, gmres, spsolve
except ImportError:
pass

Expand All @@ -17,6 +17,11 @@
except ImportError:
pass

try:
from scipy.sparse.linalg import gcrotmk
except ImportError:
pass

from .common import Benchmark


Expand All @@ -38,7 +43,7 @@ def _create_sparse_poisson2d(n):
class Bench(Benchmark):
params = [
[4, 6, 10, 16, 25, 40, 64, 100],
['dense', 'spsolve', 'cg', 'minres', 'lgmres']
['dense', 'spsolve', 'cg', 'minres', 'gmres', 'lgmres', 'gcrotmk']
]
param_names = ['(n,n)', 'solver']

Expand All @@ -59,8 +64,12 @@ def time_solve(self, n, solver):
cg(self.P_sparse, self.b)
elif solver == 'minres':
minres(self.P_sparse, self.b)
elif solver == 'gmres':
gmres(self.P_sparse, self.b)
elif solver == 'lgmres':
lgmres(self.P_sparse, self.b)
elif solver == 'gcrotmk':
gcrotmk(self.P_sparse, self.b)
elif solver == 'spsolve':
spsolve(self.P_sparse, self.b)
else:
Expand Down
1 change: 1 addition & 0 deletions scipy/optimize/nonlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ def __init__(self, rdiff=None, method='lgmres', inner_maxiter=20,
self.method_kw['maxiter'] = 1
# Carry LGMRES's `outer_v` vectors across nonlinear iterations
self.method_kw.setdefault('outer_v', [])
self.method_kw.setdefault('prepend_outer_v', True)
# But don't carry the corresponding Jacobian*v products, in case
# the Jacobian changes a lot in the nonlinear step
#
Expand Down
1 change: 1 addition & 0 deletions scipy/sparse/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
lgmres -- Solve a matrix equation using the LGMRES algorithm
minres -- Use MINimum RESidual iteration to solve Ax = b
qmr -- Use Quasi-Minimal Residual iteration to solve A x = b
gcrotmk -- Solve a matrix equation using the GCROT(m,k) algorithm
Iterative methods for least-squares problems:
Expand Down
1 change: 1 addition & 0 deletions scipy/sparse/linalg/isolve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .lgmres import lgmres
from .lsqr import lsqr
from .lsmr import lsmr
from ._gcrotmk import gcrotmk

__all__ = [s for s in dir() if not s.startswith('_')]

Expand Down
Loading

0 comments on commit 84fd3a5

Please sign in to comment.