10 #ifndef EIGEN_SIMPLICIAL_CHOLESKY_H 11 #define EIGEN_SIMPLICIAL_CHOLESKY_H 35 template<
typename Derived>
41 typedef typename MatrixType::Scalar
Scalar;
43 typedef typename MatrixType::Index
Index;
64 Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
65 const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
85 template<
typename Rhs>
91 &&
"SimplicialCholeskyBase::solve(): invalid number of rows of the right hand side matrix b");
99 template<
typename Rhs>
105 &&
"SimplicialCholesky::solve(): invalid number of rows of the right hand side matrix b");
128 Derived&
setShift(
const RealScalar& offset,
const RealScalar& scale = 1)
135 #ifndef EIGEN_PARSED_BY_DOXYGEN 137 template<
typename Stream>
142 s <<
" diag: " << ((total+=
m_diag.size() *
sizeof(
Scalar)) >> 20) <<
"Mb" <<
"\n";
143 s <<
" tree: " << ((total+=
m_parent.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
144 s <<
" nonzeros: " << ((total+=
m_nonZerosPerCol.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
145 s <<
" perm: " << ((total+=
m_P.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
146 s <<
" perm^-1: " << ((total+=
m_Pinv.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
147 s <<
" TOTAL: " << (total>> 20) <<
"Mb" <<
"\n";
151 template<
typename Rhs,
typename Dest>
154 eigen_assert(
m_factorizationIsOk &&
"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()");
166 derived().matrixL().solveInPlace(dest);
169 dest =
m_diag.asDiagonal().inverse() * dest;
172 derived().matrixU().solveInPlace(dest);
178 #endif // EIGEN_PARSED_BY_DOXYGEN 183 template<
bool DoLDLT>
187 Index size = matrix.cols();
188 CholMatrixType ap(size,size);
191 factorize_preordered<DoLDLT>(ap);
194 template<
bool DoLDLT>
199 CholMatrixType ap(size,size);
200 ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().
twistedBy(
m_P);
201 factorize_preordered<DoLDLT>(ap);
204 template<
bool DoLDLT>
211 CholMatrixType ap(size,size);
217 void ordering(
const MatrixType& a, CholMatrixType& ap);
253 typedef typename MatrixType::Scalar
Scalar;
254 typedef typename MatrixType::Index
Index;
258 static inline MatrixL
getL(
const MatrixType& m) {
return m; }
259 static inline MatrixU
getU(
const MatrixType& m) {
return m.
adjoint(); }
266 typedef typename MatrixType::Scalar
Scalar;
267 typedef typename MatrixType::Index
Index;
271 static inline MatrixL
getL(
const MatrixType& m) {
return m; }
272 static inline MatrixU
getU(
const MatrixType& m) {
return m.
adjoint(); }
300 template<
typename _MatrixType,
int _UpLo>
307 typedef typename MatrixType::Scalar
Scalar;
309 typedef typename MatrixType::Index
Index;
324 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial LLT not factorized");
325 return Traits::getL(Base::m_matrix);
330 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial LLT not factorized");
331 return Traits::getU(Base::m_matrix);
337 Base::template compute<false>(matrix);
349 Base::analyzePattern(a,
false);
360 Base::template factorize<false>(a);
366 Scalar detL = Base::m_matrix.diagonal().prod();
388 template<
typename _MatrixType,
int _UpLo>
395 typedef typename MatrixType::Scalar
Scalar;
397 typedef typename MatrixType::Index
Index;
413 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial LDLT not factorized");
418 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial LDLT not factorized");
419 return Traits::getL(Base::m_matrix);
424 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial LDLT not factorized");
425 return Traits::getU(Base::m_matrix);
431 Base::template compute<true>(matrix);
443 Base::analyzePattern(a,
true);
454 Base::template factorize<true>(a);
460 return Base::m_diag.prod();
470 template<
typename _MatrixType,
int _UpLo>
477 typedef typename MatrixType::Scalar
Scalar;
479 typedef typename MatrixType::Index
Index;
489 : Base(), m_LDLT(true)
512 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial Cholesky not factorized");
516 eigen_assert(Base::m_factorizationIsOk &&
"Simplicial Cholesky not factorized");
517 return Base::m_matrix;
524 Base::template compute<true>(matrix);
526 Base::template compute<false>(matrix);
538 Base::analyzePattern(a, m_LDLT);
550 Base::template factorize<true>(a);
552 Base::template factorize<false>(a);
556 template<
typename Rhs,
typename Dest>
559 eigen_assert(Base::m_factorizationIsOk &&
"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()");
565 if(Base::m_P.size()>0)
566 dest = Base::m_P * b;
570 if(Base::m_matrix.nonZeros()>0)
573 LDLTTraits::getL(Base::m_matrix).solveInPlace(dest);
575 LLTTraits::getL(Base::m_matrix).solveInPlace(dest);
578 if(Base::m_diag.size()>0)
579 dest = Base::m_diag.
asDiagonal().inverse() * dest;
581 if (Base::m_matrix.nonZeros()>0)
584 LDLTTraits::getU(Base::m_matrix).solveInPlace(dest);
586 LLTTraits::getU(Base::m_matrix).solveInPlace(dest);
589 if(Base::m_P.size()>0)
590 dest = Base::m_Pinv * dest;
597 return Base::m_diag.prod();
610 template<
typename Derived>
614 const Index size = a.rows();
619 C = a.template selfadjointView<UpLo>();
632 ap.template selfadjointView<Upper>() = a.template selfadjointView<UpLo>().
twistedBy(
m_P);
637 template<
typename Derived,
typename Rhs>
644 template<typename Dest>
void evalTo(Dest& dst)
const 646 dec().derived()._solve(
rhs(),dst);
650 template<
typename Derived,
typename Rhs>
657 template<typename Dest>
void evalTo(Dest& dst)
const 659 this->defaultEvalTo(dst);
667 #endif // EIGEN_SIMPLICIAL_CHOLESKY_H PermutationMatrix< Dynamic, Dynamic, Index > m_P
SimplicialCholesky(const MatrixType &matrix)
internal::traits< SimplicialLDLT< MatrixType, UpLo > > LDLTTraits
bool operator()(const Index &row, const Index &col, const Scalar &) const
void factorize(const MatrixType &a)
const AdjointReturnType adjoint() const
SimplicialCholeskyBase< SimplicialCholesky > Base
MatrixType::Scalar Scalar
SimplicialCholeskyBase< SimplicialLLT > Base
VectorXi m_nonZerosPerCol
Derived & setShift(const RealScalar &offset, const RealScalar &scale=1)
void analyzePattern(const MatrixType &a)
const internal::solve_retval< SimplicialCholeskyBase, Rhs > solve(const MatrixBase< Rhs > &b) const
MatrixType::RealScalar RealScalar
internal::traits< SimplicialLLT > Traits
static MatrixU getU(const MatrixType &m)
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
~SimplicialCholeskyBase()
iterative scaling algorithm to equilibrate rows and column norms in matrices
SimplicialCholeskyBase(const MatrixType &matrix)
A direct sparse LDLT Cholesky factorizations without square root.
void analyzePattern(const MatrixType &a)
SimplicialCholesky & setMode(SimplicialCholeskyMode mode)
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
void analyzePattern_preordered(const CholMatrixType &a, bool doLDLT)
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
Matrix< Scalar, Dynamic, 1 > VectorType
const VectorType vectorD() const
SimplicialCholeskyBase< Derived > Dec
internal::traits< SimplicialLLT< MatrixType, UpLo > > LLTTraits
SimplicialLLT & compute(const MatrixType &matrix)
const internal::sparse_solve_retval< SimplicialCholeskyBase, Rhs > solve(const SparseMatrixBase< Rhs > &b) const
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
const MatrixU matrixU() const
Scalar determinant() const
SparseSymmetricPermutationProduct< Derived, Upper|Lower > twistedBy(const PermutationMatrix< Dynamic, Dynamic, Index > &perm) const
Matrix< Scalar, Dynamic, 1 > VectorType
MatrixType::Scalar Scalar
const Derived & derived() const
void factorize(const MatrixType &a)
SimplicialCholeskyBase< Derived > Dec
void compute(const MatrixType &matrix)
Base class of any sparse matrices or sparse expressions.
void ordering(const MatrixType &a, CholMatrixType &ap)
Matrix< Scalar, Dynamic, 1 > VectorType
void factorize(const MatrixType &a)
void factorize(const MatrixType &a)
A direct sparse Cholesky factorizations.
const MatrixL matrixL() const
const PermutationMatrix< Dynamic, Dynamic, Index > & permutationPinv() const
MatrixType::Scalar Scalar
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
internal::traits< SimplicialLDLT > Traits
void resize(Index rows, Index cols)
void minimum_degree_ordering(SparseMatrix< Scalar, ColMajor, Index > &C, PermutationMatrix< Dynamic, Dynamic, Index > &perm)
void analyzePattern(const MatrixType &a, bool doLDLT)
ComputationInfo info() const
Reports whether previous computation was successful.
MatrixType::RealScalar RealScalar
#define EIGEN_MAKE_SPARSE_SOLVE_HELPERS(DecompositionType, Rhs)
Transpose< PermutationBase > inverse() const
static MatrixL getL(const MatrixType &m)
Scalar determinant() const
void rhs(const real_t *x, real_t *f)
void factorize_preordered(const CholMatrixType &a)
MatrixType::RealScalar RealScalar
const VectorType vectorD() const
MatrixType::Scalar Scalar
SimplicialCholesky & compute(const MatrixType &matrix)
SparseTriangularView< CholMatrixType, Eigen::Lower > MatrixL
MatrixType::Scalar Scalar
internal::traits< Derived >::MatrixType MatrixType
const Derived & derived() const
SimplicialLDLT & compute(const MatrixType &matrix)
Scalar determinant() const
SparseTriangularView< typename CholMatrixType::AdjointReturnType, Eigen::UnitUpper > MatrixU
void analyzePattern(const MatrixType &a)
internal::traits< SimplicialCholesky > Traits
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
void _solve(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
#define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType, Rhs)
MatrixType::Scalar Scalar
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Matrix< Scalar, Dynamic, 1 > VectorType
MatrixType::RealScalar RealScalar
void dumpMemory(Stream &s)
A direct sparse LLT Cholesky factorizations.
SparseTriangularView< typename CholMatrixType::AdjointReturnType, Eigen::Upper > MatrixU
SimplicialCholeskyBase< SimplicialLDLT > Base
const PermutationMatrix< Dynamic, Dynamic, Index > & permutationP() const
const DiagonalWrapper< const Derived > asDiagonal() const
const MatrixL matrixL() const
void resize(Index newSize)
SimplicialLDLT(const MatrixType &matrix)
const CholMatrixType rawMatrix() const
const MatrixU matrixU() const
void _solve(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
Base class for all dense matrices, vectors, and expressions.
SparseTriangularView< CholMatrixType, Eigen::UnitLower > MatrixL
static MatrixU getU(const MatrixType &m)
static MatrixL getL(const MatrixType &m)
PermutationMatrix< Dynamic, Dynamic, Index > m_Pinv
SimplicialLLT(const MatrixType &matrix)