Back to Sparse Matrices
lsqr
Least-squares solution via iterative method
Syntax
x = lsqr(A, b) [x, flag] = lsqr(A, b, tol, maxit)
Description
Solves the least-squares problem min ||Ax - b||_2 using an iterative method. Delegates to conjugate gradients on the normal equations.
Parameters
| Name | Description |
|---|---|
| A | Sparse matrix (possibly non-square) |
| b | Right-hand side vector |
| tol(optional) | Convergence tolerance (default 1e-6) |
| maxit(optional) | Maximum iterations |
Returns
Solution vector x, or [x, flag]
Examples
Try It
>> x = lsqr(A, b)