template<typename MatrixType_, typename PermutationIndex_>
class Eigen::FullPivLU< MatrixType_, PermutationIndex_ >
LU decomposition of a matrix with complete pivoting, and related features.
- Template Parameters
-
| MatrixType_ | the type of the matrix of which we are computing the LU decomposition |
This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A is decomposed as \( A = P^{-1} L U Q^{-1} \) where L is unit-lower-triangular, U is upper-triangular, and P and Q are permutation matrices. This is a rank-revealing LU decomposition. The eigenvalues (diagonal coefficients) of U are sorted in such a way that any zeros are at the end.
This decomposition provides the generic approach to solving systems of linear equations, computing the rank, invertibility, inverse, kernel, and determinant.
This LU decomposition is very stable and well tested with large matrices. However there are use cases where the SVD decomposition is inherently more stable and/or flexible. For example, when computing the kernel of a matrix, working with the SVD allows to select the smallest singular values of the matrix, something that the LU decomposition doesn't see.
The data of the LU decomposition can be directly accessed through the methods matrixLU(), permutationP(), permutationQ().
As an example, here is how the original matrix can be retrieved:
Matrix5x3 m = Matrix5x3::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is, up to permutations, its LU decomposition matrix:" << endl << lu.matrixLU() << endl;
cout << "Here is the L part:" << endl;
Matrix5x5 l = Matrix5x5::Identity();
l.block<5, 3>(0, 0).triangularView<StrictlyLower>() = lu.matrixLU();
cout << l << endl;
cout << "Here is the U part:" << endl;
Matrix5x3 u = lu.matrixLU().triangularView<
Upper>();
cout << u << endl;
cout << "Let us now reconstruct the original matrix m:" << endl;
cout << lu.permutationP().inverse() * l * u * lu.permutationQ().inverse() << endl;
LU decomposition of a matrix with complete pivoting, and related features.
Definition FullPivLU.h:70
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
@ Upper
Definition Constants.h:214
Output:
Here is the matrix m:
-0.211 0.258 -0.514
0.597 0.0268 0.608
-0.605 0.832 -0.198
0.536 0.435 -0.782
0.108 0.214 -0.563
Here is, up to permutations, its LU decomposition matrix:
0.832 -0.605 -0.198
0.522 0.852 -0.679
0.0322 0.723 1.11
0.31 -0.0281 -0.427
0.257 0.309 -0.274
Here is the L part:
1 0 0 0 0
0.522 1 0 0 0
0.0322 0.723 1 0 0
0.31 -0.0281 -0.427 1 0
0.257 0.309 -0.274 0 1
Here is the U part:
0.832 -0.605 -0.198
0 0.852 -0.679
0 0 1.11
0 0 0
0 0 0
Let us now reconstruct the original matrix m:
-0.211 0.258 -0.514
0.597 0.0268 0.608
-0.605 0.832 -0.198
0.536 0.435 -0.782
0.108 0.214 -0.563
This class supports the inplace decomposition mechanism.
- See also
- MatrixBase::fullPivLu(), MatrixBase::determinant(), MatrixBase::inverse()
|
| RealScalar | absDeterminant () const |
| |
| template<typename InputType> |
| FullPivLU & | compute (const EigenBase< InputType > &matrix) |
| |
| internal::traits< MatrixType >::Scalar | determinant () const |
| |
| Index | dimensionOfKernel () const |
| |
| | FullPivLU () |
| | Default Constructor.
|
| |
| template<typename InputType> |
| | FullPivLU (const EigenBase< InputType > &matrix) |
| |
| template<typename InputType> |
| | FullPivLU (EigenBase< InputType > &matrix) |
| | Constructs a LU factorization from a given matrix.
|
| |
| | FullPivLU (Index rows, Index cols) |
| | Default Constructor with memory preallocation.
|
| |
| const internal::image_retval< FullPivLU > | image (const MatrixType &originalMatrix) const |
| |
| ComputationInfo | info () const |
| | Reports whether the LU factorization was successful.
|
| |
| Inverse< FullPivLU > | inverse () const |
| |
| bool | isInjective () const |
| |
| bool | isInvertible () const |
| |
| bool | isSurjective () const |
| |
| const internal::kernel_retval< FullPivLU > | kernel () const |
| |
| RealScalar | logAbsDeterminant () const |
| |
| const MatrixType & | matrixLU () const |
| |
| RealScalar | maxPivot () const |
| |
| Index | nonzeroPivots () const |
| |
| const PermutationPType & | permutationP () const |
| |
| const PermutationQType & | permutationQ () const |
| |
| RealScalar | pivotCoeff (Index i) const |
| |
| Index | rank () const |
| |
| RealScalar | rcond () const |
| |
| MatrixType | reconstructedMatrix () const |
| |
| FullPivLU & | setThreshold (const RealScalar &threshold) |
| |
| FullPivLU & | setThreshold (Default_t) |
| |
| Scalar | signDeterminant () const |
| |
| template<typename Rhs> |
| Solve< FullPivLU, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| |
| RealScalar | threshold () const |
| |
| const AdjointReturnType | adjoint () const |
| |
| constexpr FullPivLU< MatrixType_, PermutationIndex_ > & | derived () |
| |
| constexpr const FullPivLU< MatrixType_, PermutationIndex_ > & | derived () const |
| |
| Solve< FullPivLU< MatrixType_, PermutationIndex_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
| |
| | SolverBase ()=default |
| |
| const ConstTransposeReturnType | transpose () const |
| |
| constexpr Index | cols () const noexcept |
| |
| constexpr FullPivLU< MatrixType_, PermutationIndex_ > & | derived () |
| |
| constexpr const FullPivLU< MatrixType_, PermutationIndex_ > & | derived () const |
| |
| constexpr Index | rows () const noexcept |
| |
| constexpr Index | size () const noexcept |
| |
| Index | dimensionOfKernel () const |
| |
| bool | isInjective () const |
| |
| bool | isInvertible () const |
| |
| bool | isSurjective () const |
| |
| RealScalar | maxPivot () const |
| |
| Index | nonzeroPivots () const |
| |
| Index | rank () const |
| |
| FullPivLU< MatrixType_, PermutationIndex_ > & | setThreshold (const RealScalar &threshold) |
| |
| FullPivLU< MatrixType_, PermutationIndex_ > & | setThreshold (Default_t) |
| |
| RealScalar | threshold () const |
| |