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

NameDescription
ASparse matrix (possibly non-square)
bRight-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)

See Also