10 #ifndef EIGEN_PASTIXSUPPORT_H 11 #define EIGEN_PASTIXSUPPORT_H 16 #define PASTIX_COMPLEX COMPLEX 17 #define PASTIX_DCOMPLEX DCOMPLEX 19 #define PASTIX_COMPLEX std::complex<float> 20 #define PASTIX_DCOMPLEX std::complex<double> 31 template<
typename _MatrixType,
bool IsStrSym = false>
class PastixLU;
32 template<
typename _MatrixType,
int Options>
class PastixLLT;
33 template<
typename _MatrixType,
int Options>
class PastixLDLT;
40 template<
typename _MatrixType>
49 template<
typename _MatrixType,
int Options>
58 template<
typename _MatrixType,
int Options>
67 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *
ptr,
int *idx,
float *vals,
int *
perm,
int * invp,
float *
x,
int nbrhs,
int *iparm,
double *dparm)
70 if (nbrhs == 0) {x =
NULL; nbrhs=1;}
71 s_pastix(pastix_data, pastix_comm, n, ptr, idx, vals, perm, invp, x, nbrhs, iparm, dparm);
74 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *
ptr,
int *idx,
double *vals,
int *
perm,
int * invp,
double *
x,
int nbrhs,
int *iparm,
double *dparm)
77 if (nbrhs == 0) {x =
NULL; nbrhs=1;}
78 d_pastix(pastix_data, pastix_comm, n, ptr, idx, vals, perm, invp, x, nbrhs, iparm, dparm);
81 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *
ptr,
int *idx, std::complex<float> *vals,
int *
perm,
int * invp, std::complex<float> *
x,
int nbrhs,
int *iparm,
double *dparm)
84 if (nbrhs == 0) {x =
NULL; nbrhs=1;}
85 c_pastix(pastix_data, pastix_comm, n, ptr, idx, reinterpret_cast<PASTIX_COMPLEX*>(vals), perm, invp, reinterpret_cast<PASTIX_COMPLEX*>(x), nbrhs, iparm, dparm);
88 inline void eigen_pastix(pastix_data_t **pastix_data,
int pastix_comm,
int n,
int *
ptr,
int *idx, std::complex<double> *vals,
int *
perm,
int * invp, std::complex<double> *
x,
int nbrhs,
int *iparm,
double *dparm)
91 if (nbrhs == 0) {x =
NULL; nbrhs=1;}
92 z_pastix(pastix_data, pastix_comm, n, ptr, idx, reinterpret_cast<PASTIX_DCOMPLEX*>(vals), perm, invp, reinterpret_cast<PASTIX_DCOMPLEX*>(x), nbrhs, iparm, dparm);
96 template <
typename MatrixType>
99 if ( !(mat.outerIndexPtr()[0]) )
102 for(i = 0; i <= mat.rows(); ++
i)
103 ++mat.outerIndexPtr()[
i];
104 for(i = 0; i < mat.nonZeros(); ++
i)
105 ++mat.innerIndexPtr()[
i];
110 template <
typename MatrixType>
114 if ( mat.outerIndexPtr()[0] == 1 )
117 for(i = 0; i <= mat.rows(); ++
i)
118 --mat.outerIndexPtr()[
i];
119 for(i = 0; i < mat.nonZeros(); ++
i)
120 --mat.innerIndexPtr()[
i];
127 template <
class Derived>
133 using Base::m_isInitialized;
135 using Base::_solve_impl;
145 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
146 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
151 PastixBase() : m_initisOk(false), m_analysisIsOk(false), m_factorizationIsOk(false), m_pastixdata(0), m_size(0)
161 template<
typename Rhs,
typename Dest>
180 return m_iparm(idxparam);
198 return m_dparm(idxparam);
214 eigen_assert(m_isInitialized &&
"Decomposition is not initialized.");
224 void analyzePattern(ColSpMatrix&
mat);
227 void factorize(ColSpMatrix& mat);
232 eigen_assert(m_initisOk &&
"The Pastix structure should be allocated first");
233 m_iparm(IPARM_START_TASK) = API_TASK_CLEAN;
234 m_iparm(IPARM_END_TASK) = API_TASK_CLEAN;
236 m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
239 void compute(ColSpMatrix& mat);
258 template <
class Derived>
262 m_iparm.setZero(IPARM_SIZE);
263 m_dparm.setZero(DPARM_SIZE);
265 m_iparm(IPARM_MODIFY_PARAMETER) = API_NO;
266 pastix(&m_pastixdata, MPI_COMM_WORLD,
268 0, 0, 0, 1, m_iparm.data(), m_dparm.data());
270 m_iparm[IPARM_MATRIX_VERIFICATION] = API_NO;
271 m_iparm[IPARM_VERBOSE] = API_VERBOSE_NOT;
272 m_iparm[IPARM_ORDERING] = API_ORDER_SCOTCH;
273 m_iparm[IPARM_INCOMPLETE] = API_NO;
274 m_iparm[IPARM_OOC_LIMIT] = 2000;
275 m_iparm[IPARM_RHS_MAKING] = API_RHS_B;
276 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
278 m_iparm(IPARM_START_TASK) = API_TASK_INIT;
279 m_iparm(IPARM_END_TASK) = API_TASK_INIT;
281 0, 0, 0, 0, m_iparm.data(), m_dparm.data());
284 if(m_iparm(IPARM_ERROR_NUMBER)) {
294 template <
class Derived>
302 m_iparm(IPARM_MATRIX_VERIFICATION) = API_NO;
306 template <
class Derived>
309 eigen_assert(m_initisOk &&
"The initialization of PaSTiX failed");
315 m_size = internal::convert_index<int>(mat.
rows());
316 m_perm.resize(m_size);
317 m_invp.resize(m_size);
319 m_iparm(IPARM_START_TASK) = API_TASK_ORDERING;
320 m_iparm(IPARM_END_TASK) = API_TASK_ANALYSE;
322 mat.
valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
325 if(m_iparm(IPARM_ERROR_NUMBER))
328 m_analysisIsOk =
false;
333 m_analysisIsOk =
true;
337 template <
class Derived>
341 eigen_assert(m_analysisIsOk &&
"The analysis phase should be called before the factorization phase");
342 m_iparm(IPARM_START_TASK) = API_TASK_NUMFACT;
343 m_iparm(IPARM_END_TASK) = API_TASK_NUMFACT;
344 m_size = internal::convert_index<int>(mat.
rows());
347 mat.
valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data());
350 if(m_iparm(IPARM_ERROR_NUMBER))
353 m_factorizationIsOk =
false;
354 m_isInitialized =
false;
359 m_factorizationIsOk =
true;
360 m_isInitialized =
true;
365 template<
typename Base>
366 template<
typename Rhs,
typename Dest>
369 eigen_assert(m_isInitialized &&
"The matrix should be factorized first");
371 THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
376 for (
int i = 0;
i < b.cols();
i++){
377 m_iparm[IPARM_START_TASK] = API_TASK_SOLVE;
378 m_iparm[IPARM_END_TASK] = API_TASK_REFINE;
381 m_perm.data(), m_invp.data(), &
x(0,
i), rhs, m_iparm.data(), m_dparm.data());
387 return m_iparm(IPARM_ERROR_NUMBER)==0;
411 template<
typename _MatrixType,
bool IsStrSym>
438 m_structureIsUptodate =
false;
440 grabMatrix(matrix, temp);
450 m_structureIsUptodate =
false;
452 grabMatrix(matrix, temp);
453 Base::analyzePattern(temp);
464 grabMatrix(matrix, temp);
465 Base::factorize(temp);
471 m_structureIsUptodate =
false;
472 m_iparm(IPARM_SYM) = API_SYM_NO;
473 m_iparm(IPARM_FACTORIZATION) = API_FACT_LU;
482 if(!m_structureIsUptodate)
485 m_transposedStructure = matrix.transpose();
488 for (
Index j=0;
j<m_transposedStructure.outerSize(); ++
j)
492 m_structureIsUptodate =
true;
495 out = m_transposedStructure +
matrix;
523 template<
typename _MatrixType,
int _UpLo>
532 enum { UpLo = _UpLo };
550 grabMatrix(matrix, temp);
561 grabMatrix(matrix, temp);
562 Base::analyzePattern(temp);
570 grabMatrix(matrix, temp);
571 Base::factorize(temp);
578 m_iparm(IPARM_SYM) = API_SYM_YES;
579 m_iparm(IPARM_FACTORIZATION) = API_FACT_LLT;
584 out.
resize(matrix.rows(), matrix.cols());
586 out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();
607 template<
typename _MatrixType,
int _UpLo>
616 enum { UpLo = _UpLo };
634 grabMatrix(matrix, temp);
645 grabMatrix(matrix, temp);
646 Base::analyzePattern(temp);
654 grabMatrix(matrix, temp);
655 Base::factorize(temp);
663 m_iparm(IPARM_SYM) = API_SYM_YES;
664 m_iparm(IPARM_FACTORIZATION) = API_FACT_LDLT;
670 out.
resize(matrix.rows(), matrix.cols());
671 out.template selfadjointView<Lower>() = matrix.template selfadjointView<UpLo>();
SparseMatrix< Scalar, ColMajor > ColSpMatrix
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
bool _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &x) const
Array< int, IPARM_SIZE, 1 > m_iparm
_MatrixType::RealScalar RealScalar
void analyzePattern(ColSpMatrix &mat)
PastixLU(const MatrixType &matrix)
void compute(const MatrixType &matrix)
_MatrixType::StorageIndex StorageIndex
Base::ColSpMatrix ColSpMatrix
PastixLDLT(const MatrixType &matrix)
void resize(Index rows, Index cols)
A base class for sparse solvers.
void factorize(const MatrixType &matrix)
Namespace containing all symbols from the Eigen library.
PastixLLT(const MatrixType &matrix)
void factorize(const MatrixType &matrix)
MatrixType::RealScalar RealScalar
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
void compute(const MatrixType &matrix)
pastix_data_t * m_pastixdata
Matrix< StorageIndex, Dynamic, 1 > m_perm
const Scalar * valuePtr() const
const unsigned int RowMajorBit
void compute(const MatrixType &matrix)
Array< double, DPARM_SIZE, 1 > m_dparm
double & dparm(int idxparam)
void fortran_to_c_numbering(MatrixType &mat)
SparseSolverBase< Derived > Base
void compute(ColSpMatrix &mat)
_MatrixType::Scalar Scalar
void analyzePattern(const MatrixType &matrix)
Matrix< Scalar, Dynamic, 1 > Vector
_MatrixType::StorageIndex StorageIndex
_MatrixType::RealScalar RealScalar
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library...
MatrixType::StorageIndex StorageIndex
PastixBase< PastixLLT< MatrixType, _UpLo > > Base
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
bool m_structureIsUptodate
Matrix< StorageIndex, Dynamic, 1 > m_invp
Base::InnerIterator InnerIterator
idx_t idx_t idx_t idx_t idx_t * perm
_MatrixType::RealScalar RealScalar
PastixBase< PastixLU< MatrixType > > Base
int & iparm(int idxparam)
_MatrixType::StorageIndex StorageIndex
_MatrixType::Scalar Scalar
_MatrixType::Scalar Scalar
NumTraits< Scalar >::Real RealScalar
Array< double, DPARM_SIZE, 1 > & dparm()
void c_to_fortran_numbering(MatrixType &mat)
const StorageIndex * outerIndexPtr() const
void analyzePattern(const MatrixType &matrix)
void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, float *vals, int *perm, int *invp, float *x, int nbrhs, int *iparm, double *dparm)
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
MatrixType::StorageIndex StorageIndex
Base::ColSpMatrix ColSpMatrix
Base::ColSpMatrix ColSpMatrix
void factorize(ColSpMatrix &mat)
void factorize(const MatrixType &matrix)
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
General-purpose arrays with easy API for coefficient-wise operations.
Interface to the PaStix solver.
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library...
ComputationInfo info() const
Reports whether previous computation was successful.
ColSpMatrix m_transposedStructure
Array< StorageIndex, IPARM_SIZE, 1 > & iparm()
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
const StorageIndex * innerIndexPtr() const
EIGEN_DONT_INLINE void compute(Solver &solver, const MatrixType &A)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
internal::pastix_traits< Derived >::MatrixType _MatrixType
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
void analyzePattern(const MatrixType &matrix)
Base class for all dense matrices, vectors, and expressions.
PastixBase< PastixLDLT< MatrixType, _UpLo > > Base
MatrixType::Scalar Scalar