![]() |
Eigen
5.0.1
|
#include <Eigen/src/SparseQR/SparseQR.h>
Sparse left-looking QR factorization with numerical column pivoting.
This class implements a left-looking QR decomposition of sparse matrices with numerical column pivoting. When a column has a norm less than a given tolerance it is implicitly permuted to the end. The QR factorization thus obtained is given by A*P = Q*R where R is upper triangular or trapezoidal.
P is the column permutation which is the product of the fill-reducing and the numerical permutations. Use colsPermutation() to get it.
Q is the orthogonal matrix represented as products of Householder reflectors. Use matrixQ() to get an expression and matrixQ().adjoint() to get the adjoint. You can then apply it to a vector.
R is the sparse triangular or trapezoidal matrix. The latter occurs when A is rank-deficient. matrixR().topLeftCorner(rank(), rank()) always returns a triangular factor of full rank.
| MatrixType_ | The type of the sparse matrix A, must be a column-major SparseMatrix<> |
| OrderingType_ | The fill-reducing ordering method. See the OrderingMethods module for the list of built-in and external ordering methods. |
This class follows the sparse solver concept .
The default pivot threshold follows SuiteSparse QR and is detailed in the following paper: Tim Davis, "Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing Sparse QR Factorization", ACM Trans. on Math. Soft. 38(1), 2011. With the default threshold, Eigen also uses a bounded best-effort look-ahead to reject a pivot that is tiny relative to its candidate column if later columns provide enough stronger replacement pivots. This avoids accepting replaceable roundoff pivots after the fill-in reducing permutation. If this look-ahead exceeds its work or storage budget, the factorization keeps the usual default-threshold behavior for that pivot. Even though it is qualified as "rank-revealing", this strategy might fail for some rank deficient problems. When this class is used to solve linear or least-square problems it is thus strongly recommended to check the accuracy of the computed solution. If it failed, it usually helps to increase the threshold with setPivotThreshold.
Inheritance diagram for Eigen::SparseQR< MatrixType_, OrderingType_ >:Public Member Functions | |
| void | analyzePattern (const MatrixType &mat) |
| Preprocessing step of a QR factorization. | |
| Index | cols () const |
| const PermutationType & | colsPermutation () const |
| void | compute (const MatrixType &mat) |
| void | factorize (const MatrixType &mat) |
| Performs the numerical QR factorization of the input matrix. | |
| ComputationInfo | info () const |
| Reports whether previous computation was successful. | |
| std::string | lastErrorMessage () const |
| bool | lastPivotLookAheadSkipped () const |
| SparseQRMatrixQReturnType< SparseQR > | matrixQ () const |
| const QRMatrixType & | matrixR () const |
| Index | rank () const |
| Index | rows () const |
| void | setPivotThreshold (const RealScalar &threshold) |
| template<typename Rhs> | |
| Solve< SparseQR, Rhs > | solve (const MatrixBase< Rhs > &B) const |
| SparseQR (const MatrixType &mat) | |
Public Member Functions inherited from Eigen::SparseSolverBase< SparseQR< MatrixType_, OrderingType_ > > | |
| Solve< SparseQR< MatrixType_, OrderingType_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| Solve< SparseQR< MatrixType_, OrderingType_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| Solve< SparseQR< MatrixType_, OrderingType_ >, Rhs > | solve (const SparseMatrixBase< Rhs > &b) const |
| Solve< SparseQR< MatrixType_, OrderingType_ >, Rhs > | solve (const SparseMatrixBase< Rhs > &b) const |
| SparseSolverBase ()=default | |
| SparseSolverBase ()=default | |
|
inlineexplicit |
Construct a QR factorization of the matrix mat.
| void Eigen::SparseQR< MatrixType, OrderingType >::analyzePattern | ( | const MatrixType & | mat | ) |
Preprocessing step of a QR factorization.
In this step, the fill-reducing permutation is computed and applied to the columns of A and the column elimination tree is computed as well. Only the sparsity pattern of mat is exploited.
|
inline |
|
inline |
|
inline |
Computes the QR factorization of the sparse matrix mat.
| void Eigen::SparseQR< MatrixType, OrderingType >::factorize | ( | const MatrixType & | mat | ) |
Performs the numerical QR factorization of the input matrix.
The function SparseQR::analyzePattern(const MatrixType&) must have been called beforehand with a matrix having the same sparsity pattern than mat.
| mat | The sparse column-major matrix |
|
inline |
Reports whether previous computation was successful.
Success if computation was successful, NumericalIssue if the QR factorization reports a numerical problem InvalidInput if the input matrix is invalid
|
inline |
|
inline |
This flag is reset at the start of factorize(). It can only become true when the default pivot threshold is in use; setting an explicit pivot threshold disables the look-ahead.
|
inline |
To get a plain SparseMatrix representation of Q:
Internally, this call simply performs a sparse product between the matrix Q and a sparse identity matrix. However, due to the fact that the sparse reflectors are stored unsorted, two transpositions are needed to sort them before performing the product.
|
inline |
To sort the entries, you can assign it to a row-major matrix, and if a column-major matrix is required, you can copy it again:
|
inline |
|
inline |
|
inline |
Sets the threshold that is used to determine linearly dependent columns during the factorization.
In practice, if during the factorization the norm of the column that has to be eliminated is below this threshold, then the entire column is treated as zero, and it is moved at the end. Setting an explicit threshold disables the additional default-mode check for replaceable roundoff pivots.
|
inline |