template<typename MatrixType_, typename OrderingType_>
class Eigen::SparseLU< MatrixType_, OrderingType_ >
Sparse supernodal LU factorization for general matrices.
This class implements the supernodal LU factorization for general matrices. It uses the main techniques from the sequential SuperLU package (http://crd-legacy.lbl.gov/~xiaoye/SuperLU/). It handles transparently real and complex arithmetic with single and double precision, depending on the scalar type of your input matrix. The code has been optimized to provide BLAS-3 operations during supernode-panel updates. It benefits directly from the built-in high-performant Eigen BLAS routines. Moreover, when the size of a supernode is very small, the BLAS calls are avoided to enable a better optimization from the compiler. For best performance, you should compile it with NDEBUG flag to avoid the numerous bounds checking on vectors.
An important parameter of this class is the ordering method. It is used to reorder the columns (and eventually the rows) of the matrix to reduce the number of new elements that are created during numerical factorization. The cheapest method available is COLAMD. See the OrderingMethods module for the list of built-in and external ordering methods.
Simple example with key steps
Definition Ordering.h:109
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
Sparse supernodal LU factorization for general matrices.
Definition SparseLU.h:151
const Solve< SparseLU, Rhs > solve(const MatrixBase< Rhs > &B) const
Solve a system .
void factorize(const MatrixType &matrix)
Factorize the matrix to get the solver ready.
Definition SparseLU.h:611
void analyzePattern(const MatrixType &matrix)
Compute the column permutation.
Definition SparseLU.h:528
A versatible sparse matrix representation.
Definition SparseUtil.h:47
We can directly call compute() instead of analyzePattern() and factorize()
void compute(const MatrixType &matrix)
Analyze and factorize the matrix so the solver is ready to solve.
Definition SparseLU.h:210
Or give the matrix to the constructor SparseLU(const MatrixType& matrix)
- Warning
- The input matrix A should be in a compressed and column-major form. Otherwise an expensive copy will be made. You can call the inexpensive makeCompressed() to get a compressed matrix.
- Note
- Unlike the initial SuperLU implementation, there is no step to equilibrate the matrix. For badly scaled matrices, this step can be useful to reduce the pivoting during factorization. If this is the case for your matrices, you can try the basic scaling method at "unsupported/Eigen/src/IterativeSolvers/Scaling.h"
- Template Parameters
-
MatrixType_ | The type of the sparse matrix. It must be a column-major SparseMatrix<> |
OrderingType_ | The ordering method to use, either AMD, COLAMD or METIS. Default is COLMAD |
This class follows the sparse solver concept .
- See also
- Sparse solver concept
-
OrderingMethods module
|
Scalar | absDeterminant () |
| Give the absolute value of the determinant.
|
|
const SparseLUTransposeView< true, SparseLU< MatrixType_, OrderingType_ > > | adjoint () |
| Return a solver for the adjointed matrix.
|
|
void | analyzePattern (const MatrixType &matrix) |
| Compute the column permutation.
|
|
Index | cols () const |
| Give the numver of columns.
|
|
const PermutationType & | colsPermutation () const |
| Give the column matrix permutation.
|
|
void | compute (const MatrixType &matrix) |
| Analyze and factorize the matrix so the solver is ready to solve.
|
|
Scalar | determinant () |
| Give the determinant.
|
|
void | factorize (const MatrixType &matrix) |
| Factorize the matrix to get the solver ready.
|
|
ComputationInfo | info () const |
| Reports whether previous computation was successful.
|
|
void | isSymmetric (bool sym) |
| Let you set that the pattern of the input matrix is symmetric.
|
|
std::string | lastErrorMessage () const |
| Give a human readable error.
|
|
Scalar | logAbsDeterminant () const |
| Give the natural log of the absolute determinant.
|
|
SparseLUMatrixLReturnType< SCMatrix > | matrixL () const |
| Give the matrixL.
|
|
SparseLUMatrixUReturnType< SCMatrix, Map< SparseMatrix< Scalar, ColMajor, StorageIndex > > > | matrixU () const |
| Give the MatrixU.
|
|
Index | nnzL () const |
| Give the number of non zero in matrix L.
|
|
Index | nnzU () const |
| Give the number of non zero in matrix U.
|
|
Index | rows () const |
| Give the number of rows.
|
|
const PermutationType & | rowsPermutation () const |
| Give the row matrix permutation.
|
|
void | setPivotThreshold (const RealScalar &thresh) |
|
Scalar | signDeterminant () |
| Give the sign of the determinant.
|
|
template<typename Rhs > |
const Solve< SparseLU, Rhs > | solve (const MatrixBase< Rhs > &B) const |
| Solve a system \( A X = B \).
|
|
| SparseLU () |
| Basic constructor of the solver.
|
|
| SparseLU (const MatrixType &matrix) |
| Constructor of the solver already based on a specific matrix.
|
|
const SparseLUTransposeView< false, SparseLU< MatrixType_, OrderingType_ > > | transpose () |
| Return a solver for the transposed matrix.
|
|
const Solve< SparseLU< MatrixType_, OrderingType_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
|
const Solve< SparseLU< MatrixType_, OrderingType_ >, Rhs > | solve (const SparseMatrixBase< Rhs > &b) const |
|
| SparseSolverBase () |
|
template<typename MatrixType , typename OrderingType >
void Eigen::SparseLU< MatrixType, OrderingType >::analyzePattern |
( |
const MatrixType & | mat | ) |
|
Compute the column permutation.
Compute the column permutation to minimize the fill-in
- Apply this permutation to the input matrix -
- Compute the column elimination tree on the permuted matrix
- Postorder the elimination tree and the column permutation
It is possible to call compute() instead of analyzePattern() + factorize().
If the matrix is row-major this function will do an heavy copy.
- See also
- factorize(), compute()
template<typename MatrixType , typename OrderingType >
void Eigen::SparseLU< MatrixType, OrderingType >::factorize |
( |
const MatrixType & | matrix | ) |
|
Factorize the matrix to get the solver ready.
- Numerical factorization
- Interleaved with the symbolic factorization
To get error of this function you should check info(), you can get more info of errors with lastErrorMessage().
In the past (before 2012 (git history is not older)), this function was returning an integer. This exit was 0 if successful factorization.
0 if info = i, and i is been completed, but the factor U is exactly singular,
and division by zero will occur if it is used to solve a system of equation.
A->ncol: number of bytes allocated when memory allocation failure occured, plus A->ncol.
If lwork = -1, it is the estimated amount of space needed, plus A->ncol.
It seems that A was the name of the matrix in the past.
- See also
- analyzePattern(), compute(), SparseLU(), info(), lastErrorMessage()