LU decomposition of a matrix with complete pivoting, and related features.
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 = PLUQ 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 exemple, here is how the original matrix can be retrieved:
Output:
Definition at line 58 of file FullPivLU.h.
#include <src/LU/FullPivLU.h>
Public Types | |
enum | { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime } |
typedef _MatrixType | MatrixType |
typedef MatrixType::Scalar | Scalar |
typedef NumTraits< typename MatrixType::Scalar >::Real | RealScalar |
typedef internal::traits < MatrixType >::StorageKind | StorageKind |
typedef MatrixType::Index | Index |
typedef internal::plain_row_type < MatrixType, Index >::type | IntRowVectorType |
typedef internal::plain_col_type < MatrixType, Index >::type | IntColVectorType |
typedef PermutationMatrix < ColsAtCompileTime, MaxColsAtCompileTime > | PermutationQType |
typedef PermutationMatrix < RowsAtCompileTime, MaxRowsAtCompileTime > | PermutationPType |
Public Member Functions | |
FullPivLU () | |
Default Constructor. | |
FullPivLU (Index rows, Index cols) | |
Default Constructor with memory preallocation. | |
FullPivLU (const MatrixType &matrix) | |
Constructor. | |
FullPivLU & | compute (const MatrixType &matrix) |
Computes the LU decomposition of the given matrix. | |
const MatrixType & | matrixLU () const |
Index | nonzeroPivots () const |
RealScalar | maxPivot () const |
const PermutationPType & | permutationP () const |
const PermutationQType & | permutationQ () const |
const internal::kernel_retval < FullPivLU > | kernel () const |
const internal::image_retval < FullPivLU > | image (const MatrixType &originalMatrix) const |
template<typename Rhs > | |
const internal::solve_retval < FullPivLU, Rhs > | solve (const MatrixBase< Rhs > &b) const |
internal::traits< MatrixType > ::Scalar | determinant () const |
FullPivLU & | setThreshold (const RealScalar &threshold) |
Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine when pivots are to be considered nonzero. | |
FullPivLU & | setThreshold (Default_t) |
Allows to come back to the default behavior, letting Eigen use its default formula for determining the threshold. | |
RealScalar | threshold () const |
Returns the threshold that will be used by certain methods such as rank(). | |
Index | rank () const |
Index | dimensionOfKernel () const |
bool | isInjective () const |
bool | isSurjective () const |
bool | isInvertible () const |
const internal::solve_retval < FullPivLU, typename MatrixType::IdentityReturnType > | inverse () const |
MatrixType | reconstructedMatrix () const |
Index | rows () const |
Index | cols () const |
Protected Attributes | |
MatrixType | m_lu |
PermutationPType | m_p |
PermutationQType | m_q |
IntColVectorType | m_rowsTranspositions |
IntRowVectorType | m_colsTranspositions |
Index | m_det_pq |
Index | m_nonzero_pivots |
RealScalar | m_maxpivot |
RealScalar | m_prescribedThreshold |
bool | m_isInitialized |
bool | m_usePrescribedThreshold |
Definition at line 72 of file FullPivLU.h.
typedef internal::plain_col_type<MatrixType, Index>::type FullPivLU< _MatrixType >::IntColVectorType |
Definition at line 74 of file FullPivLU.h.
typedef internal::plain_row_type<MatrixType, Index>::type FullPivLU< _MatrixType >::IntRowVectorType |
Definition at line 73 of file FullPivLU.h.
typedef _MatrixType FullPivLU< _MatrixType >::MatrixType |
Definition at line 61 of file FullPivLU.h.
typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> FullPivLU< _MatrixType >::PermutationPType |
Definition at line 76 of file FullPivLU.h.
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> FullPivLU< _MatrixType >::PermutationQType |
Definition at line 75 of file FullPivLU.h.
typedef NumTraits<typename MatrixType::Scalar>::Real FullPivLU< _MatrixType >::RealScalar |
Definition at line 70 of file FullPivLU.h.
Definition at line 69 of file FullPivLU.h.
typedef internal::traits<MatrixType>::StorageKind FullPivLU< _MatrixType >::StorageKind |
Definition at line 71 of file FullPivLU.h.
anonymous enum |
Definition at line 62 of file FullPivLU.h.
FullPivLU< MatrixType >::FullPivLU | ( | ) |
Default Constructor.
The default constructor is useful in cases in which the user intends to perform decompositions via LU::compute(const MatrixType&).
Definition at line 398 of file FullPivLU.h.
FullPivLU< MatrixType >::FullPivLU | ( | Index | rows, |
Index | cols | ||
) |
Default Constructor with memory preallocation.
Like the default constructor but with preallocation of the internal data according to the specified problem size.
Definition at line 404 of file FullPivLU.h.
FullPivLU< MatrixType >::FullPivLU | ( | const MatrixType & | matrix | ) |
Constructor.
matrix | the matrix of which to compute the LU decomposition. It is required to be nonzero. |
Definition at line 416 of file FullPivLU.h.
References FullPivLU< _MatrixType >::compute().
Definition at line 384 of file FullPivLU.h.
References FullPivLU< _MatrixType >::m_lu.
Referenced by FullPivLU< _MatrixType >::dimensionOfKernel(), and FullPivLU< _MatrixType >::isInjective().
FullPivLU< MatrixType > & FullPivLU< MatrixType >::compute | ( | const MatrixType & | matrix | ) |
Computes the LU decomposition of the given matrix.
matrix | the matrix of which to compute the LU decomposition. It is required to be nonzero. |
Definition at line 429 of file FullPivLU.h.
References mrpt::math::size().
Referenced by FullPivLU< _MatrixType >::FullPivLU().
internal::traits< MatrixType >::Scalar FullPivLU< MatrixType >::determinant | ( | ) | const |
Definition at line 522 of file FullPivLU.h.
References eigen_assert.
Definition at line 322 of file FullPivLU.h.
References FullPivLU< _MatrixType >::cols(), eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::rank().
const internal::image_retval<FullPivLU> FullPivLU< _MatrixType >::image | ( | const MatrixType & | originalMatrix | ) | const [inline] |
originalMatrix | the original matrix, of which *this is the LU decomposition. The reason why it is needed to pass it here, is that this allows a large optimization, as otherwise this method would need to reconstruct it from the LU decomposition. |
Example:
Output:
Definition at line 200 of file FullPivLU.h.
References eigen_assert, and FullPivLU< _MatrixType >::m_isInitialized.
const internal::solve_retval<FullPivLU,typename MatrixType::IdentityReturnType> FullPivLU< _MatrixType >::inverse | ( | ) | const [inline] |
Definition at line 373 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_lu.
bool FullPivLU< _MatrixType >::isInjective | ( | ) | const [inline] |
Definition at line 335 of file FullPivLU.h.
References FullPivLU< _MatrixType >::cols(), eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::rank().
Referenced by FullPivLU< _MatrixType >::isInvertible().
bool FullPivLU< _MatrixType >::isInvertible | ( | ) | const [inline] |
Definition at line 360 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::isInjective(), FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_lu.
bool FullPivLU< _MatrixType >::isSurjective | ( | ) | const [inline] |
Definition at line 348 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, FullPivLU< _MatrixType >::rank(), and FullPivLU< _MatrixType >::rows().
const internal::kernel_retval<FullPivLU> FullPivLU< _MatrixType >::kernel | ( | ) | const [inline] |
Example:
Output:
Definition at line 174 of file FullPivLU.h.
References eigen_assert, and FullPivLU< _MatrixType >::m_isInitialized.
const MatrixType& FullPivLU< _MatrixType >::matrixLU | ( | ) | const [inline] |
Definition at line 116 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_lu.
RealScalar FullPivLU< _MatrixType >::maxPivot | ( | ) | const [inline] |
Definition at line 138 of file FullPivLU.h.
References FullPivLU< _MatrixType >::m_maxpivot.
Definition at line 129 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_nonzero_pivots.
const PermutationPType& FullPivLU< _MatrixType >::permutationP | ( | ) | const [inline] |
Definition at line 144 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_p.
const PermutationQType& FullPivLU< _MatrixType >::permutationQ | ( | ) | const [inline] |
Definition at line 154 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, and FullPivLU< _MatrixType >::m_q.
Definition at line 306 of file FullPivLU.h.
References abs(), eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, FullPivLU< _MatrixType >::m_lu, FullPivLU< _MatrixType >::m_maxpivot, FullPivLU< _MatrixType >::m_nonzero_pivots, and FullPivLU< _MatrixType >::threshold().
Referenced by FullPivLU< _MatrixType >::dimensionOfKernel(), FullPivLU< _MatrixType >::isInjective(), and FullPivLU< _MatrixType >::isSurjective().
MatrixType FullPivLU< MatrixType >::reconstructedMatrix | ( | ) | const |
Definition at line 533 of file FullPivLU.h.
References eigen_assert.
Definition at line 383 of file FullPivLU.h.
References FullPivLU< _MatrixType >::m_lu.
Referenced by FullPivLU< _MatrixType >::isSurjective(), and internal::image_retval_base< FullPivLU< _MatrixType > >::rows().
FullPivLU& FullPivLU< _MatrixType >::setThreshold | ( | Default_t | ) | [inline] |
Allows to come back to the default behavior, letting Eigen use its default formula for determining the threshold.
You should pass the special object Eigen::Default as parameter here.
lu.setThreshold(Eigen::Default);
See the documentation of setThreshold(const RealScalar&).
Definition at line 282 of file FullPivLU.h.
References FullPivLU< _MatrixType >::m_usePrescribedThreshold.
FullPivLU& FullPivLU< _MatrixType >::setThreshold | ( | const RealScalar & | threshold | ) | [inline] |
Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine when pivots are to be considered nonzero.
This is not used for the LU decomposition itself.
When it needs to get the threshold value, Eigen calls threshold(). By default, this uses a formula to automatically determine a reasonable threshold. Once you have called the present method setThreshold(const RealScalar&), your value is used instead.
threshold | The new value to use as the threshold. |
A pivot will be considered nonzero if its absolute value is strictly greater than where maxpivot is the biggest pivot.
If you want to come back to the default behavior, call setThreshold(Default_t)
Definition at line 267 of file FullPivLU.h.
References FullPivLU< _MatrixType >::m_prescribedThreshold, FullPivLU< _MatrixType >::m_usePrescribedThreshold, and FullPivLU< _MatrixType >::threshold().
const internal::solve_retval<FullPivLU, Rhs> FullPivLU< _MatrixType >::solve | ( | const MatrixBase< Rhs > & | b | ) | const [inline] |
b | the right-hand-side of the equation to solve. Can be a vector or a matrix, the only requirement in order for the equation to make sense is that b.rows()==A.rows(), where A is the matrix of which *this is the LU decomposition. |
Example:
Output:
Definition at line 227 of file FullPivLU.h.
References eigen_assert, and FullPivLU< _MatrixType >::m_isInitialized.
RealScalar FullPivLU< _MatrixType >::threshold | ( | ) | const [inline] |
Returns the threshold that will be used by certain methods such as rank().
See the documentation of setThreshold(const RealScalar&).
Definition at line 291 of file FullPivLU.h.
References eigen_assert, FullPivLU< _MatrixType >::m_isInitialized, FullPivLU< _MatrixType >::m_lu, FullPivLU< _MatrixType >::m_prescribedThreshold, and FullPivLU< _MatrixType >::m_usePrescribedThreshold.
Referenced by FullPivLU< _MatrixType >::rank(), and FullPivLU< _MatrixType >::setThreshold().
IntRowVectorType FullPivLU< _MatrixType >::m_colsTranspositions [protected] |
Definition at line 391 of file FullPivLU.h.
Definition at line 392 of file FullPivLU.h.
bool FullPivLU< _MatrixType >::m_isInitialized [protected] |
Definition at line 394 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::dimensionOfKernel(), FullPivLU< _MatrixType >::image(), FullPivLU< _MatrixType >::inverse(), FullPivLU< _MatrixType >::isInjective(), FullPivLU< _MatrixType >::isInvertible(), FullPivLU< _MatrixType >::isSurjective(), FullPivLU< _MatrixType >::kernel(), FullPivLU< _MatrixType >::matrixLU(), FullPivLU< _MatrixType >::nonzeroPivots(), FullPivLU< _MatrixType >::permutationP(), FullPivLU< _MatrixType >::permutationQ(), FullPivLU< _MatrixType >::rank(), FullPivLU< _MatrixType >::solve(), and FullPivLU< _MatrixType >::threshold().
MatrixType FullPivLU< _MatrixType >::m_lu [protected] |
Definition at line 387 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::cols(), FullPivLU< _MatrixType >::inverse(), FullPivLU< _MatrixType >::isInvertible(), FullPivLU< _MatrixType >::matrixLU(), FullPivLU< _MatrixType >::rank(), FullPivLU< _MatrixType >::rows(), and FullPivLU< _MatrixType >::threshold().
RealScalar FullPivLU< _MatrixType >::m_maxpivot [protected] |
Definition at line 393 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::maxPivot(), and FullPivLU< _MatrixType >::rank().
Index FullPivLU< _MatrixType >::m_nonzero_pivots [protected] |
Definition at line 392 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::nonzeroPivots(), and FullPivLU< _MatrixType >::rank().
PermutationPType FullPivLU< _MatrixType >::m_p [protected] |
Definition at line 388 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::permutationP().
RealScalar FullPivLU< _MatrixType >::m_prescribedThreshold [protected] |
Definition at line 393 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::setThreshold(), and FullPivLU< _MatrixType >::threshold().
PermutationQType FullPivLU< _MatrixType >::m_q [protected] |
Definition at line 389 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::permutationQ().
IntColVectorType FullPivLU< _MatrixType >::m_rowsTranspositions [protected] |
Definition at line 390 of file FullPivLU.h.
bool FullPivLU< _MatrixType >::m_usePrescribedThreshold [protected] |
Definition at line 394 of file FullPivLU.h.
Referenced by FullPivLU< _MatrixType >::setThreshold(), and FullPivLU< _MatrixType >::threshold().
Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011 |