mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-29 00:02:40 +08:00
Merge with upstream.
This commit is contained in:
commit
a97aaa2bcf
@ -10,7 +10,7 @@
|
|||||||
#ifndef EIGEN_CHOLMODSUPPORT_H
|
#ifndef EIGEN_CHOLMODSUPPORT_H
|
||||||
#define EIGEN_CHOLMODSUPPORT_H
|
#define EIGEN_CHOLMODSUPPORT_H
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
@ -79,12 +79,12 @@ cholmod_sparse viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_StorageIndex> >
|
|||||||
|
|
||||||
res.dtype = 0;
|
res.dtype = 0;
|
||||||
res.stype = -1;
|
res.stype = -1;
|
||||||
|
|
||||||
if (internal::is_same<_StorageIndex,int>::value)
|
if (internal::is_same<_StorageIndex,int>::value)
|
||||||
{
|
{
|
||||||
res.itype = CHOLMOD_INT;
|
res.itype = CHOLMOD_INT;
|
||||||
}
|
}
|
||||||
else if (internal::is_same<_StorageIndex,long>::value)
|
else if (internal::is_same<_StorageIndex,SuiteSparse_long>::value)
|
||||||
{
|
{
|
||||||
res.itype = CHOLMOD_LONG;
|
res.itype = CHOLMOD_LONG;
|
||||||
}
|
}
|
||||||
@ -95,9 +95,9 @@ cholmod_sparse viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_StorageIndex> >
|
|||||||
|
|
||||||
// setup res.xtype
|
// setup res.xtype
|
||||||
internal::cholmod_configure_matrix<_Scalar>::run(res);
|
internal::cholmod_configure_matrix<_Scalar>::run(res);
|
||||||
|
|
||||||
res.stype = 0;
|
res.stype = 0;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ template<typename _Scalar, int _Options, typename _Index, unsigned int UpLo>
|
|||||||
cholmod_sparse viewAsCholmod(const SparseSelfAdjointView<const SparseMatrix<_Scalar,_Options,_Index>, UpLo>& mat)
|
cholmod_sparse viewAsCholmod(const SparseSelfAdjointView<const SparseMatrix<_Scalar,_Options,_Index>, UpLo>& mat)
|
||||||
{
|
{
|
||||||
cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_Index> >(mat.matrix().const_cast_derived()));
|
cholmod_sparse res = viewAsCholmod(Ref<SparseMatrix<_Scalar,_Options,_Index> >(mat.matrix().const_cast_derived()));
|
||||||
|
|
||||||
if(UpLo==Upper) res.stype = 1;
|
if(UpLo==Upper) res.stype = 1;
|
||||||
if(UpLo==Lower) res.stype = -1;
|
if(UpLo==Lower) res.stype = -1;
|
||||||
// swap stype for rowmajor matrices (only works for real matrices)
|
// swap stype for rowmajor matrices (only works for real matrices)
|
||||||
@ -168,11 +168,11 @@ namespace internal {
|
|||||||
|
|
||||||
#define EIGEN_CHOLMOD_SPECIALIZE0(ret, name) \
|
#define EIGEN_CHOLMOD_SPECIALIZE0(ret, name) \
|
||||||
template<typename _StorageIndex> inline ret cm_ ## name (cholmod_common &Common) { return cholmod_ ## name (&Common); } \
|
template<typename _StorageIndex> inline ret cm_ ## name (cholmod_common &Common) { return cholmod_ ## name (&Common); } \
|
||||||
template<> inline ret cm_ ## name<long> (cholmod_common &Common) { return cholmod_l_ ## name (&Common); }
|
template<> inline ret cm_ ## name<SuiteSparse_long> (cholmod_common &Common) { return cholmod_l_ ## name (&Common); }
|
||||||
|
|
||||||
#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
|
#define EIGEN_CHOLMOD_SPECIALIZE1(ret, name, t1, a1) \
|
||||||
template<typename _StorageIndex> inline ret cm_ ## name (t1& a1, cholmod_common &Common) { return cholmod_ ## name (&a1, &Common); } \
|
template<typename _StorageIndex> inline ret cm_ ## name (t1& a1, cholmod_common &Common) { return cholmod_ ## name (&a1, &Common); } \
|
||||||
template<> inline ret cm_ ## name<long> (t1& a1, cholmod_common &Common) { return cholmod_l_ ## name (&a1, &Common); }
|
template<> inline ret cm_ ## name<SuiteSparse_long> (t1& a1, cholmod_common &Common) { return cholmod_l_ ## name (&a1, &Common); }
|
||||||
|
|
||||||
EIGEN_CHOLMOD_SPECIALIZE0(int, start)
|
EIGEN_CHOLMOD_SPECIALIZE0(int, start)
|
||||||
EIGEN_CHOLMOD_SPECIALIZE0(int, finish)
|
EIGEN_CHOLMOD_SPECIALIZE0(int, finish)
|
||||||
@ -184,15 +184,15 @@ EIGEN_CHOLMOD_SPECIALIZE1(int, free_sparse, cholmod_sparse*, A)
|
|||||||
EIGEN_CHOLMOD_SPECIALIZE1(cholmod_factor*, analyze, cholmod_sparse, A)
|
EIGEN_CHOLMOD_SPECIALIZE1(cholmod_factor*, analyze, cholmod_sparse, A)
|
||||||
|
|
||||||
template<typename _StorageIndex> inline cholmod_dense* cm_solve (int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common &Common) { return cholmod_solve (sys, &L, &B, &Common); }
|
template<typename _StorageIndex> inline cholmod_dense* cm_solve (int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common &Common) { return cholmod_solve (sys, &L, &B, &Common); }
|
||||||
template<> inline cholmod_dense* cm_solve<long> (int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common &Common) { return cholmod_l_solve (sys, &L, &B, &Common); }
|
template<> inline cholmod_dense* cm_solve<SuiteSparse_long> (int sys, cholmod_factor& L, cholmod_dense& B, cholmod_common &Common) { return cholmod_l_solve (sys, &L, &B, &Common); }
|
||||||
|
|
||||||
template<typename _StorageIndex> inline cholmod_sparse* cm_spsolve (int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common &Common) { return cholmod_spsolve (sys, &L, &B, &Common); }
|
template<typename _StorageIndex> inline cholmod_sparse* cm_spsolve (int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common &Common) { return cholmod_spsolve (sys, &L, &B, &Common); }
|
||||||
template<> inline cholmod_sparse* cm_spsolve<long> (int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common &Common) { return cholmod_l_spsolve (sys, &L, &B, &Common); }
|
template<> inline cholmod_sparse* cm_spsolve<SuiteSparse_long> (int sys, cholmod_factor& L, cholmod_sparse& B, cholmod_common &Common) { return cholmod_l_spsolve (sys, &L, &B, &Common); }
|
||||||
|
|
||||||
template<typename _StorageIndex>
|
template<typename _StorageIndex>
|
||||||
inline int cm_factorize_p (cholmod_sparse* A, double beta[2], _StorageIndex* fset, std::size_t fsize, cholmod_factor* L, cholmod_common &Common) { return cholmod_factorize_p (A, beta, fset, fsize, L, &Common); }
|
inline int cm_factorize_p (cholmod_sparse* A, double beta[2], _StorageIndex* fset, std::size_t fsize, cholmod_factor* L, cholmod_common &Common) { return cholmod_factorize_p (A, beta, fset, fsize, L, &Common); }
|
||||||
template<>
|
template<>
|
||||||
inline int cm_factorize_p<long> (cholmod_sparse* A, double beta[2], long* fset, std::size_t fsize, cholmod_factor* L, cholmod_common &Common) { return cholmod_l_factorize_p (A, beta, fset, fsize, L, &Common); }
|
inline int cm_factorize_p<SuiteSparse_long> (cholmod_sparse* A, double beta[2], SuiteSparse_long* fset, std::size_t fsize, cholmod_factor* L, cholmod_common &Common) { return cholmod_l_factorize_p (A, beta, fset, fsize, L, &Common); }
|
||||||
|
|
||||||
#undef EIGEN_CHOLMOD_SPECIALIZE0
|
#undef EIGEN_CHOLMOD_SPECIALIZE0
|
||||||
#undef EIGEN_CHOLMOD_SPECIALIZE1
|
#undef EIGEN_CHOLMOD_SPECIALIZE1
|
||||||
@ -254,10 +254,10 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
internal::cm_free_factor<StorageIndex>(m_cholmodFactor, m_cholmod);
|
internal::cm_free_factor<StorageIndex>(m_cholmodFactor, m_cholmod);
|
||||||
internal::cm_finish<StorageIndex>(m_cholmod);
|
internal::cm_finish<StorageIndex>(m_cholmod);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
|
inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
|
||||||
inline StorageIndex rows() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
|
inline StorageIndex rows() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); }
|
||||||
|
|
||||||
/** \brief Reports whether previous computation was successful.
|
/** \brief Reports whether previous computation was successful.
|
||||||
*
|
*
|
||||||
* \returns \c Success if computation was successful,
|
* \returns \c Success if computation was successful,
|
||||||
@ -276,11 +276,11 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
factorize(matrix);
|
factorize(matrix);
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs a symbolic decomposition on the sparsity pattern of \a matrix.
|
/** Performs a symbolic decomposition on the sparsity pattern of \a matrix.
|
||||||
*
|
*
|
||||||
* This function is particularly useful when solving for several problems having the same structure.
|
* This function is particularly useful when solving for several problems having the same structure.
|
||||||
*
|
*
|
||||||
* \sa factorize()
|
* \sa factorize()
|
||||||
*/
|
*/
|
||||||
void analyzePattern(const MatrixType& matrix)
|
void analyzePattern(const MatrixType& matrix)
|
||||||
@ -292,13 +292,13 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
}
|
}
|
||||||
cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
|
cholmod_sparse A = viewAsCholmod(matrix.template selfadjointView<UpLo>());
|
||||||
m_cholmodFactor = internal::cm_analyze<StorageIndex>(A, m_cholmod);
|
m_cholmodFactor = internal::cm_analyze<StorageIndex>(A, m_cholmod);
|
||||||
|
|
||||||
this->m_isInitialized = true;
|
this->m_isInitialized = true;
|
||||||
this->m_info = Success;
|
this->m_info = Success;
|
||||||
m_analysisIsOk = true;
|
m_analysisIsOk = true;
|
||||||
m_factorizationIsOk = false;
|
m_factorizationIsOk = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Performs a numeric decomposition of \a matrix
|
/** Performs a numeric decomposition of \a matrix
|
||||||
*
|
*
|
||||||
* The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been performed.
|
* The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been performed.
|
||||||
@ -315,11 +315,11 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);
|
this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);
|
||||||
m_factorizationIsOk = true;
|
m_factorizationIsOk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a reference to the Cholmod's configuration structure to get a full control over the performed operations.
|
/** Returns a reference to the Cholmod's configuration structure to get a full control over the performed operations.
|
||||||
* See the Cholmod user guide for details. */
|
* See the Cholmod user guide for details. */
|
||||||
cholmod_common& cholmod() { return m_cholmod; }
|
cholmod_common& cholmod() { return m_cholmod; }
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \internal */
|
/** \internal */
|
||||||
template<typename Rhs,typename Dest>
|
template<typename Rhs,typename Dest>
|
||||||
@ -329,7 +329,7 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
const Index size = m_cholmodFactor->n;
|
const Index size = m_cholmodFactor->n;
|
||||||
EIGEN_UNUSED_VARIABLE(size);
|
EIGEN_UNUSED_VARIABLE(size);
|
||||||
eigen_assert(size==b.rows());
|
eigen_assert(size==b.rows());
|
||||||
|
|
||||||
// Cholmod needs column-major storage without inner-stride, which corresponds to the default behavior of Ref.
|
// Cholmod needs column-major storage without inner-stride, which corresponds to the default behavior of Ref.
|
||||||
Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b.derived());
|
Ref<const Matrix<typename Rhs::Scalar,Dynamic,Dynamic,ColMajor> > b_ref(b.derived());
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
|
dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
|
||||||
internal::cm_free_dense<StorageIndex>(x_cd, m_cholmod);
|
internal::cm_free_dense<StorageIndex>(x_cd, m_cholmod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal */
|
/** \internal */
|
||||||
template<typename RhsDerived, typename DestDerived>
|
template<typename RhsDerived, typename DestDerived>
|
||||||
void _solve_impl(const SparseMatrixBase<RhsDerived> &b, SparseMatrixBase<DestDerived> &dest) const
|
void _solve_impl(const SparseMatrixBase<RhsDerived> &b, SparseMatrixBase<DestDerived> &dest) const
|
||||||
@ -370,8 +370,8 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
internal::cm_free_sparse<StorageIndex>(x_cs, m_cholmod);
|
internal::cm_free_sparse<StorageIndex>(x_cs, m_cholmod);
|
||||||
}
|
}
|
||||||
#endif // EIGEN_PARSED_BY_DOXYGEN
|
#endif // EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
|
|
||||||
/** Sets the shift parameter that will be used to adjust the diagonal coefficients during the numerical factorization.
|
/** Sets the shift parameter that will be used to adjust the diagonal coefficients during the numerical factorization.
|
||||||
*
|
*
|
||||||
* During the numerical factorization, an offset term is added to the diagonal coefficients:\n
|
* During the numerical factorization, an offset term is added to the diagonal coefficients:\n
|
||||||
@ -386,7 +386,7 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
m_shiftOffset[0] = double(offset);
|
m_shiftOffset[0] = double(offset);
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the determinant of the underlying matrix from the current factorization */
|
/** \returns the determinant of the underlying matrix from the current factorization */
|
||||||
Scalar determinant() const
|
Scalar determinant() const
|
||||||
{
|
{
|
||||||
@ -441,7 +441,7 @@ class CholmodBase : public SparseSolverBase<Derived>
|
|||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void dumpMemory(Stream& /*s*/)
|
void dumpMemory(Stream& /*s*/)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable cholmod_common m_cholmod;
|
mutable cholmod_common m_cholmod;
|
||||||
cholmod_factor* m_cholmodFactor;
|
cholmod_factor* m_cholmodFactor;
|
||||||
@ -478,11 +478,11 @@ class CholmodSimplicialLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimpl
|
|||||||
{
|
{
|
||||||
typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT> Base;
|
typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLLT> Base;
|
||||||
using Base::m_cholmod;
|
using Base::m_cholmod;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef _MatrixType MatrixType;
|
typedef _MatrixType MatrixType;
|
||||||
|
|
||||||
CholmodSimplicialLLT() : Base() { init(); }
|
CholmodSimplicialLLT() : Base() { init(); }
|
||||||
|
|
||||||
CholmodSimplicialLLT(const MatrixType& matrix) : Base()
|
CholmodSimplicialLLT(const MatrixType& matrix) : Base()
|
||||||
@ -529,11 +529,11 @@ class CholmodSimplicialLDLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimp
|
|||||||
{
|
{
|
||||||
typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT> Base;
|
typedef CholmodBase<_MatrixType, _UpLo, CholmodSimplicialLDLT> Base;
|
||||||
using Base::m_cholmod;
|
using Base::m_cholmod;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef _MatrixType MatrixType;
|
typedef _MatrixType MatrixType;
|
||||||
|
|
||||||
CholmodSimplicialLDLT() : Base() { init(); }
|
CholmodSimplicialLDLT() : Base() { init(); }
|
||||||
|
|
||||||
CholmodSimplicialLDLT(const MatrixType& matrix) : Base()
|
CholmodSimplicialLDLT(const MatrixType& matrix) : Base()
|
||||||
@ -578,11 +578,11 @@ class CholmodSupernodalLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSuper
|
|||||||
{
|
{
|
||||||
typedef CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT> Base;
|
typedef CholmodBase<_MatrixType, _UpLo, CholmodSupernodalLLT> Base;
|
||||||
using Base::m_cholmod;
|
using Base::m_cholmod;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef _MatrixType MatrixType;
|
typedef _MatrixType MatrixType;
|
||||||
|
|
||||||
CholmodSupernodalLLT() : Base() { init(); }
|
CholmodSupernodalLLT() : Base() { init(); }
|
||||||
|
|
||||||
CholmodSupernodalLLT(const MatrixType& matrix) : Base()
|
CholmodSupernodalLLT(const MatrixType& matrix) : Base()
|
||||||
@ -629,11 +629,11 @@ class CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecom
|
|||||||
{
|
{
|
||||||
typedef CholmodBase<_MatrixType, _UpLo, CholmodDecomposition> Base;
|
typedef CholmodBase<_MatrixType, _UpLo, CholmodDecomposition> Base;
|
||||||
using Base::m_cholmod;
|
using Base::m_cholmod;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef _MatrixType MatrixType;
|
typedef _MatrixType MatrixType;
|
||||||
|
|
||||||
CholmodDecomposition() : Base() { init(); }
|
CholmodDecomposition() : Base() { init(); }
|
||||||
|
|
||||||
CholmodDecomposition(const MatrixType& matrix) : Base()
|
CholmodDecomposition(const MatrixType& matrix) : Base()
|
||||||
@ -643,7 +643,7 @@ class CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecom
|
|||||||
}
|
}
|
||||||
|
|
||||||
~CholmodDecomposition() {}
|
~CholmodDecomposition() {}
|
||||||
|
|
||||||
void setMode(CholmodMode mode)
|
void setMode(CholmodMode mode)
|
||||||
{
|
{
|
||||||
switch(mode)
|
switch(mode)
|
||||||
|
@ -405,7 +405,7 @@ template<typename T> struct plain_matrix_type_row_major
|
|||||||
typedef Matrix<typename traits<T>::Scalar,
|
typedef Matrix<typename traits<T>::Scalar,
|
||||||
Rows,
|
Rows,
|
||||||
Cols,
|
Cols,
|
||||||
(MaxCols==1&&MaxRows!=1) ? RowMajor : ColMajor,
|
(MaxCols==1&&MaxRows!=1) ? ColMajor : RowMajor,
|
||||||
MaxRows,
|
MaxRows,
|
||||||
MaxCols
|
MaxCols
|
||||||
> type;
|
> type;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user