FUNCTION REFERENCE

lsqr

Least squares QR method for a rectangular or square system.

Least squares QR method for a rectangular or square system.

Syntax

x = lsqr(A, b)

Syntax

[x, flag, relres, iter, resvec, lsvec] = lsqr(A, b, tol, maxit, M1, M2, x0, ...)

Solves min norm(b - A*x). A function handle is called as afun(x,'notransp') and afun(x,'transp'). Defaults: tol 1e-6, maxit min([size(A) 20]). lsvec holds the scaled estimates of norm(A'*r).

Example

[x, flag] = lsqr([1 2; 3 4; 5 6], [1; 2; 4])   % x = [0.6667; 0.0833]

Differences from MATLAB: Real dense or sparse matrices and real-valued function handles; complex systems are unsupported. A sparse A is used through sparse products (same values as full(A)); a sparse M1 or M2 is solved by substitution when triangular (same values as full) and otherwise factorized once per call by sparse LU. Singular dense preconditioners return flag 2 without MATLAB's singular-matrix warning.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.