10#ifndef EIGEN_SIMPLICIAL_CHOLESKY_H
11#define EIGEN_SIMPLICIAL_CHOLESKY_H
21 template<
typename CholMatrixType,
typename InputMatrixType>
31 template<
typename MatrixType>
54template<
typename Derived>
64 typedef typename MatrixType::Scalar
Scalar;
104 Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
105 const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
117 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
147#ifndef EIGEN_PARSED_BY_DOXYGEN
149 template<
typename Stream>
154 s <<
" diag: " << ((total+=
m_diag.size() *
sizeof(
Scalar)) >> 20) <<
"Mb" <<
"\n";
155 s <<
" tree: " << ((total+=
m_parent.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
156 s <<
" nonzeros: " << ((total+=
m_nonZerosPerCol.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
157 s <<
" perm: " << ((total+=
m_P.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
158 s <<
" perm^-1: " << ((total+=
m_Pinv.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
159 s <<
" TOTAL: " << (total>> 20) <<
"Mb" <<
"\n";
163 template<
typename Rhs,
typename Dest>
166 eigen_assert(
m_factorizationIsOk &&
"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()");
178 derived().matrixL().solveInPlace(dest);
181 dest =
m_diag.asDiagonal().inverse() * dest;
184 derived().matrixU().solveInPlace(dest);
190 template<
typename Rhs,
typename Dest>
201 template<
bool DoLDLT>
210 factorize_preordered<DoLDLT>(*pmat);
213 template<
bool DoLDLT>
228 tmp.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().
twistedBy(
m_P);
232 factorize_preordered<DoLDLT>(*pmat);
235 template<
bool DoLDLT>
274template<
typename _MatrixType,
int _UpLo = Lower,
typename _Ordering = AMDOrdering<
typename _MatrixType::StorageIndex> >
class SimplicialLLT;
275template<
typename _MatrixType,
int _UpLo = Lower,
typename _Ordering = AMDOrdering<
typename _MatrixType::StorageIndex> >
class SimplicialLDLT;
276template<
typename _MatrixType,
int _UpLo = Lower,
typename _Ordering = AMDOrdering<
typename _MatrixType::StorageIndex> >
class SimplicialCholesky;
280template<
typename _MatrixType,
int _UpLo,
typename _Ordering>
struct traits<
SimplicialLLT<_MatrixType,_UpLo,_Ordering> >
284 enum { UpLo = _UpLo };
285 typedef typename MatrixType::Scalar
Scalar;
294template<
typename _MatrixType,
int _UpLo,
typename _Ordering>
struct traits<
SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >
298 enum { UpLo = _UpLo };
299 typedef typename MatrixType::Scalar
Scalar;
312 enum { UpLo = _UpLo };
337template<
typename _MatrixType,
int _UpLo,
typename _Ordering>
344 typedef typename MatrixType::Scalar
Scalar;
374 Base::template compute<false>(matrix);
397 Base::template factorize<false>(a);
428template<
typename _MatrixType,
int _UpLo,
typename _Ordering>
435 typedef typename MatrixType::Scalar
Scalar;
471 Base::template compute<true>(matrix);
494 Base::template factorize<true>(a);
510template<
typename _MatrixType,
int _UpLo,
typename _Ordering>
517 typedef typename MatrixType::Scalar
Scalar;
564 Base::template compute<true>(matrix);
566 Base::template compute<false>(matrix);
590 Base::template factorize<true>(a);
592 Base::template factorize<false>(a);
596 template<
typename Rhs,
typename Dest>
619 dest =
Base::m_diag.real().asDiagonal().inverse() * dest;
634 template<
typename Rhs,
typename Dest>
657template<
typename Derived>
668 C = a.template selfadjointView<UpLo>();
674 if(m_Pinv.size()>0) m_P = m_Pinv.inverse();
678 ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().
twistedBy(m_P);
684 if(
int(UpLo)==
int(
Lower) || MatrixType::IsRowMajor)
688 ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>();
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ColXpr col(Index i)
This is the const version of col().
Definition: BlockMethods.h:1097
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE RowXpr row(Index i)
This is the const version of row(). */.
Definition: BlockMethods.h:1118
#define eigen_assert(x)
Definition: Macros.h:1047
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:65
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
Functor computing the natural ordering (identity)
Definition: Ordering.h:92
EIGEN_DEVICE_FUNC Index size() const
Definition: PermutationMatrix.h:97
A base class for direct sparse Cholesky factorizations.
Definition: SimplicialCholesky.h:56
SimplicialCholeskyBase()
Default constructor.
Definition: SimplicialCholesky.h:82
PermutationMatrix< Dynamic, Dynamic, StorageIndex > m_P
Definition: SimplicialCholesky.h:267
MatrixType::RealScalar RealScalar
Definition: SimplicialCholesky.h:65
VectorI m_parent
Definition: SimplicialCholesky.h:265
CholMatrixType const * ConstCholMatrixPtr
Definition: SimplicialCholesky.h:68
void factorize_preordered(const CholMatrixType &a)
Definition: SimplicialCholesky_impl.h:76
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Definition: SimplicialCholesky.h:164
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: SimplicialCholesky.h:115
bool m_analysisIsOk
Definition: SimplicialCholesky.h:261
const PermutationMatrix< Dynamic, Dynamic, StorageIndex > & permutationP() const
Definition: SimplicialCholesky.h:123
void ordering(const MatrixType &a, ConstCholMatrixPtr &pmat, CholMatrixType &ap)
Definition: SimplicialCholesky.h:658
RealScalar m_shiftOffset
Definition: SimplicialCholesky.h:270
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:64
Matrix< StorageIndex, Dynamic, 1 > VectorI
Definition: SimplicialCholesky.h:70
void dumpMemory(Stream &s)
Definition: SimplicialCholesky.h:150
CholMatrixType m_matrix
Definition: SimplicialCholesky.h:263
void _solve_impl(const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
Definition: SimplicialCholesky.h:191
Derived & setShift(const RealScalar &offset, const RealScalar &scale=1)
Sets the shift parameters that will be used to adjust the diagonal coefficients during the numerical ...
Definition: SimplicialCholesky.h:140
Derived & derived()
Definition: SimplicialCholesky.h:104
@ ColsAtCompileTime
Definition: SimplicialCholesky.h:73
@ MaxColsAtCompileTime
Definition: SimplicialCholesky.h:74
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:66
SimplicialCholeskyBase(const MatrixType &matrix)
Definition: SimplicialCholesky.h:90
void compute(const MatrixType &matrix)
Computes the sparse Cholesky decomposition of matrix.
Definition: SimplicialCholesky.h:202
Matrix< Scalar, Dynamic, 1 > VectorType
Definition: SimplicialCholesky.h:69
Index cols() const
Definition: SimplicialCholesky.h:107
VectorType m_diag
Definition: SimplicialCholesky.h:264
@ UpLo
Definition: SimplicialCholesky.h:63
void analyzePattern(const MatrixType &a, bool doLDLT)
Definition: SimplicialCholesky.h:238
Index rows() const
Definition: SimplicialCholesky.h:108
const PermutationMatrix< Dynamic, Dynamic, StorageIndex > & permutationPinv() const
Definition: SimplicialCholesky.h:128
void analyzePattern_preordered(const CholMatrixType &a, bool doLDLT)
Definition: SimplicialCholesky_impl.h:26
internal::traits< Derived >::MatrixType MatrixType
Definition: SimplicialCholesky.h:61
PermutationMatrix< Dynamic, Dynamic, StorageIndex > m_Pinv
Definition: SimplicialCholesky.h:268
~SimplicialCholeskyBase()
Definition: SimplicialCholesky.h:100
VectorI m_nonZerosPerCol
Definition: SimplicialCholesky.h:266
void factorize(const MatrixType &a)
Definition: SimplicialCholesky.h:214
const Derived & derived() const
Definition: SimplicialCholesky.h:105
bool m_factorizationIsOk
Definition: SimplicialCholesky.h:260
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
Definition: SimplicialCholesky.h:67
RealScalar m_shiftScale
Definition: SimplicialCholesky.h:271
ComputationInfo m_info
Definition: SimplicialCholesky.h:259
internal::traits< Derived >::OrderingType OrderingType
Definition: SimplicialCholesky.h:62
Definition: SimplicialCholesky.h:512
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
Definition: SimplicialCholesky.h:520
SimplicialCholesky & setMode(SimplicialCholeskyMode mode)
Definition: SimplicialCholesky.h:534
@ UpLo
Definition: SimplicialCholesky.h:515
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Definition: SimplicialCholesky.h:597
Scalar determinant() const
Definition: SimplicialCholesky.h:640
SimplicialCholesky(const MatrixType &matrix)
Definition: SimplicialCholesky.h:528
MatrixType::RealScalar RealScalar
Definition: SimplicialCholesky.h:518
SimplicialCholesky & compute(const MatrixType &matrix)
Computes the sparse Cholesky decomposition of matrix.
Definition: SimplicialCholesky.h:561
internal::traits< SimplicialCholesky > Traits
Definition: SimplicialCholesky.h:522
bool m_LDLT
Definition: SimplicialCholesky.h:654
SimplicialCholeskyBase< SimplicialCholesky > Base
Definition: SimplicialCholesky.h:516
void analyzePattern(const MatrixType &a)
Performs a symbolic decomposition on the sparcity of matrix.
Definition: SimplicialCholesky.h:576
internal::traits< SimplicialLDLT< MatrixType, UpLo > > LDLTTraits
Definition: SimplicialCholesky.h:523
internal::traits< SimplicialLLT< MatrixType, UpLo > > LLTTraits
Definition: SimplicialCholesky.h:524
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:517
void _solve_impl(const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
Definition: SimplicialCholesky.h:635
const CholMatrixType rawMatrix() const
Definition: SimplicialCholesky.h:555
_MatrixType MatrixType
Definition: SimplicialCholesky.h:514
void factorize(const MatrixType &a)
Performs a numeric decomposition of matrix.
Definition: SimplicialCholesky.h:587
Matrix< Scalar, Dynamic, 1 > VectorType
Definition: SimplicialCholesky.h:521
const VectorType vectorD() const
Definition: SimplicialCholesky.h:551
SimplicialCholesky()
Definition: SimplicialCholesky.h:526
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:519
A direct sparse LDLT Cholesky factorizations without square root.
Definition: SimplicialCholesky.h:430
SimplicialLDLT(const MatrixType &matrix)
Constructs and performs the LLT factorization of matrix.
Definition: SimplicialCholesky.h:448
MatrixType::RealScalar RealScalar
Definition: SimplicialCholesky.h:436
SimplicialLDLT()
Default constructor.
Definition: SimplicialCholesky.h:445
Traits::MatrixU MatrixU
Definition: SimplicialCholesky.h:442
Matrix< Scalar, Dynamic, 1 > VectorType
Definition: SimplicialCholesky.h:439
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:437
SimplicialLDLT & compute(const MatrixType &matrix)
Computes the sparse Cholesky decomposition of matrix.
Definition: SimplicialCholesky.h:469
_MatrixType MatrixType
Definition: SimplicialCholesky.h:432
SimplicialCholeskyBase< SimplicialLDLT > Base
Definition: SimplicialCholesky.h:434
void factorize(const MatrixType &a)
Performs a numeric decomposition of matrix.
Definition: SimplicialCholesky.h:492
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:435
Scalar determinant() const
Definition: SimplicialCholesky.h:498
void analyzePattern(const MatrixType &a)
Performs a symbolic decomposition on the sparcity of matrix.
Definition: SimplicialCholesky.h:481
const VectorType vectorD() const
Definition: SimplicialCholesky.h:452
Traits::MatrixL MatrixL
Definition: SimplicialCholesky.h:441
internal::traits< SimplicialLDLT > Traits
Definition: SimplicialCholesky.h:440
const MatrixL matrixL() const
Definition: SimplicialCholesky.h:457
const MatrixU matrixU() const
Definition: SimplicialCholesky.h:463
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
Definition: SimplicialCholesky.h:438
@ UpLo
Definition: SimplicialCholesky.h:433
A direct sparse LLT Cholesky factorizations.
Definition: SimplicialCholesky.h:339
Traits::MatrixL MatrixL
Definition: SimplicialCholesky.h:350
const MatrixU matrixU() const
Definition: SimplicialCholesky.h:366
@ UpLo
Definition: SimplicialCholesky.h:342
SimplicialLLT(const MatrixType &matrix)
Constructs and performs the LLT factorization of matrix.
Definition: SimplicialCholesky.h:356
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:346
SimplicialLLT & compute(const MatrixType &matrix)
Computes the sparse Cholesky decomposition of matrix.
Definition: SimplicialCholesky.h:372
void factorize(const MatrixType &a)
Performs a numeric decomposition of matrix.
Definition: SimplicialCholesky.h:395
Scalar determinant() const
Definition: SimplicialCholesky.h:401
SimplicialCholeskyBase< SimplicialLLT > Base
Definition: SimplicialCholesky.h:343
Traits::MatrixU MatrixU
Definition: SimplicialCholesky.h:351
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:344
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
Definition: SimplicialCholesky.h:347
SimplicialLLT()
Default constructor.
Definition: SimplicialCholesky.h:354
MatrixType::RealScalar RealScalar
Definition: SimplicialCholesky.h:345
void analyzePattern(const MatrixType &a)
Performs a symbolic decomposition on the sparcity of matrix.
Definition: SimplicialCholesky.h:384
Matrix< Scalar, Dynamic, 1 > VectorType
Definition: SimplicialCholesky.h:348
const MatrixL matrixL() const
Definition: SimplicialCholesky.h:360
_MatrixType MatrixType
Definition: SimplicialCholesky.h:341
internal::traits< SimplicialLLT > Traits
Definition: SimplicialCholesky.h:349
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:28
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
Definition: SparseMatrixBase.h:329
const AdjointReturnType adjoint() const
Definition: SparseMatrixBase.h:356
Index nonZeros() const
Definition: SparseCompressedBase.h:56
const ConstDiagonalReturnType diagonal() const
Definition: SparseMatrix.h:655
Index rows() const
Definition: SparseMatrix.h:138
Index cols() const
Definition: SparseMatrix.h:140
void resize(Index rows, Index cols)
Resizes the matrix to a rows x cols matrix and initializes it to zero.
Definition: SparseMatrix.h:626
A base class for sparse solvers.
Definition: SparseSolverBase.h:68
bool m_isInitialized
Definition: SparseSolverBase.h:119
Derived & derived()
Definition: SparseSolverBase.h:79
Expression of a triangular part in a matrix.
Definition: TriangularMatrix.h:189
ComputationInfo
Enum for reporting the status of a computation.
Definition: Constants.h:440
@ Lower
View matrix as a lower triangular matrix.
Definition: Constants.h:209
@ Upper
View matrix as an upper triangular matrix.
Definition: Constants.h:211
@ Success
Computation was successful.
Definition: Constants.h:442
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
enable_if< Rhs::ColsAtCompileTime!=1 &&Dest::ColsAtCompileTime!=1 >::type solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs &rhs, Dest &dest)
Definition: SparseSolverBase.h:23
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: MathFunctions.h:1292
Namespace containing all symbols from the Eigen library.
Definition: MatrixExponential.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
SimplicialCholeskyMode
Definition: SimplicialCholesky.h:15
@ SimplicialCholeskyLDLT
Definition: SimplicialCholesky.h:17
@ SimplicialCholeskyLLT
Definition: SimplicialCholesky.h:16
Definition: Eigen_Colamd.h:50
keeps off-diagonal entries; drops diagonal entries
Definition: SimplicialCholesky.h:252
bool operator()(const Index &row, const Index &col, const Scalar &) const
Definition: SimplicialCholesky.h:253
_MatrixType MatrixType
Definition: SimplicialCholesky.h:310
_Ordering OrderingType
Definition: SimplicialCholesky.h:311
TriangularView< const typename CholMatrixType::AdjointReturnType, Eigen::UnitUpper > MatrixU
Definition: SimplicialCholesky.h:303
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
Definition: SimplicialCholesky.h:301
static MatrixU getU(const CholMatrixType &m)
Definition: SimplicialCholesky.h:305
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:300
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:299
TriangularView< const CholMatrixType, Eigen::UnitLower > MatrixL
Definition: SimplicialCholesky.h:302
_MatrixType MatrixType
Definition: SimplicialCholesky.h:296
static MatrixL getL(const CholMatrixType &m)
Definition: SimplicialCholesky.h:304
_Ordering OrderingType
Definition: SimplicialCholesky.h:297
TriangularView< const typename CholMatrixType::AdjointReturnType, Eigen::Upper > MatrixU
Definition: SimplicialCholesky.h:289
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
Definition: SimplicialCholesky.h:287
_MatrixType MatrixType
Definition: SimplicialCholesky.h:282
MatrixType::StorageIndex StorageIndex
Definition: SimplicialCholesky.h:286
_Ordering OrderingType
Definition: SimplicialCholesky.h:283
static MatrixL getL(const CholMatrixType &m)
Definition: SimplicialCholesky.h:290
MatrixType::Scalar Scalar
Definition: SimplicialCholesky.h:285
TriangularView< const CholMatrixType, Eigen::Lower > MatrixL
Definition: SimplicialCholesky.h:288
static MatrixU getU(const CholMatrixType &m)
Definition: SimplicialCholesky.h:291
Definition: ForwardDeclarations.h:17