Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Eigen::FullPivLU Class Reference

LU decomposition of a matrix with complete pivoting, and related features. More...

#include <ForwardDeclarations.h>

Public Types

enum  { MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
 
typedef SolverBase< FullPivLUBase
 
typedef internal::plain_col_type< MatrixType, StorageIndex >::type IntColVectorType
 
typedef internal::plain_row_type< MatrixType, StorageIndex >::type IntRowVectorType
 
typedef _MatrixType MatrixType
 
typedef PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTimePermutationPType
 
typedef PermutationMatrix< ColsAtCompileTime, MaxColsAtCompileTimePermutationQType
 
typedef MatrixType::PlainObject PlainObject
 

Public Member Functions

template<typename RhsType , typename DstType >
void _solve_impl (const RhsType &rhs, DstType &dst) const
 
template<bool Conjugate, typename RhsType , typename DstType >
void _solve_impl_transposed (const RhsType &rhs, DstType &dst) const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
template<typename InputType >
FullPivLUcompute (const EigenBase< InputType > &matrix)
 
internal::traits< MatrixType >::Scalar determinant () const
 
Index dimensionOfKernel () const
 
 FullPivLU ()
 Default Constructor. More...
 
template<typename MatrixType >
 FullPivLU ()
 
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...
 
template<typename MatrixType >
 FullPivLU (Index rows, Index cols)
 
const internal::image_retval< FullPivLUimage (const MatrixType &originalMatrix) const
 
const Inverse< FullPivLUinverse () const
 
bool isInjective () const
 
bool isInvertible () const
 
bool isSurjective () const
 
const internal::kernel_retval< FullPivLUkernel () const
 
const MatrixTypematrixLU () const
 
RealScalar maxPivot () const
 
Index nonzeroPivots () const
 
const EIGEN_DEVICE_FUNC PermutationPTypepermutationP () const
 
const PermutationQTypepermutationQ () const
 
Index rank () const
 
RealScalar rcond () const
 
MatrixType reconstructedMatrix () const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
FullPivLUsetThreshold (const RealScalar &threshold)
 
FullPivLUsetThreshold (Default_t)
 
RealScalar threshold () const
 

Protected Member Functions

void computeInPlace ()
 

Static Protected Member Functions

static void check_template_parameters ()
 

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
 

Friends

class SolverBase< FullPivLU >
 

Detailed Description

LU decomposition of a matrix with complete pivoting, and related features.

Template Parameters
_MatrixTypethe 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:

typedef Matrix<double, 5, 3> Matrix5x3;
typedef Matrix<double, 5, 5> Matrix5x5;
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;

Output:

This class supports the inplace decomposition mechanism.

See also
MatrixBase::fullPivLu(), MatrixBase::determinant(), MatrixBase::inverse()

Definition at line 268 of file ForwardDeclarations.h.

Member Typedef Documentation

◆ Base

Definition at line 65 of file FullPivLU.h.

◆ IntColVectorType

Definition at line 74 of file FullPivLU.h.

◆ IntRowVectorType

Definition at line 73 of file FullPivLU.h.

◆ MatrixType

typedef _MatrixType Eigen::FullPivLU::MatrixType

Definition at line 64 of file FullPivLU.h.

◆ PermutationPType

Definition at line 76 of file FullPivLU.h.

◆ PermutationQType

Definition at line 75 of file FullPivLU.h.

◆ PlainObject

typedef MatrixType::PlainObject Eigen::FullPivLU::PlainObject

Definition at line 77 of file FullPivLU.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MaxRowsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 69 of file FullPivLU.h.

Constructor & Destructor Documentation

◆ FullPivLU() [1/6]

Eigen::FullPivLU::FullPivLU ( )

Default Constructor.

The default constructor is useful in cases in which the user intends to perform decompositions via LU::compute(const MatrixType&).

◆ FullPivLU() [2/6]

Eigen::FullPivLU::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.

See also
FullPivLU()

◆ FullPivLU() [3/6]

template<typename InputType >
Eigen::FullPivLU::FullPivLU ( const EigenBase< InputType > &  matrix)
explicit

Constructor.

Parameters
matrixthe matrix of which to compute the LU decomposition. It is required to be nonzero.

Definition at line 461 of file FullPivLU.h.

◆ FullPivLU() [4/6]

template<typename InputType >
Eigen::FullPivLU::FullPivLU ( EigenBase< InputType > &  matrix)
explicit

Constructs a LU factorization from a given matrix.

This overloaded constructor is provided for inplace decomposition when MatrixType is a Eigen::Ref.

See also
FullPivLU(const EigenBase&)

Definition at line 475 of file FullPivLU.h.

◆ FullPivLU() [5/6]

template<typename MatrixType >
Eigen::FullPivLU::FullPivLU ( )

Definition at line 442 of file FullPivLU.h.

◆ FullPivLU() [6/6]

template<typename MatrixType >
Eigen::FullPivLU::FullPivLU ( Index  rows,
Index  cols 
)

Definition at line 448 of file FullPivLU.h.

Member Function Documentation

◆ _solve_impl()

template<typename RhsType , typename DstType >
void Eigen::FullPivLU::_solve_impl ( const RhsType &  rhs,
DstType &  dst 
) const

Definition at line 745 of file FullPivLU.h.

◆ _solve_impl_transposed()

template<bool Conjugate, typename RhsType , typename DstType >
void Eigen::FullPivLU::_solve_impl_transposed ( const RhsType &  rhs,
DstType &  dst 
) const

Definition at line 792 of file FullPivLU.h.

◆ check_template_parameters()

static void Eigen::FullPivLU::check_template_parameters ( )
inlinestaticprotected

Definition at line 422 of file FullPivLU.h.

◆ cols()

EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index Eigen::FullPivLU::cols ( ) const
inline

Definition at line 410 of file FullPivLU.h.

◆ compute()

template<typename InputType >
FullPivLU& Eigen::FullPivLU::compute ( const EigenBase< InputType > &  matrix)
inline

Computes the LU decomposition of the given matrix.

Parameters
matrixthe matrix of which to compute the LU decomposition. It is required to be nonzero.
Returns
a reference to *this

Definition at line 120 of file FullPivLU.h.

◆ computeInPlace()

void Eigen::FullPivLU::computeInPlace ( )
protected

Definition at line 488 of file FullPivLU.h.

◆ determinant()

internal::traits< MatrixType >::Scalar Eigen::FullPivLU::determinant ( ) const
Returns
the determinant of the matrix of which *this is the LU decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the LU decomposition has already been computed.
Note
This is only for square matrices.
For fixed-size matrices of size up to 4, MatrixBase::determinant() offers optimized paths.
Warning
a determinant can be very big or small, so for matrices of large enough dimension, there is a risk of overflow/underflow.
See also
MatrixBase::determinant()

Definition at line 581 of file FullPivLU.h.

◆ dimensionOfKernel()

Index Eigen::FullPivLU::dimensionOfKernel ( ) const
inline
Returns
the dimension of the kernel of the matrix of which *this is the LU decomposition.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Definition at line 347 of file FullPivLU.h.

◆ image()

const internal::image_retval<FullPivLU> Eigen::FullPivLU::image ( const MatrixType originalMatrix) const
inline
Returns
the image of the matrix, also called its column-space. The columns of the returned matrix will form a basis of the image (column-space).
Parameters
originalMatrixthe 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.
Note
If the image has dimension zero, then the returned matrix is a column-vector filled with zeros.
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Example:

Matrix3d m;
m << 1,1,0,
1,3,2,
0,1,1;
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Notice that the middle column is the sum of the two others, so the "
<< "columns are linearly dependent." << endl;
cout << "Here is a matrix whose columns have the same span but are linearly independent:"
<< endl << m.fullPivLu().image(m) << endl;

Output:

See also
kernel()

Definition at line 216 of file FullPivLU.h.

◆ inverse()

const Inverse<FullPivLU> Eigen::FullPivLU::inverse ( ) const
inline
Returns
the inverse of the matrix of which *this is the LU decomposition.
Note
If this matrix is not invertible, the returned matrix has undefined coefficients. Use isInvertible() to first determine whether this matrix is invertible.
See also
MatrixBase::inverse()

Definition at line 398 of file FullPivLU.h.

◆ isInjective()

bool Eigen::FullPivLU::isInjective ( ) const
inline
Returns
true if the matrix of which *this is the LU decomposition represents an injective linear map, i.e. has trivial kernel; false otherwise.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Definition at line 360 of file FullPivLU.h.

◆ isInvertible()

bool Eigen::FullPivLU::isInvertible ( ) const
inline
Returns
true if the matrix of which *this is the LU decomposition is invertible.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Definition at line 385 of file FullPivLU.h.

◆ isSurjective()

bool Eigen::FullPivLU::isSurjective ( ) const
inline
Returns
true if the matrix of which *this is the LU decomposition represents a surjective linear map; false otherwise.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Definition at line 373 of file FullPivLU.h.

◆ kernel()

const internal::kernel_retval<FullPivLU> Eigen::FullPivLU::kernel ( ) const
inline
Returns
the kernel of the matrix, also called its null-space. The columns of the returned matrix will form a basis of the kernel.
Note
If the kernel has dimension zero, then the returned matrix is a column-vector filled with zeros.
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Example:

MatrixXf m = MatrixXf::Random(3,5);
cout << "Here is the matrix m:" << endl << m << endl;
MatrixXf ker = m.fullPivLu().kernel();
cout << "Here is a matrix whose columns form a basis of the kernel of m:"
<< endl << ker << endl;
cout << "By definition of the kernel, m*ker is zero:"
<< endl << m*ker << endl;

Output:

See also
image()

Definition at line 190 of file FullPivLU.h.

◆ matrixLU()

const MatrixType& Eigen::FullPivLU::matrixLU ( ) const
inline
Returns
the LU decomposition matrix: the upper-triangular part is U, the unit-lower-triangular part is L (at least for square matrices; in the non-square case, special care is needed, see the documentation of class FullPivLU).
See also
matrixL(), matrixU()

Definition at line 132 of file FullPivLU.h.

◆ maxPivot()

RealScalar Eigen::FullPivLU::maxPivot ( ) const
inline
Returns
the absolute value of the biggest pivot, i.e. the biggest diagonal coefficient of U.

Definition at line 154 of file FullPivLU.h.

◆ nonzeroPivots()

Index Eigen::FullPivLU::nonzeroPivots ( ) const
inline
Returns
the number of nonzero pivots in the LU decomposition. Here nonzero is meant in the exact sense, not in a fuzzy sense. So that notion isn't really intrinsically interesting, but it is still useful when implementing algorithms.
See also
rank()

Definition at line 145 of file FullPivLU.h.

◆ permutationP()

const EIGEN_DEVICE_FUNC PermutationPType& Eigen::FullPivLU::permutationP ( ) const
inline
Returns
the permutation matrix P
See also
permutationQ()

Definition at line 160 of file FullPivLU.h.

◆ permutationQ()

const PermutationQType& Eigen::FullPivLU::permutationQ ( ) const
inline
Returns
the permutation matrix Q
See also
permutationP()

Definition at line 170 of file FullPivLU.h.

◆ rank()

Index Eigen::FullPivLU::rank ( ) const
inline
Returns
the rank of the matrix of which *this is the LU decomposition.
Note
This method has to determine which pivots should be considered nonzero. For that, it uses the threshold value that you can control by calling setThreshold(const RealScalar&).

Definition at line 330 of file FullPivLU.h.

◆ rcond()

RealScalar Eigen::FullPivLU::rcond ( ) const
inline
Returns
an estimate of the reciprocal condition number of the matrix of which *this is the LU decomposition.

Definition at line 250 of file FullPivLU.h.

◆ reconstructedMatrix()

MatrixType Eigen::FullPivLU::reconstructedMatrix ( ) const
Returns
the matrix represented by the decomposition, i.e., it returns the product: $ P^{-1} L U Q^{-1} $. This function is provided for debug purposes.

Definition at line 592 of file FullPivLU.h.

◆ rows()

EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index Eigen::FullPivLU::rows ( ) const
inline

Definition at line 408 of file FullPivLU.h.

◆ setThreshold() [1/2]

FullPivLU& Eigen::FullPivLU::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.

Parameters
thresholdThe 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 290 of file FullPivLU.h.

◆ setThreshold() [2/2]

FullPivLU& Eigen::FullPivLU::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 305 of file FullPivLU.h.

◆ threshold()

RealScalar Eigen::FullPivLU::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 315 of file FullPivLU.h.

Friends And Related Function Documentation

◆ SolverBase< FullPivLU >

friend class SolverBase< FullPivLU >
friend

Definition at line 66 of file FullPivLU.h.

Member Data Documentation

◆ m_colsTranspositions

IntRowVectorType Eigen::FullPivLU::m_colsTranspositions
protected

Definition at line 433 of file FullPivLU.h.

◆ m_det_pq

signed char Eigen::FullPivLU::m_det_pq
protected

Definition at line 437 of file FullPivLU.h.

◆ m_isInitialized

bool Eigen::FullPivLU::m_isInitialized
protected

Definition at line 438 of file FullPivLU.h.

◆ m_l1_norm

RealScalar Eigen::FullPivLU::m_l1_norm
protected

Definition at line 435 of file FullPivLU.h.

◆ m_lu

MatrixType Eigen::FullPivLU::m_lu
protected

Definition at line 429 of file FullPivLU.h.

◆ m_maxpivot

RealScalar Eigen::FullPivLU::m_maxpivot
protected

Definition at line 436 of file FullPivLU.h.

◆ m_nonzero_pivots

Index Eigen::FullPivLU::m_nonzero_pivots
protected

Definition at line 434 of file FullPivLU.h.

◆ m_p

PermutationPType Eigen::FullPivLU::m_p
protected

Definition at line 430 of file FullPivLU.h.

◆ m_prescribedThreshold

RealScalar Eigen::FullPivLU::m_prescribedThreshold
protected

Definition at line 436 of file FullPivLU.h.

◆ m_q

PermutationQType Eigen::FullPivLU::m_q
protected

Definition at line 431 of file FullPivLU.h.

◆ m_rowsTranspositions

IntColVectorType Eigen::FullPivLU::m_rowsTranspositions
protected

Definition at line 432 of file FullPivLU.h.

◆ m_usePrescribedThreshold

bool Eigen::FullPivLU::m_usePrescribedThreshold
protected

Definition at line 438 of file FullPivLU.h.


The documentation for this class was generated from the following files:
Matrix5x5
Matrix< double, 5, 5 > Matrix5x5
Definition: class_FullPivLU.cpp:2
Eigen::Upper
@ Upper
Definition: Constants.h:211
Eigen::FullPivLU
LU decomposition of a matrix with complete pivoting, and related features.
Definition: ForwardDeclarations.h:268
l
static const Line3 l(Rot3(), 1, 1)
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Matrix5x3
Matrix< double, 5, 3 > Matrix5x3
Definition: class_FullPivLU.cpp:1
lu
cout<< "Here is the matrix m:"<< endl<< m<< endl;Eigen::FullPivLU< Matrix5x3 > lu(m)
Eigen::Default
@ Default
Definition: Constants.h:362


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:09:38