template<typename MatrixType_, typename Preconditioner_>
class Eigen::LSMR< MatrixType_, Preconditioner_ >
An LSMR solver for sparse (or dense) least-squares problems.
This class solves for the least-squares solution of A x = b using the LSMR algorithm of Fong and Saunders. LSMR is based on the Golub-Kahan bidiagonalization and is analytically equivalent to MINRES applied to the normal equation \( A^T A x = A^T b \), so the residual of the normal equation \( ||A^T r|| \) decreases monotonically. In exact arithmetic LSMR returns the minimum-norm least-squares solution. The matrix A can be non-symmetric and rectangular; A and the vectors x and b can be either dense or sparse. LSMR only needs A through the products \( Av \) and \( A^T u \), so a matrix-free operator may be used as well.
Unlike LeastSquaresConjugateGradient, which forms \( A^T A \) implicitly, LSMR works on A directly through the bidiagonalization and is therefore more robust on ill-conditioned problems.
- Template Parameters
-
| MatrixType_ | the type of the matrix A, can be a dense or a sparse matrix. |
| Preconditioner_ | the type of the preconditioner. Default is IdentityPreconditioner. |
This class follows the sparse solver concept .
The maximum number of iterations and the tolerance can be controlled via the setMaxIterations() and setTolerance() methods. The defaults are twice the number of columns of the matrix for the maximum number of iterations and NumTraits<Scalar>::epsilon() for the tolerance. setTolerance() sets both of the algorithm's stopping tolerances atol (relative error assumed in A) and btol (relative error assumed in b); they can also be set independently via setToleranceA() and setToleranceB().
Unlike most other iterative solvers, error() does not report the relative residual \( ||Ax-b||/||b|| \): it reports the estimate \( ||A^T r|| / (||A||\,||r||) \), with \( r = b - Ax \), of the relative residual of the normal equations, the quantity that the least-squares stopping rule bounds by atol.
The setDamping() method enables Tikhonov regularization: with a damping \( \lambda > 0 \) the solver minimizes \( ||Ax-b||^2 + \lambda^2 ||x||^2 \), for which a unique solution always exists. The setConditionLimit() method can be used to stop the iterations as soon as the estimated condition number of A exceeds a given bound.
This class can be used like the other iterative solvers. Here is a typical usage example:
int m = 1000000, n = 10000;
lsmr.compute(A);
x = lsmr.solve(b);
std::cout << "#iterations: " << lsmr.iterations() << std::endl;
std::cout << "estimated error: " << lsmr.error() << std::endl;
x = lsmr.solve(b);
LSMR()
Definition LSMR.h:370
A versatile sparse matrix representation.
Definition SparseMatrix.h:122
Matrix< double, Dynamic, 1 > VectorXd
DynamicĂ—1 vector of type double.
Definition Matrix.h:489
By default the iterations start with x=0 as an initial guess of the solution. One can control the start using the solveWithGuess() method.
If a non-default preconditioner is supplied it is applied as a self-adjoint right preconditioner (LSMR is run on \( A M^{-1} z = b \) and the solution recovered from \( M x = z \)); it should therefore be self-adjoint, as DiagonalPreconditioner and IdentityPreconditioner are.
- See also
- class LeastSquaresConjugateGradient, class ConjugateGradient, SparseLU, SparseQR
|
| RealScalar | conditionLimit () const |
| |
| RealScalar | damping () const |
| |
| | LSMR () |
| |
| template<typename MatrixDerived> |
| | LSMR (const EigenBase< MatrixDerived > &A) |
| |
| LSMR & | setConditionLimit (const RealScalar &conlim) |
| |
| LSMR & | setDamping (const RealScalar &lambda) |
| |
| LSMR & | setToleranceA (const RealScalar &atol) |
| |
| LSMR & | setToleranceB (const RealScalar &btol) |
| |
| RealScalar | toleranceA () const |
| |
| RealScalar | toleranceB () const |
| |
| LSMR< MatrixType_, Preconditioner_ > & | analyzePattern (const EigenBase< MatrixDerived > &A) |
| |
| LSMR< MatrixType_, Preconditioner_ > & | compute (const EigenBase< MatrixDerived > &A) |
| |
| RealScalar | error () const |
| |
| LSMR< MatrixType_, Preconditioner_ > & | factorize (const EigenBase< MatrixDerived > &A) |
| |
| ComputationInfo | info () const |
| |
| Index | iterations () const |
| |
| | IterativeSolverBase () |
| |
| | IterativeSolverBase (const EigenBase< MatrixDerived > &A) |
| |
| Index | maxIterations () const |
| |
| Preconditioner & | preconditioner () |
| |
| const Preconditioner & | preconditioner () const |
| |
| LSMR< MatrixType_, Preconditioner_ > & | setMaxIterations (Index maxIters) |
| |
| LSMR< MatrixType_, Preconditioner_ > & | setTolerance (const RealScalar &tolerance) |
| |
| const SolveWithGuess< LSMR< MatrixType_, Preconditioner_ >, Rhs, Guess > | solveWithGuess (const MatrixBase< Rhs > &b, const Guess &x0) const |
| |
| void | solveWithGuessInPlace (const Rhs &b, Dest &x) const |
| |
| RealScalar | tolerance () const |
| |
| Solve< LSMR< MatrixType_, Preconditioner_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| |
| Solve< LSMR< MatrixType_, Preconditioner_ >, Rhs > | solve (const SparseMatrixBase< Rhs > &b) const |
| |
| | SparseSolverBase ()=default |
| |