x = lsmr(A, b)
x = lsmr(A, b, tol, maxit)
x = lsmr(A, b, tol, maxit, M1, M2, x0)
[x, flag, relres, iter, resvec, lsvec] = lsmr(...)
| Parameter | Description |
|---|---|
| A | a sparse real or complex floating-point matrix. |
| b | a real or complex floating-point right-hand side vector compatible with A. |
| tol | a finite real scalar convergence tolerance. Default is 1e-6. |
| maxit | a non-negative integer maximum iteration count. |
| M1, M2 | optional right preconditioners: sparse or full square matrices, diagonal vectors, or function handles. Function handles must accept a vector and a transpose flag. |
| x0 | optional initial guess vector. |
| Parameter | Description |
|---|---|
| x | computed solution vector. |
| flag | 0 when convergence is reached, 1 when maxit is reached, 4 on numerical breakdown. |
| relres | relative residual norm. |
| iter | iteration count. |
| resvec | residual norm history. |
| lsvec | normal-equation residual norm history. |
lsmr solves sparse linear equations and least-squares problems using a Golub-Kahan bidiagonalization method.
The method supports square and rectangular sparse double, single, complex double, and complex single matrices.
M1 and M2 are right preconditioners. They can be diagonal vectors, sparse or dense square matrices, or function handles accepting a vector and the transpose flag 'notransp' or 'transp'.
If any compatible input, preconditioner, or initial guess is complex, the iteration is performed in the matching complex class.
resvec stores residual norms and lsvec stores least-squares residual estimates for each iteration.
A = sparse([1 0; 0 1; 1 1; 2 -1]);
b = [1; 2; 4; 1];
[x, flag, relres, iter] = lsmr(A, b, 1e-12, 20)
A = sparse([1 0; 0 1; 1 1; 2 -1]);
b = [1; 2; 4; 1];
M1 = [2 0; 0 1];
M2 = [1 0.5; 0 3];
[x, flag, relres, iter] = lsmr(A, b, 1e-12, 20, M1, M2)
| Version | Description |
|---|---|
| 2.0.0 | initial version |
| 2.0.0 | added single, complex single, right-preconditioner, initial guess, and residual-history coverage |