Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::LLT< _MatrixType, _UpLo > Class Template Reference

Standard Cholesky decomposition (LL^T) of a matrix and associated features. More...

#include <src/eigen/Eigen/src/Cholesky/LLT.h>

+ Collaboration diagram for Eigen::LLT< _MatrixType, _UpLo >:

Public Types

enum  { RowsAtCompileTime = MatrixType::RowsAtCompileTime , ColsAtCompileTime = MatrixType::ColsAtCompileTime , MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }
 
enum  { PacketSize = internal::packet_traits<Scalar>::size , AlignmentMask = int(PacketSize)-1 , UpLo = _UpLo }
 
typedef _MatrixType MatrixType
 
typedef MatrixType::Scalar Scalar
 
typedef NumTraits< typenameMatrixType::Scalar >::Real RealScalar
 
typedef Eigen::Index Index
 
typedef MatrixType::StorageIndex StorageIndex
 
typedef internal::LLT_Traits< MatrixType, UpLoTraits
 

Public Member Functions

 LLT ()
 Default Constructor.
 
 LLT (Index size)
 Default Constructor with memory preallocation.
 
template<typename InputType >
 LLT (const EigenBase< InputType > &matrix)
 
template<typename InputType >
 LLT (EigenBase< InputType > &matrix)
 Constructs a LDLT factorization from a given matrix.
 
Traits::MatrixU matrixU () const
 
Traits::MatrixL matrixL () const
 
template<typename Rhs >
const Solve< LLT, Rhs > solve (const MatrixBase< Rhs > &b) const
 
template<typename Derived >
void solveInPlace (const MatrixBase< Derived > &bAndX) const
 
template<typename InputType >
LLTcompute (const EigenBase< InputType > &matrix)
 
RealScalar rcond () const
 
const MatrixTypematrixLLT () const
 
MatrixType reconstructedMatrix () const
 
ComputationInfo info () const
 Reports whether previous computation was successful.
 
const LLTadjoint () const
 
Index rows () const
 
Index cols () const
 
template<typename VectorType >
LLT rankUpdate (const VectorType &vec, const RealScalar &sigma=1)
 
template<typename RhsType , typename DstType >
EIGEN_DEVICE_FUNC void _solve_impl (const RhsType &rhs, DstType &dst) const
 
template<typename InputType >
LLT< MatrixType, _UpLo > & compute (const EigenBase< InputType > &a)
 
template<typename VectorType >
LLT< _MatrixType, _UpLo > rankUpdate (const VectorType &v, const RealScalar &sigma)
 
template<typename RhsType , typename DstType >
void _solve_impl (const RhsType &rhs, DstType &dst) const
 

Static Protected Member Functions

static void check_template_parameters ()
 

Protected Attributes

MatrixType m_matrix
 
RealScalar m_l1_norm
 
bool m_isInitialized
 
ComputationInfo m_info
 

Detailed Description

template<typename _MatrixType, int _UpLo>
class Eigen::LLT< _MatrixType, _UpLo >

Standard Cholesky decomposition (LL^T) of a matrix and associated features.

Template Parameters
_MatrixTypethe type of the matrix of which we are computing the LL^T Cholesky decomposition
_UpLothe triangular part that will be used for the decompositon: Lower (default) or Upper. The other triangular part won't be read.

This class performs a LL^T Cholesky decomposition of a symmetric, positive definite matrix A such that A = LL^* = U^*U, where L is lower triangular.

While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b, for that purpose, we recommend the Cholesky decomposition without square root which is more stable and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other situations like generalised eigen problems with hermitian matrices.

Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive definite matrices, use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine whether a system of equations has a solution.

Example:

Output:

Performance: for best performance, it is recommended to use a column-major storage format with the Lower triangular part (the default), or, equivalently, a row-major storage format with the Upper triangular part. Otherwise, you might get a 20% slowdown for the full factorization step, and rank-updates can be up to 3 times slower.

This class supports the inplace decomposition mechanism.

Note that during the decomposition, only the lower (or upper, as defined by _UpLo) triangular part of A is considered. Therefore, the strict lower part does not have to store correct values.

See also
MatrixBase::llt(), SelfAdjointView::llt(), class LDLT

Member Typedef Documentation

◆ Index

template<typename _MatrixType , int _UpLo>
typedef Eigen::Index Eigen::LLT< _MatrixType, _UpLo >::Index

◆ MatrixType

template<typename _MatrixType , int _UpLo>
typedef _MatrixType Eigen::LLT< _MatrixType, _UpLo >::MatrixType

◆ RealScalar

template<typename _MatrixType , int _UpLo>
typedef NumTraits<typenameMatrixType::Scalar>::Real Eigen::LLT< _MatrixType, _UpLo >::RealScalar

◆ Scalar

template<typename _MatrixType , int _UpLo>
typedef MatrixType::Scalar Eigen::LLT< _MatrixType, _UpLo >::Scalar

◆ StorageIndex

template<typename _MatrixType , int _UpLo>
typedef MatrixType::StorageIndex Eigen::LLT< _MatrixType, _UpLo >::StorageIndex

◆ Traits

template<typename _MatrixType , int _UpLo>
typedef internal::LLT_Traits<MatrixType,UpLo> Eigen::LLT< _MatrixType, _UpLo >::Traits

Member Enumeration Documentation

◆ anonymous enum

template<typename _MatrixType , int _UpLo>
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
MaxColsAtCompileTime 
60 {
61 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
62 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
63 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
64 };
@ ColsAtCompileTime
Definition LLT.h:62
@ MaxColsAtCompileTime
Definition LLT.h:63
@ RowsAtCompileTime
Definition LLT.h:61

◆ anonymous enum

template<typename _MatrixType , int _UpLo>
anonymous enum
Enumerator
PacketSize 
AlignmentMask 
UpLo 
70 {
73 UpLo = _UpLo
74 };
@ PacketSize
Definition LLT.h:71
@ UpLo
Definition LLT.h:73
@ AlignmentMask
Definition LLT.h:72
@ size
Definition GenericPacketMath.h:102

Constructor & Destructor Documentation

◆ LLT() [1/4]

template<typename _MatrixType , int _UpLo>
Eigen::LLT< _MatrixType, _UpLo >::LLT ( )
inline

Default Constructor.

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

84: m_matrix(), m_isInitialized(false) {}
bool m_isInitialized
Definition LLT.h:224
MatrixType m_matrix
Definition LLT.h:222

◆ LLT() [2/4]

template<typename _MatrixType , int _UpLo>
Eigen::LLT< _MatrixType, _UpLo >::LLT ( Index  size)
inlineexplicit

Default Constructor with memory preallocation.

Like the default constructor but with preallocation of the internal data according to the specified problem size.

See also
LLT()
92 : m_matrix(size, size),
93 m_isInitialized(false) {}

◆ LLT() [3/4]

template<typename _MatrixType , int _UpLo>
template<typename InputType >
Eigen::LLT< _MatrixType, _UpLo >::LLT ( const EigenBase< InputType > &  matrix)
inlineexplicit
97 : m_matrix(matrix.rows(), matrix.cols()),
98 m_isInitialized(false)
99 {
100 compute(matrix.derived());
101 }
LLT & compute(const EigenBase< InputType > &matrix)

References Eigen::LLT< _MatrixType, _UpLo >::compute(), and Eigen::EigenBase< Derived >::derived().

+ Here is the call graph for this function:

◆ LLT() [4/4]

template<typename _MatrixType , int _UpLo>
template<typename InputType >
Eigen::LLT< _MatrixType, _UpLo >::LLT ( EigenBase< InputType > &  matrix)
inlineexplicit

Constructs a LDLT factorization from a given matrix.

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

See also
LLT(const EigenBase&)
112 : m_matrix(matrix.derived()),
113 m_isInitialized(false)
114 {
115 compute(matrix.derived());
116 }

References Eigen::LLT< _MatrixType, _UpLo >::compute(), and Eigen::EigenBase< Derived >::derived().

+ Here is the call graph for this function:

Member Function Documentation

◆ _solve_impl() [1/2]

template<typename _MatrixType , int _UpLo>
template<typename RhsType , typename DstType >
EIGEN_DEVICE_FUNC void Eigen::LLT< _MatrixType, _UpLo >::_solve_impl ( const RhsType &  rhs,
DstType &  dst 
) const

◆ _solve_impl() [2/2]

template<typename _MatrixType , int _UpLo>
template<typename RhsType , typename DstType >
void Eigen::LLT< _MatrixType, _UpLo >::_solve_impl ( const RhsType &  rhs,
DstType &  dst 
) const
479{
480 dst = rhs;
481 solveInPlace(dst);
482}
void solveInPlace(const MatrixBase< Derived > &bAndX) const
Definition LLT.h:500

◆ adjoint()

template<typename _MatrixType , int _UpLo>
const LLT & Eigen::LLT< _MatrixType, _UpLo >::adjoint ( ) const
inline
Returns
the adjoint of *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.

This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:

x = decomposition.adjoint().solve(b)
197{ return *this; };

◆ check_template_parameters()

template<typename _MatrixType , int _UpLo>
static void Eigen::LLT< _MatrixType, _UpLo >::check_template_parameters ( )
inlinestaticprotected
214 {
216 }
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition StaticAssert.h:184
MatrixType::Scalar Scalar
Definition LLT.h:65

References EIGEN_STATIC_ASSERT_NON_INTEGER.

◆ cols()

template<typename _MatrixType , int _UpLo>
Index Eigen::LLT< _MatrixType, _UpLo >::cols ( ) const
inline
200{ return m_matrix.cols(); }

References Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

◆ compute() [1/2]

template<typename _MatrixType , int _UpLo>
template<typename InputType >
LLT< MatrixType, _UpLo > & Eigen::LLT< _MatrixType, _UpLo >::compute ( const EigenBase< InputType > &  a)

Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of matrix

Returns
a reference to *this

Example:

Output:

 
426{
428
429 eigen_assert(a.rows()==a.cols());
430 const Index size = a.rows();
431 m_matrix.resize(size, size);
432 if (!internal::is_same_dense(m_matrix, a.derived()))
433 m_matrix = a.derived();
434
435 // Compute matrix L1 norm = max abs column sum.
437 // TODO move this code to SelfAdjointView
438 for (Index col = 0; col < size; ++col) {
439 RealScalar abs_col_sum;
440 if (_UpLo == Lower)
441 abs_col_sum = m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();
442 else
443 abs_col_sum = m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();
444 if (abs_col_sum > m_l1_norm)
445 m_l1_norm = abs_col_sum;
446 }
447
448 m_isInitialized = true;
449 bool ok = Traits::inplace_decomposition(m_matrix);
451
452 return *this;
453}
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Definition BlockMethods.h:838
#define eigen_assert(x)
Definition Macros.h:579
NumTraits< typenameMatrixType::Scalar >::Real RealScalar
Definition LLT.h:66
RealScalar m_l1_norm
Definition LLT.h:223
ComputationInfo m_info
Definition LLT.h:225
static void check_template_parameters()
Definition LLT.h:213
Eigen::Index Index
Definition LLT.h:67
@ Lower
Definition Constants.h:204
@ NumericalIssue
Definition Constants.h:434
@ Success
Definition Constants.h:432
bool is_same_dense(const T1 &mat1, const T2 &mat2, typename enable_if< has_direct_access< T1 >::ret &&has_direct_access< T2 >::ret, T1 >::type *=0)
Definition XprHelper.h:661
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183

References col(), eigen_assert, Eigen::internal::is_same_dense(), Eigen::Lower, Eigen::NumericalIssue, and Eigen::Success.

+ Here is the call graph for this function:

◆ compute() [2/2]

template<typename _MatrixType , int _UpLo>
template<typename InputType >
LLT & Eigen::LLT< _MatrixType, _UpLo >::compute ( const EigenBase< InputType > &  matrix)

Referenced by Eigen::LLT< _MatrixType, _UpLo >::LLT(), Eigen::LLT< _MatrixType, _UpLo >::LLT(), and igl::copyleft::quadprog().

+ Here is the caller graph for this function:

◆ info()

template<typename _MatrixType , int _UpLo>
ComputationInfo Eigen::LLT< _MatrixType, _UpLo >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NumericalIssue if the matrix.appears not to be positive definite.
187 {
188 eigen_assert(m_isInitialized && "LLT is not initialized.");
189 return m_info;
190 }

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_info, and Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized.

◆ matrixL()

template<typename _MatrixType , int _UpLo>
Traits::MatrixL Eigen::LLT< _MatrixType, _UpLo >::matrixL ( ) const
inline
Returns
a view of the lower triangular matrix L
127 {
128 eigen_assert(m_isInitialized && "LLT is not initialized.");
129 return Traits::getL(m_matrix);
130 }

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized, and Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

Referenced by Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::compute().

+ Here is the caller graph for this function:

◆ matrixLLT()

template<typename _MatrixType , int _UpLo>
const MatrixType & Eigen::LLT< _MatrixType, _UpLo >::matrixLLT ( ) const
inline
Returns
the LLT decomposition matrix

TODO: document the storage layout

173 {
174 eigen_assert(m_isInitialized && "LLT is not initialized.");
175 return m_matrix;
176 }

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized, and Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

◆ matrixU()

template<typename _MatrixType , int _UpLo>
Traits::MatrixU Eigen::LLT< _MatrixType, _UpLo >::matrixU ( ) const
inline
Returns
a view of the upper triangular matrix U
120 {
121 eigen_assert(m_isInitialized && "LLT is not initialized.");
122 return Traits::getU(m_matrix);
123 }

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized, and Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

Referenced by Eigen::GeneralizedSelfAdjointEigenSolver< _MatrixType >::compute(), and igl::copyleft::quadprog().

+ Here is the caller graph for this function:

◆ rankUpdate() [1/2]

template<typename _MatrixType , int _UpLo>
template<typename VectorType >
LLT< _MatrixType, _UpLo > Eigen::LLT< _MatrixType, _UpLo >::rankUpdate ( const VectorType &  v,
const RealScalar sigma 
)

Performs a rank one update (or dowdate) of the current decomposition. If A = LL^* before the rank one update, then after it we have LL^* = A + sigma * v v^* where v must be a vector of same dimension.

463{
465 eigen_assert(v.size()==m_matrix.cols());
467 if(internal::llt_inplace<typename MatrixType::Scalar, UpLo>::rankUpdate(m_matrix,v,sigma)>=0)
469 else
470 m_info = Success;
471
472 return *this;
473}
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition StaticAssert.h:139

References eigen_assert, EIGEN_STATIC_ASSERT_VECTOR_ONLY, Eigen::NumericalIssue, and Eigen::Success.

◆ rankUpdate() [2/2]

template<typename _MatrixType , int _UpLo>
template<typename VectorType >
LLT Eigen::LLT< _MatrixType, _UpLo >::rankUpdate ( const VectorType &  vec,
const RealScalar sigma = 1 
)

◆ rcond()

template<typename _MatrixType , int _UpLo>
RealScalar Eigen::LLT< _MatrixType, _UpLo >::rcond ( ) const
inline
Returns
an estimate of the reciprocal condition number of the matrix of which *this is the Cholesky decomposition.
162 {
163 eigen_assert(m_isInitialized && "LLT is not initialized.");
164 eigen_assert(m_info == Success && "LLT failed because matrix appears to be negative");
166 }
Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition &dec)
Reciprocal condition number estimator.
Definition ConditionEstimator.h:159

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_info, Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized, Eigen::LLT< _MatrixType, _UpLo >::m_l1_norm, Eigen::internal::rcond_estimate_helper(), and Eigen::Success.

+ Here is the call graph for this function:

◆ reconstructedMatrix()

template<typename MatrixType , int _UpLo>
MatrixType Eigen::LLT< MatrixType, _UpLo >::reconstructedMatrix
Returns
the matrix represented by the decomposition, i.e., it returns the product: L L^*. This function is provided for debug purpose.
513{
514 eigen_assert(m_isInitialized && "LLT is not initialized.");
515 return matrixL() * matrixL().adjoint().toDenseMatrix();
516}
Traits::MatrixL matrixL() const
Definition LLT.h:126

References eigen_assert.

◆ rows()

template<typename _MatrixType , int _UpLo>
Index Eigen::LLT< _MatrixType, _UpLo >::rows ( ) const
inline
199{ return m_matrix.rows(); }

References Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

◆ solve()

template<typename _MatrixType , int _UpLo>
template<typename Rhs >
const Solve< LLT, Rhs > Eigen::LLT< _MatrixType, _UpLo >::solve ( const MatrixBase< Rhs > &  b) const
inline
Returns
the solution x of $ A x = b $ using the current decomposition of A.

Since this LLT class assumes anyway that the matrix A is invertible, the solution theoretically exists and is unique regardless of b.

Example:

Output:

See also
solveInPlace(), MatrixBase::llt(), SelfAdjointView::llt()
145 {
146 eigen_assert(m_isInitialized && "LLT is not initialized.");
147 eigen_assert(m_matrix.rows()==b.rows()
148 && "LLT::solve(): invalid number of rows of the right hand side matrix b");
149 return Solve<LLT, Rhs>(*this, b.derived());
150 }

References eigen_assert, Eigen::LLT< _MatrixType, _UpLo >::m_isInitialized, and Eigen::LLT< _MatrixType, _UpLo >::m_matrix.

Referenced by igl::copyleft::quadprog().

+ Here is the caller graph for this function:

◆ solveInPlace()

template<typename MatrixType , int _UpLo>
template<typename Derived >
void Eigen::LLT< MatrixType, _UpLo >::solveInPlace ( const MatrixBase< Derived > &  bAndX) const
501{
502 eigen_assert(m_isInitialized && "LLT is not initialized.");
503 eigen_assert(m_matrix.rows()==bAndX.rows());
504 matrixL().solveInPlace(bAndX);
505 matrixU().solveInPlace(bAndX);
506}
Traits::MatrixU matrixU() const
Definition LLT.h:119

References eigen_assert.

Member Data Documentation

◆ m_info

template<typename _MatrixType , int _UpLo>
ComputationInfo Eigen::LLT< _MatrixType, _UpLo >::m_info
protected

◆ m_isInitialized

◆ m_l1_norm

template<typename _MatrixType , int _UpLo>
RealScalar Eigen::LLT< _MatrixType, _UpLo >::m_l1_norm
protected

◆ m_matrix


The documentation for this class was generated from the following file: