lgmres(A, b, x0=None, tol=1e-05, maxiter=1000, M=None, callback=None, inner_m=30, outer_k=3, outer_v=None, store_outer_Av=True, prepend_outer_v=False, atol=None)
The LGMRES algorithm is designed to avoid some problems in the convergence in restarted GMRES, and often converges in fewer iterations.
The LGMRES algorithm is designed to avoid the slowing of convergence in restarted GMRES, due to alternating residual vectors. Typically, it often outperforms GMRES(m) of comparable memory requirements by some measure, or at least is not much worse.
Another advantage in this algorithm is that you can supply it with 'guess' vectors in the :None:None:`outer_v`
argument that augment the Krylov subspace. If the solution lies close to the span of these vectors, the algorithm converges faster. This can be useful if several very similar matrices need to be inverted one after another, such as in Newton-Krylov iteration where the Jacobian matrix often changes little in the nonlinear steps.
The real or complex N-by-N matrix of the linear system. Alternatively, A
can be a linear operator which can produce Ax
using, e.g., scipy.sparse.linalg.LinearOperator
.
Right hand side of the linear system. Has shape (N,) or (N,1).
Starting guess for the solution.
Tolerances for convergence, norm(residual) <= max(tol*norm(b), atol)
. The default for atol
is :None:None:`tol`
.
The default value for :None:None:`atol`
will be changed in a future release. For future compatibility, specify :None:None:`atol`
explicitly.
Maximum number of iterations. Iteration will stop after maxiter steps even if the specified tolerance has not been achieved.
Preconditioner for A. The preconditioner should approximate the inverse of A. Effective preconditioning dramatically improves the rate of convergence, which implies that fewer iterations are needed to reach a given error tolerance.
User-supplied function to call after each iteration. It is called as callback(xk), where xk is the current solution vector.
Number of inner GMRES iterations per each outer iteration.
Number of vectors to carry between inner GMRES iterations. According to , good values are in the range of 1...3. However, note that if you want to use the additional vectors to accelerate solving multiple similar problems, larger values may be beneficial.
List containing tuples (v, Av)
of vectors and corresponding matrix-vector products, used to augment the Krylov subspace, and carried between inner GMRES iterations. The element Av
can be :None:None:`None`
if the matrix-vector product should be re-evaluated. This parameter is modified in-place by lgmres
, and can be used to pass "guess" vectors in and out of the algorithm when solving similar problems.
Whether LGMRES should store also A@v in addition to vectors v
in the :None:None:`outer_v`
list. Default is True.
Whether to put outer_v augmentation vectors before Krylov iterates. In standard LGMRES, prepend_outer_v=False.
Solve a matrix equation using the LGMRES algorithm.
>>> from scipy.sparse import csc_matrix
... from scipy.sparse.linalg import lgmres
... A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
... b = np.array([2, 4, -1], dtype=float)
... x, exitCode = lgmres(A, b)
... print(exitCode) # 0 indicates successful convergence 0
>>> np.allclose(A.dot(x), b) TrueSee :
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.sparse.linalg._isolve.lgmres.lgmres
scipy.optimize._nonlin.newton_krylov
scipy.optimize._nonlin.KrylovJacobian
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them