mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Refactoring of sparse solvers through a SparseSolverBase class and usage of the Solve<> expression. Introduce a SolveWithGuess expression on top of Solve.
This commit is contained in:
@@ -125,9 +125,15 @@ namespace internal
|
||||
// This is the base class to interface with PaStiX functions.
|
||||
// Users should not used this class directly.
|
||||
template <class Derived>
|
||||
class PastixBase : internal::noncopyable
|
||||
class PastixBase : public SparseSolverBase<Derived>
|
||||
{
|
||||
protected:
|
||||
typedef SparseSolverBase<Derived> Base;
|
||||
using Base::derived;
|
||||
using Base::m_isInitialized;
|
||||
public:
|
||||
using Base::_solve_impl;
|
||||
|
||||
typedef typename internal::pastix_traits<Derived>::MatrixType _MatrixType;
|
||||
typedef _MatrixType MatrixType;
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
@@ -138,7 +144,7 @@ class PastixBase : internal::noncopyable
|
||||
|
||||
public:
|
||||
|
||||
PastixBase() : m_initisOk(false), m_analysisIsOk(false), m_factorizationIsOk(false), m_isInitialized(false), m_pastixdata(0), m_size(0)
|
||||
PastixBase() : m_initisOk(false), m_analysisIsOk(false), m_factorizationIsOk(false), m_pastixdata(0), m_size(0)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -148,6 +154,7 @@ class PastixBase : internal::noncopyable
|
||||
clean();
|
||||
}
|
||||
|
||||
#ifndef EIGEN_TEST_EVALUATORS
|
||||
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A.
|
||||
*
|
||||
* \sa compute()
|
||||
@@ -161,19 +168,11 @@ class PastixBase : internal::noncopyable
|
||||
&& "PastixBase::solve(): invalid number of rows of the right hand side matrix b");
|
||||
return internal::solve_retval<PastixBase, Rhs>(*this, b.derived());
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Rhs,typename Dest>
|
||||
bool _solve (const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const;
|
||||
bool _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const;
|
||||
|
||||
Derived& derived()
|
||||
{
|
||||
return *static_cast<Derived*>(this);
|
||||
}
|
||||
const Derived& derived() const
|
||||
{
|
||||
return *static_cast<const Derived*>(this);
|
||||
}
|
||||
|
||||
/** Returns a reference to the integer vector IPARM of PaStiX parameters
|
||||
* to modify the default parameters.
|
||||
* The statistics related to the different phases of factorization and solve are saved here as well
|
||||
@@ -228,6 +227,7 @@ class PastixBase : internal::noncopyable
|
||||
return m_info;
|
||||
}
|
||||
|
||||
#ifndef EIGEN_TEST_EVALUATORS
|
||||
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A.
|
||||
*
|
||||
* \sa compute()
|
||||
@@ -241,6 +241,7 @@ class PastixBase : internal::noncopyable
|
||||
&& "PastixBase::solve(): invalid number of rows of the right hand side matrix b");
|
||||
return internal::sparse_solve_retval<PastixBase, Rhs>(*this, b.derived());
|
||||
}
|
||||
#endif // EIGEN_TEST_EVALUATORS
|
||||
|
||||
protected:
|
||||
|
||||
@@ -268,7 +269,6 @@ class PastixBase : internal::noncopyable
|
||||
int m_initisOk;
|
||||
int m_analysisIsOk;
|
||||
int m_factorizationIsOk;
|
||||
bool m_isInitialized;
|
||||
mutable ComputationInfo m_info;
|
||||
mutable pastix_data_t *m_pastixdata; // Data structure for pastix
|
||||
mutable int m_comm; // The MPI communicator identifier
|
||||
@@ -393,7 +393,7 @@ void PastixBase<Derived>::factorize(ColSpMatrix& mat)
|
||||
/* Solve the system */
|
||||
template<typename Base>
|
||||
template<typename Rhs,typename Dest>
|
||||
bool PastixBase<Base>::_solve (const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const
|
||||
bool PastixBase<Base>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &x) const
|
||||
{
|
||||
eigen_assert(m_isInitialized && "The matrix should be factorized first");
|
||||
EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,
|
||||
@@ -694,6 +694,7 @@ class PastixLDLT : public PastixBase< PastixLDLT<_MatrixType, _UpLo> >
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef EIGEN_TEST_EVALUATORS
|
||||
namespace internal {
|
||||
|
||||
template<typename _MatrixType, typename Rhs>
|
||||
@@ -705,7 +706,7 @@ struct solve_retval<PastixBase<_MatrixType>, Rhs>
|
||||
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
dec()._solve(rhs(),dst);
|
||||
dec()._solve_impl(rhs(),dst);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -723,6 +724,7 @@ struct sparse_solve_retval<PastixBase<_MatrixType>, Rhs>
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
#endif // EIGEN_TEST_EVALUATORS
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
|
||||
Reference in New Issue
Block a user