LU decomposition of a matrix with complete pivoting, and related features. More...
Public Member Functions | |
EIGEN_CONSTEXPR Index | cols () const EIGEN_NOEXCEPT |
template<typename InputType > | |
FullPivLU & | compute (const EigenBase< InputType > &matrix) |
internal::traits< MatrixType >::Scalar | determinant () const |
Index | dimensionOfKernel () const |
FullPivLU () | |
Default Constructor. More... | |
template<typename InputType > | |
FullPivLU (const EigenBase< InputType > &matrix) | |
template<typename InputType > | |
FullPivLU (EigenBase< InputType > &matrix) | |
Constructs a LU factorization from a given matrix. More... | |
FullPivLU (Index rows, Index cols) | |
Default Constructor with memory preallocation. More... | |
const internal::image_retval< FullPivLU > | image (const MatrixType &originalMatrix) const |
const Inverse< FullPivLU > | inverse () const |
bool | isInjective () const |
bool | isInvertible () const |
bool | isSurjective () const |
const internal::kernel_retval< FullPivLU > | kernel () const |
const MatrixType & | matrixLU () const |
RealScalar | maxPivot () const |
Index | nonzeroPivots () const |
const PermutationPType & | permutationP () const |
const PermutationQType & | permutationQ () const |
Index | rank () const |
RealScalar | rcond () const |
MatrixType | reconstructedMatrix () const |
EIGEN_CONSTEXPR Index | rows () const EIGEN_NOEXCEPT |
FullPivLU & | setThreshold (const RealScalar &threshold) |
FullPivLU & | setThreshold (Default_t) |
template<typename Rhs > | |
const Solve< FullPivLU, Rhs > | solve (const MatrixBase< Rhs > &b) const |
RealScalar | threshold () const |
Public Member Functions inherited from Eigen::SolverBase< FullPivLU< MatrixType_, PermutationIndex_ > > | |
const AdjointReturnType | adjoint () const |
FullPivLU< MatrixType_, PermutationIndex_ > & | derived () |
const FullPivLU< MatrixType_, PermutationIndex_ > & | derived () const |
const Solve< FullPivLU< MatrixType_, PermutationIndex_ >, Rhs > | solve (const MatrixBase< Rhs > &b) const |
SolverBase () | |
const ConstTransposeReturnType | transpose () const |
~SolverBase () | |
Public Member Functions inherited from Eigen::EigenBase< Derived > | |
template<typename Dest > | |
void | addTo (Dest &dst) const |
template<typename Dest > | |
void | applyThisOnTheLeft (Dest &dst) const |
template<typename Dest > | |
void | applyThisOnTheRight (Dest &dst) const |
EIGEN_CONSTEXPR Index | cols () const EIGEN_NOEXCEPT |
Derived & | const_cast_derived () const |
const Derived & | const_derived () const |
Derived & | derived () |
const Derived & | derived () const |
template<typename Dest > | |
void | evalTo (Dest &dst) const |
EIGEN_CONSTEXPR Index | rows () const EIGEN_NOEXCEPT |
EIGEN_CONSTEXPR Index | size () const EIGEN_NOEXCEPT |
template<typename Dest > | |
void | subTo (Dest &dst) const |
Protected Member Functions | |
void | computeInPlace () |
Protected Member Functions inherited from Eigen::SolverBase< FullPivLU< MatrixType_, PermutationIndex_ > > | |
void | _check_solve_assertion (const Rhs &b) const |
Protected Attributes | |
IntRowVectorType | m_colsTranspositions |
signed char | m_det_pq |
bool | m_isInitialized |
RealScalar | m_l1_norm |
MatrixType | m_lu |
RealScalar | m_maxpivot |
Index | m_nonzero_pivots |
PermutationPType | m_p |
RealScalar | m_prescribedThreshold |
PermutationQType | m_q |
IntColVectorType | m_rowsTranspositions |
bool | m_usePrescribedThreshold |
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 = 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:
Output:
Here is the matrix m: 0.68 -0.605 -0.0452 -0.211 -0.33 0.258 0.566 0.536 -0.27 0.597 -0.444 0.0268 0.823 0.108 0.904 Here is, up to permutations, its LU decomposition matrix: 0.904 0.823 0.108 -0.299 0.812 0.569 -0.05 0.888 -1.1 0.0296 0.705 0.768 0.285 -0.549 0.0436 Here is the L part: 1 0 0 0 0 -0.299 1 0 0 0 -0.05 0.888 1 0 0 0.0296 0.705 0.768 1 0 0.285 -0.549 0.0436 0 1 Here is the U part: 0.904 0.823 0.108 0 0.812 0.569 0 0 -1.1 0 0 0 0 0 0 Let us now reconstruct the original matrix m: 0.68 -0.605 -0.0452 -0.211 -0.33 0.258 0.566 0.536 -0.27 0.597 -0.444 0.0268 0.823 0.108 0.904
This class supports the inplace decomposition mechanism.
Definition at line 62 of file FullPivLU.h.
typedef SolverBase<FullPivLU> Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::Base |
Definition at line 67 of file FullPivLU.h.
typedef internal::plain_col_type<MatrixType, PermutationIndex>::type Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::IntColVectorType |
Definition at line 77 of file FullPivLU.h.
typedef internal::plain_row_type<MatrixType, PermutationIndex>::type Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::IntRowVectorType |
Definition at line 76 of file FullPivLU.h.
typedef MatrixType_ Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::MatrixType |
Definition at line 66 of file FullPivLU.h.
using Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::PermutationIndex = PermutationIndex_ |
Definition at line 75 of file FullPivLU.h.
typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime, PermutationIndex> Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::PermutationPType |
Definition at line 79 of file FullPivLU.h.
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime, PermutationIndex> Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::PermutationQType |
Definition at line 78 of file FullPivLU.h.
typedef MatrixType::PlainObject Eigen::FullPivLU< MatrixType_, PermutationIndex_ >::PlainObject |
Definition at line 80 of file FullPivLU.h.
anonymous enum |
Eigen::FullPivLU< MatrixType, PermutationIndex >::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 442 of file FullPivLU.h.
Eigen::FullPivLU< MatrixType, PermutationIndex >::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 448 of file FullPivLU.h.
|
explicit |
Constructor.
matrix | the matrix of which to compute the LU decomposition. It is required to be nonzero. |
Definition at line 461 of file FullPivLU.h.
|
explicit |
Constructs a LU factorization from a given matrix.
This overloaded constructor is provided for inplace decomposition when MatrixType
is a Eigen::Ref.
Definition at line 475 of file FullPivLU.h.
|
inline |
Definition at line 413 of file FullPivLU.h.
|
inline |
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 123 of file FullPivLU.h.
|
protected |
Definition at line 488 of file FullPivLU.h.
internal::traits< MatrixType >::Scalar Eigen::FullPivLU< MatrixType, PermutationIndex >::determinant |
Definition at line 578 of file FullPivLU.h.
|
inline |
Definition at line 350 of file FullPivLU.h.
|
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:
Here is the matrix m: 1 1 0 1 3 2 0 1 1 Notice that the middle column is the sum of the two others, so the columns are linearly dependent. Here is a matrix whose columns have the same span but are linearly independent: 1 1 3 1 1 0
Definition at line 219 of file FullPivLU.h.
|
inline |
Definition at line 401 of file FullPivLU.h.
|
inline |
Definition at line 363 of file FullPivLU.h.
|
inline |
Definition at line 388 of file FullPivLU.h.
|
inline |
Definition at line 376 of file FullPivLU.h.
|
inline |
Example:
Output:
Here is the matrix m: 0.68 0.597 -0.33 0.108 -0.27 -0.211 0.823 0.536 -0.0452 0.0268 0.566 -0.605 -0.444 0.258 0.904 Here is a matrix whose columns form a basis of the kernel of m: -0.219 0.763 0.00335 -0.447 0 1 1 0 -0.145 -0.285 By definition of the kernel, m*ker is zero: 7.45e-09 1.49e-08 -1.86e-09 -4.05e-08 0 -2.98e-08
Definition at line 193 of file FullPivLU.h.
|
inline |
Definition at line 135 of file FullPivLU.h.
|
inline |
Definition at line 157 of file FullPivLU.h.
|
inline |
Definition at line 148 of file FullPivLU.h.
|
inline |
|
inline |
|
inline |
Definition at line 333 of file FullPivLU.h.
|
inline |
*this
is the LU decomposition. Definition at line 253 of file FullPivLU.h.
MatrixType Eigen::FullPivLU< MatrixType, PermutationIndex >::reconstructedMatrix |
Definition at line 589 of file FullPivLU.h.
|
inline |
Definition at line 411 of file FullPivLU.h.
|
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 \( \vert pivot \vert \leqslant threshold \times \vert maxpivot \vert \) where maxpivot is the biggest pivot.
If you want to come back to the default behavior, call setThreshold(Default_t)
Definition at line 293 of file FullPivLU.h.
|
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.
See the documentation of setThreshold(const RealScalar&).
Definition at line 308 of file FullPivLU.h.
|
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. |
This method just tries to find as good a solution as possible. If you want to check whether a solution exists or if it is accurate, just call this function to get a result and then compute the error of this result, or use MatrixBase::isApprox() directly, for instance like this:
This method avoids dividing by zero, so that the non-existence of a solution doesn't by itself mean that you'll get inf
or nan
values.
If there exists more than one solution, this method will arbitrarily choose one. If you need a complete analysis of the space of solutions, take the one solution obtained by this method and add to it elements of the kernel, as determined by kernel().
Example:
Output:
Here is the matrix m: 0.68 0.566 0.823 -0.211 0.597 -0.605 Here is the matrix y: -0.33 -0.444 0.536 0.108 Here is a solution x to the equation mx=y: 0 0 0.291 -0.216 -0.6 -0.391
|
inline |
Returns the threshold that will be used by certain methods such as rank().
See the documentation of setThreshold(const RealScalar&).
Definition at line 318 of file FullPivLU.h.
|
protected |
Definition at line 433 of file FullPivLU.h.
|
protected |
Definition at line 437 of file FullPivLU.h.
|
protected |
Definition at line 438 of file FullPivLU.h.
|
protected |
Definition at line 435 of file FullPivLU.h.
|
protected |
Definition at line 429 of file FullPivLU.h.
|
protected |
Definition at line 436 of file FullPivLU.h.
|
protected |
Definition at line 434 of file FullPivLU.h.
|
protected |
Definition at line 430 of file FullPivLU.h.
|
protected |
Definition at line 436 of file FullPivLU.h.
|
protected |
Definition at line 431 of file FullPivLU.h.
|
protected |
Definition at line 432 of file FullPivLU.h.
|
protected |
Definition at line 438 of file FullPivLU.h.