45 template<
typename _MatrixType, 
int _UpLo> 
class LDLT    50       RowsAtCompileTime = MatrixType::RowsAtCompileTime,
    51       ColsAtCompileTime = MatrixType::ColsAtCompileTime,
    53       MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
    54       MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
    57     typedef typename MatrixType::Scalar 
Scalar;
    59     typedef typename MatrixType::Index 
Index;
    72     LDLT() : m_matrix(), m_transpositions(), m_isInitialized(false) {}
    81       : m_matrix(size, size),
    82         m_transpositions(size),
    84         m_isInitialized(false)
    92     LDLT(
const MatrixType& matrix)
    93       : m_matrix(matrix.rows(), matrix.cols()),
    94         m_transpositions(matrix.rows()),
    95         m_temporary(matrix.rows()),
    96         m_isInitialized(false)
   106       m_isInitialized = 
false;
   110     inline typename Traits::MatrixU 
matrixU()
 const   112       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   113       return Traits::getU(m_matrix);
   117     inline typename Traits::MatrixL 
matrixL()
 const   119       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   120       return Traits::getL(m_matrix);
   127       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   128       return m_transpositions;
   134       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   135       return m_matrix.diagonal();
   141       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   145     #ifdef EIGEN2_SUPPORT   146     inline bool isPositiveDefinite()
 const   155       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   174     template<
typename Rhs>
   178       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   180                 && 
"LDLT::solve(): invalid number of rows of the right hand side matrix b");
   184     #ifdef EIGEN2_SUPPORT   185     template<
typename OtherDerived, 
typename ResultType>
   188       *result = this->solve(b);
   193     template<
typename Derived>
   196     LDLT& compute(
const MatrixType& matrix);
   198     template <
typename Derived>
   207       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   211     MatrixType reconstructedMatrix() 
const;
   213     inline Index 
rows()
 const { 
return m_matrix.rows(); }
   214     inline Index 
cols()
 const { 
return m_matrix.cols(); }
   223       eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   248   template<
typename MatrixType, 
typename TranspositionType, 
typename Workspace>
   249   static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, 
int* sign=0)
   252     typedef typename MatrixType::Scalar Scalar;
   253     typedef typename MatrixType::RealScalar RealScalar;
   254     typedef typename MatrixType::Index Index;
   256     const Index size = mat.rows();
   260       transpositions.setIdentity();
   266     RealScalar cutoff(0), biggest_in_corner;
   268     for (Index k = 0; k < size; ++k)
   271       Index index_of_biggest_in_corner;
   272       biggest_in_corner = mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
   273       index_of_biggest_in_corner += k;
   284       if(biggest_in_corner < cutoff)
   286         for(Index i = k; i < size; i++) transpositions.coeffRef(i) = i;
   291       transpositions.coeffRef(k) = index_of_biggest_in_corner;
   292       if(k != index_of_biggest_in_corner)
   296         Index 
s = size-index_of_biggest_in_corner-1; 
   297         mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
   298         mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
   299         std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));
   300         for(
int i=k+1;i<index_of_biggest_in_corner;++i)
   302           Scalar tmp = mat.coeffRef(i,k);
   303           mat.coeffRef(i,k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner,i));
   304           mat.coeffRef(index_of_biggest_in_corner,i) = numext::conj(tmp);
   307           mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k));
   314       Index rs = size - k - 1;
   321         temp.head(k) = mat.diagonal().head(k).asDiagonal() * A10.adjoint();
   322         mat.coeffRef(k,k) -= (A10 * temp.head(k)).value();
   324           A21.noalias() -= A20 * temp.head(k);
   326       if((rs>0) && (
abs(mat.coeffRef(k,k)) > cutoff))
   327         A21 /= mat.coeffRef(k,k);
   332         int newSign = 
numext::real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0;
   335         else if(*sign != newSign)
   350   template<
typename MatrixType, 
typename WDerived>
   354     typedef typename MatrixType::Scalar Scalar;
   355     typedef typename MatrixType::RealScalar RealScalar;
   356     typedef typename MatrixType::Index Index;
   358     const Index size = mat.rows();
   361     RealScalar alpha = 1;
   364     for (Index j = 0; j < size; j++)
   372       Scalar wj = w.coeff(j);
   374       RealScalar gamma = dj*alpha + swj2;
   376       mat.coeffRef(j,j) += swj2/alpha;
   382       w.
tail(rs) -= wj * mat.col(j).tail(rs);
   384         mat.col(j).tail(rs) += (sigma*numext::conj(wj)/gamma)*w.
tail(rs);
   389   template<
typename MatrixType, 
typename TranspositionType, 
typename Workspace, 
typename WType>
   390   static bool update(MatrixType& mat, 
const TranspositionType& transpositions, Workspace& tmp, 
const WType& w, 
const typename MatrixType::RealScalar& sigma=1)
   393     tmp = transpositions * w;
   401   template<
typename MatrixType, 
typename TranspositionType, 
typename Workspace>
   408   template<
typename MatrixType, 
typename TranspositionType, 
typename Workspace, 
typename WType>
   409   static EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w, 
const typename MatrixType::RealScalar& sigma=1)
   420   static inline MatrixL 
getL(
const MatrixType& m) { 
return m; }
   421   static inline MatrixU 
getU(
const MatrixType& m) { 
return m.
adjoint(); }
   428   static inline MatrixL 
getL(
const MatrixType& m) { 
return m.
adjoint(); }
   429   static inline MatrixU 
getU(
const MatrixType& m) { 
return m; }
   436 template<
typename MatrixType, 
int _UpLo>
   440   const Index size = a.rows();
   444   m_transpositions.resize(size);
   445   m_isInitialized = 
false;
   446   m_temporary.resize(size);
   450   m_isInitialized = 
true;
   459 template<
typename MatrixType, 
int _UpLo>
   460 template<
typename Derived>
   463   const Index size = w.rows();
   470     m_matrix.resize(size,size);
   472     m_transpositions.resize(size);
   473     for (
Index i = 0; i < size; i++)
   474       m_transpositions.coeffRef(i) = i;
   475     m_temporary.resize(size);
   476     m_sign = sigma>=0 ? 1 : -1;
   477     m_isInitialized = 
true;
   486 template<
typename _MatrixType, 
int _UpLo, 
typename Rhs>
   493   template<typename Dest> 
void evalTo(Dest& dst)
 const   495     eigen_assert(rhs().rows() == dec().matrixLDLT().rows());
   497     dst = dec().transpositionsP() * rhs();
   500     dec().matrixL().solveInPlace(dst);
   512     for (
Index i = 0; i < vectorD.size(); ++i) {
   513       if(
abs(vectorD(i)) > tolerance)
   514         dst.row(i) /= vectorD(i);
   516         dst.row(i).setZero();
   520     dec().matrixU().solveInPlace(dst);
   523     dst = dec().transpositionsP().transpose() * dst;
   541 template<
typename MatrixType,
int _UpLo>
   542 template<
typename Derived>
   545   eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   548   bAndX = this->solve(bAndX);
   556 template<
typename MatrixType, 
int _UpLo>
   559   eigen_assert(m_isInitialized && 
"LDLT is not initialized.");
   560   const Index size = m_matrix.rows();
   565   res = transpositionsP() * res;
   567   res = matrixU() * res;
   569   res = vectorD().asDiagonal() * res;
   571   res = matrixL() * res;
   573   res = transpositionsP().transpose() * res;
   581 template<
typename MatrixType, 
unsigned int UpLo>
   591 template<
typename Derived>
   600 #endif // EIGEN_LDLT_H Robust Cholesky decomposition of a matrix with pivoting. 
TranspositionType m_transpositions
const LDLT< PlainObject > ldlt() const 
NumTraits< typename MatrixType::Scalar >::Real RealScalar
static bool update(MatrixType &mat, const TranspositionType &transpositions, Workspace &tmp, const WType &w, const typename MatrixType::RealScalar &sigma=1)
#define EIGEN_STRONG_INLINE
const TriangularView< const typename MatrixType::AdjointReturnType, TransposeMode > adjoint() const 
SegmentReturnType tail(Index vecSize)
Expression of the transpose of a matrix. 
LDLT(Index size)
Default Constructor with memory preallocation. 
LDLT & rankUpdate(const MatrixBase< Derived > &w, const RealScalar &alpha=1)
static bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, int *sign=0)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
static bool updateInPlace(MatrixType &mat, MatrixBase< WDerived > &w, const typename MatrixType::RealScalar &sigma=1)
const unsigned int RowMajorBit
Matrix< Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1 > TmpMatrixType
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const 
const MatrixType & matrixLDLT() const 
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const 
RealReturnType real() const 
static EIGEN_STRONG_INLINE bool update(MatrixType &mat, TranspositionType &transpositions, Workspace &tmp, WType &w, const typename MatrixType::RealScalar &sigma=1)
LDLT()
Default Constructor. 
bool solveInPlace(MatrixBase< Derived > &bAndX) const 
bool isNegative(void) const 
const TriangularView< const typename MatrixType::AdjointReturnType, UnitLower > MatrixL
const TriangularView< const MatrixType, UnitLower > MatrixL
Transpositions< RowsAtCompileTime, MaxRowsAtCompileTime > TranspositionType
MatrixType reconstructedMatrix() const 
static MatrixL getL(const MatrixType &m)
internal::LDLT_Traits< MatrixType, UpLo > Traits
const TranspositionType & transpositionsP() const 
static MatrixU getU(const MatrixType &m)
Traits::MatrixU matrixU() const 
TmpMatrixType m_temporary
LDLT< _MatrixType, _UpLo > LDLTType
TFSIMD_FORCE_INLINE const tfScalar & w() const 
static MatrixU getU(const MatrixType &m)
ComputationInfo info() const 
Reports whether previous computation was successful. 
Expression of a fixed-size or dynamic-size block. 
MatrixType::Scalar Scalar
Diagonal< const MatrixType > vectorD() const 
Traits::MatrixL matrixL() const 
Base class for triangular part in a matrix. 
static EIGEN_STRONG_INLINE bool unblocked(MatrixType &mat, TranspositionType &transpositions, Workspace &temp, int *sign=0)
#define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType, Rhs)
const TriangularView< const MatrixType, UnitUpper > MatrixU
const TriangularView< const typename MatrixType::AdjointReturnType, UnitUpper > MatrixU
Expression of a diagonal/subdiagonal/superdiagonal in a matrix. 
const internal::solve_retval< LDLT, Rhs > solve(const MatrixBase< Rhs > &b) const 
Base class for all dense matrices, vectors, and expressions. 
PermutationMatrix< RowsAtCompileTime, MaxRowsAtCompileTime > PermutationType
bool() isfinite(const T &x)
LDLT & compute(const MatrixType &matrix)
LDLT(const MatrixType &matrix)
Constructor with decomposition. 
const LDLT< PlainObject, UpLo > ldlt() const 
static MatrixL getL(const MatrixType &m)