10 #ifndef EIGEN_SIMPLICIAL_CHOLESKY_H
11 #define EIGEN_SIMPLICIAL_CHOLESKY_H
23 template<
typename CholMatrixType,
typename InputMatrixType>
24 struct simplicial_cholesky_grab_input {
25 typedef CholMatrixType
const * ConstCholMatrixPtr;
26 static void run(
const InputMatrixType& input, ConstCholMatrixPtr &pmat, CholMatrixType &tmp)
33 template<
typename MatrixType>
56 template<
typename Derived>
64 typedef typename internal::traits<Derived>::OrderingType
OrderingType;
65 enum {
UpLo = internal::traits<Derived>::UpLo };
106 Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
107 const Derived&
derived()
const {
return *
static_cast<const Derived*
>(
this); }
149 #ifndef EIGEN_PARSED_BY_DOXYGEN
151 template<
typename Stream>
152 void dumpMemory(Stream& s)
156 s <<
" diag: " << ((total+=
m_diag.size() *
sizeof(
Scalar)) >> 20) <<
"Mb" <<
"\n";
157 s <<
" tree: " << ((total+=
m_parent.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
158 s <<
" nonzeros: " << ((total+=
m_nonZerosPerCol.size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
159 s <<
" perm: " << ((total+=
m_P.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
160 s <<
" perm^-1: " << ((total+=
m_Pinv.
size() *
sizeof(int)) >> 20) <<
"Mb" <<
"\n";
161 s <<
" TOTAL: " << (total>> 20) <<
"Mb" <<
"\n";
165 template<
typename Rhs,
typename Dest>
166 void _solve_impl(
const MatrixBase<Rhs> &
b, MatrixBase<Dest> &dest)
const
168 eigen_assert(
m_factorizationIsOk &&
"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()");
180 derived().matrixL().solveInPlace(dest);
183 dest =
m_diag.asDiagonal().inverse() * dest;
186 derived().matrixU().solveInPlace(dest);
192 template<
typename Rhs,
typename Dest>
193 void _solve_impl(
const SparseMatrixBase<Rhs> &
b, SparseMatrixBase<Dest> &dest)
const
203 template<
bool DoLDLT>
212 factorize_preordered<DoLDLT>(*pmat);
215 template<
bool DoLDLT>
226 internal::simplicial_cholesky_grab_input<CholMatrixType,MatrixType>::run(
a, pmat, tmp);
230 tmp.template selfadjointView<Upper>() =
a.template selfadjointView<UpLo>().twistedBy(
m_P);
234 factorize_preordered<DoLDLT>(*pmat);
237 template<
bool DoLDLT>
276 template<
typename MatrixType_,
int UpLo_ = Lower,
typename Ordering_ = AMDOrdering<
typename MatrixType_::StorageIndex> >
class SimplicialLLT;
277 template<
typename MatrixType_,
int UpLo_ = Lower,
typename Ordering_ = AMDOrdering<
typename MatrixType_::StorageIndex> >
class SimplicialLDLT;
278 template<
typename MatrixType_,
int UpLo_ = Lower,
typename Ordering_ = AMDOrdering<
typename MatrixType_::StorageIndex> >
class SimplicialCholesky;
282 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
struct traits<
SimplicialLLT<MatrixType_,UpLo_,Ordering_> >
285 typedef Ordering_ OrderingType;
286 enum { UpLo = UpLo_ };
289 typedef SparseMatrix<Scalar, ColMajor, StorageIndex> CholMatrixType;
290 typedef TriangularView<const CholMatrixType, Eigen::Lower> MatrixL;
291 typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::Upper> MatrixU;
292 static inline MatrixL getL(
const CholMatrixType&
m) {
return MatrixL(
m); }
293 static inline MatrixU getU(
const CholMatrixType&
m) {
return MatrixU(
m.adjoint()); }
296 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
struct traits<SimplicialLDLT<MatrixType_,UpLo_,Ordering_> >
299 typedef Ordering_ OrderingType;
300 enum { UpLo = UpLo_ };
303 typedef SparseMatrix<Scalar, ColMajor, StorageIndex> CholMatrixType;
304 typedef TriangularView<const CholMatrixType, Eigen::UnitLower> MatrixL;
305 typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::UnitUpper> MatrixU;
306 static inline MatrixL getL(
const CholMatrixType&
m) {
return MatrixL(
m); }
307 static inline MatrixU getU(
const CholMatrixType&
m) {
return MatrixU(
m.adjoint()); }
310 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
struct traits<SimplicialCholesky<MatrixType_,UpLo_,Ordering_> >
313 typedef Ordering_ OrderingType;
314 enum { UpLo = UpLo_ };
339 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
351 typedef internal::traits<SimplicialLLT>
Traits;
376 Base::template compute<false>(matrix);
399 Base::template factorize<false>(
a);
430 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
442 typedef internal::traits<SimplicialLDLT>
Traits;
473 Base::template compute<true>(matrix);
496 Base::template factorize<true>(
a);
512 template<
typename MatrixType_,
int UpLo_,
typename Ordering_>
524 typedef internal::traits<SimplicialCholesky>
Traits;
525 typedef internal::traits<SimplicialLDLT<MatrixType,UpLo> >
LDLTTraits;
526 typedef internal::traits<SimplicialLLT<MatrixType,UpLo> >
LLTTraits;
566 Base::template compute<true>(matrix);
568 Base::template compute<false>(matrix);
592 Base::template factorize<true>(
a);
594 Base::template factorize<false>(
a);
598 template<
typename Rhs,
typename Dest>
621 dest =
Base::m_diag.real().asDiagonal().inverse() * dest;
636 template<
typename Rhs,
typename Dest>
659 template<
typename Derived>
670 C =
a.template selfadjointView<UpLo>();
676 if(m_Pinv.size()>0) m_P = m_Pinv.inverse();
680 ap.template selfadjointView<Upper>() =
a.template selfadjointView<UpLo>().twistedBy(m_P);
686 if(
int(UpLo)==
int(
Lower) || MatrixType::IsRowMajor)
690 ap.template selfadjointView<Upper>() =
a.template selfadjointView<UpLo>();
693 internal::simplicial_cholesky_grab_input<CholMatrixType,MatrixType>::run(
a, pmat, ap);
RowXpr row(Index i)
This is the const version of row(). */.
ColXpr col(Index i)
This is the const version of col().
Matrix< float, 1, Dynamic > MatrixType
NumTraits< Scalar >::Real RealScalar
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
internal::traits< Derived >::Scalar Scalar
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Base class for all dense matrices, vectors, and expressions.
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
constexpr void resize(Index rows, Index cols)
A base class for direct sparse Cholesky factorizations.
SparseSolverBase< Derived > Base
PermutationMatrix< Dynamic, Dynamic, StorageIndex > m_P
const PermutationMatrix< Dynamic, Dynamic, StorageIndex > & permutationPinv() const
MatrixType::RealScalar RealScalar
CholMatrixType const * ConstCholMatrixPtr
void factorize_preordered(const CholMatrixType &a)
Derived & setShift(const RealScalar &offset, const RealScalar &scale=1)
ComputationInfo info() const
Reports whether previous computation was successful.
void ordering(const MatrixType &a, ConstCholMatrixPtr &pmat, CholMatrixType &ap)
MatrixType::Scalar Scalar
Matrix< StorageIndex, Dynamic, 1 > VectorI
MatrixType::StorageIndex StorageIndex
SimplicialCholeskyBase(const MatrixType &matrix)
void compute(const MatrixType &matrix)
Matrix< Scalar, Dynamic, 1 > VectorType
void analyzePattern(const MatrixType &a, bool doLDLT)
const Derived & derived() const
void analyzePattern_preordered(const CholMatrixType &a, bool doLDLT)
internal::traits< Derived >::MatrixType MatrixType
PermutationMatrix< Dynamic, Dynamic, StorageIndex > m_Pinv
~SimplicialCholeskyBase()
void factorize(const MatrixType &a)
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
internal::traits< Derived >::OrderingType OrderingType
const PermutationMatrix< Dynamic, Dynamic, StorageIndex > & permutationP() const
void _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &dest) const
MatrixType::Scalar Scalar
MatrixType::RealScalar RealScalar
SimplicialCholesky & compute(const MatrixType &matrix)
void factorize(const MatrixType &a)
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
SimplicialCholesky & setMode(SimplicialCholeskyMode mode)
void _solve_impl(const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
const VectorType vectorD() const
void analyzePattern(const MatrixType &a)
internal::traits< SimplicialLDLT< MatrixType, UpLo > > LDLTTraits
Scalar determinant() const
SimplicialCholesky(const MatrixType &matrix)
internal::traits< SimplicialCholesky > Traits
SimplicialCholeskyBase< SimplicialCholesky > Base
MatrixType::StorageIndex StorageIndex
internal::traits< SimplicialLLT< MatrixType, UpLo > > LLTTraits
Matrix< Scalar, Dynamic, 1 > VectorType
const CholMatrixType rawMatrix() const
A direct sparse LDLT Cholesky factorizations without square root.
MatrixType::RealScalar RealScalar
Scalar determinant() const
const MatrixL matrixL() const
SimplicialLDLT(const MatrixType &matrix)
MatrixType::Scalar Scalar
const MatrixU matrixU() const
SimplicialCholeskyBase< SimplicialLDLT > Base
Matrix< Scalar, Dynamic, 1 > VectorType
SimplicialLDLT & compute(const MatrixType &matrix)
internal::traits< SimplicialLDLT > Traits
void analyzePattern(const MatrixType &a)
void factorize(const MatrixType &a)
const VectorType vectorD() const
SparseMatrix< Scalar, ColMajor, StorageIndex > CholMatrixType
MatrixType::StorageIndex StorageIndex
A direct sparse LLT Cholesky factorizations.
MatrixType::Scalar Scalar
MatrixType::StorageIndex StorageIndex
const MatrixL matrixL() const
SparseMatrix< Scalar, ColMajor, Index > CholMatrixType
Scalar determinant() const
Matrix< Scalar, Dynamic, 1 > VectorType
SimplicialCholeskyBase< SimplicialLLT > Base
internal::traits< SimplicialLLT > Traits
SimplicialLLT & compute(const MatrixType &matrix)
MatrixType::RealScalar RealScalar
const MatrixU matrixU() const
void analyzePattern(const MatrixType &a)
void factorize(const MatrixType &a)
SimplicialLLT(const MatrixType &matrix)
Base class of any sparse matrices or sparse expressions.
const ConstDiagonalReturnType diagonal() const
void resize(Index rows, Index cols)
A base class for sparse solvers.
std::enable_if_t< Rhs::ColsAtCompileTime!=1 &&Dest::ColsAtCompileTime!=1 > solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs &rhs, Dest &dest)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
bool operator()(const Index &row, const Index &col, const Scalar &) const