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>
44 typedef typename _MatrixType::Scalar
Scalar;
49 template<
typename _MatrixType,
int Options>
53 typedef typename _MatrixType::Scalar
Scalar;
58 template<
typename _MatrixType,
int Options>
62 typedef typename _MatrixType::Scalar
Scalar;
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)
69 if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
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)
76 if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
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)
83 if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
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)
90 if (n == 0) { ptr = NULL; idx = NULL; vals = NULL; }
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>
139 typedef typename MatrixType::Scalar
Scalar;
161 template<
typename Rhs,
typename Dest>
233 m_iparm(IPARM_START_TASK) = API_TASK_CLEAN;
234 m_iparm(IPARM_END_TASK) = API_TASK_CLEAN;
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>
472 m_iparm(IPARM_SYM) = API_SYM_NO;
473 m_iparm(IPARM_FACTORIZATION) = API_FACT_LU;
523 template<
typename _MatrixType,
int _UpLo>
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>
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>();
#define eigen_assert(x)
Definition: Macros.h:1037
#define PASTIX_DCOMPLEX
Definition: PaStiXSupport.h:20
#define PASTIX_COMPLEX
Definition: PaStiXSupport.h:19
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:127
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:47
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
Definition: PaStiXSupport.h:129
Index rows() const
Definition: PaStiXSupport.h:202
Array< double, DPARM_SIZE, 1 > m_dparm
Definition: PaStiXSupport.h:248
void analyzePattern(ColSpMatrix &mat)
Definition: PaStiXSupport.h:307
int m_factorizationIsOk
Definition: PaStiXSupport.h:243
Matrix< StorageIndex, Dynamic, 1 > m_invp
Definition: PaStiXSupport.h:250
MatrixType::StorageIndex StorageIndex
Definition: PaStiXSupport.h:141
internal::pastix_traits< Derived >::MatrixType _MatrixType
Definition: PaStiXSupport.h:137
Array< StorageIndex, IPARM_SIZE, 1 > & iparm()
Definition: PaStiXSupport.h:169
Matrix< StorageIndex, Dynamic, 1 > m_perm
Definition: PaStiXSupport.h:249
MatrixType::RealScalar RealScalar
Definition: PaStiXSupport.h:140
void compute(ColSpMatrix &mat)
Definition: PaStiXSupport.h:295
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: PaStiXSupport.h:212
PastixBase()
Definition: PaStiXSupport.h:151
int & iparm(int idxparam)
Definition: PaStiXSupport.h:178
Array< int, IPARM_SIZE, 1 > m_iparm
Definition: PaStiXSupport.h:247
bool _solve_impl(const MatrixBase< Rhs > &b, MatrixBase< Dest > &x) const
Definition: PaStiXSupport.h:367
Index cols() const
Definition: PaStiXSupport.h:201
_MatrixType MatrixType
Definition: PaStiXSupport.h:138
double & dparm(int idxparam)
Definition: PaStiXSupport.h:196
int m_analysisIsOk
Definition: PaStiXSupport.h:242
MatrixType::Scalar Scalar
Definition: PaStiXSupport.h:139
Matrix< Scalar, Dynamic, 1 > Vector
Definition: PaStiXSupport.h:142
int m_initisOk
Definition: PaStiXSupport.h:241
void clean()
Definition: PaStiXSupport.h:230
int m_size
Definition: PaStiXSupport.h:251
~PastixBase()
Definition: PaStiXSupport.h:156
bool m_isInitialized
Definition: SparseSolverBase.h:119
void init()
Definition: PaStiXSupport.h:259
void factorize(ColSpMatrix &mat)
Definition: PaStiXSupport.h:338
pastix_data_t * m_pastixdata
Definition: PaStiXSupport.h:245
ComputationInfo m_info
Definition: PaStiXSupport.h:244
@ ColsAtCompileTime
Definition: PaStiXSupport.h:145
@ MaxColsAtCompileTime
Definition: PaStiXSupport.h:146
SparseMatrix< Scalar, ColMajor > ColSpMatrix
Definition: PaStiXSupport.h:143
int m_comm
Definition: PaStiXSupport.h:246
Array< double, DPARM_SIZE, 1 > & dparm()
Definition: PaStiXSupport.h:187
SparseSolverBase< Derived > Base
Definition: PaStiXSupport.h:131
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:609
void analyzePattern(const MatrixType &matrix)
Definition: PaStiXSupport.h:642
@ UpLo
Definition: PaStiXSupport.h:616
void factorize(const MatrixType &matrix)
Definition: PaStiXSupport.h:651
Base::ColSpMatrix ColSpMatrix
Definition: PaStiXSupport.h:613
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
Definition: PaStiXSupport.h:667
Array< int, IPARM_SIZE, 1 > m_iparm
Definition: PaStiXSupport.h:247
PastixBase< PastixLDLT< MatrixType, _UpLo > > Base
Definition: PaStiXSupport.h:612
PastixLDLT(const MatrixType &matrix)
Definition: PaStiXSupport.h:622
PastixLDLT()
Definition: PaStiXSupport.h:617
void compute(const MatrixType &matrix)
Definition: PaStiXSupport.h:631
void init()
Definition: PaStiXSupport.h:661
_MatrixType MatrixType
Definition: PaStiXSupport.h:611
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:525
PastixLLT()
Definition: PaStiXSupport.h:533
void init()
Definition: PaStiXSupport.h:576
void compute(const MatrixType &matrix)
Definition: PaStiXSupport.h:547
Array< int, IPARM_SIZE, 1 > m_iparm
Definition: PaStiXSupport.h:247
void factorize(const MatrixType &matrix)
Definition: PaStiXSupport.h:567
void analyzePattern(const MatrixType &matrix)
Definition: PaStiXSupport.h:558
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
Definition: PaStiXSupport.h:582
_MatrixType MatrixType
Definition: PaStiXSupport.h:527
@ UpLo
Definition: PaStiXSupport.h:532
Base::ColSpMatrix ColSpMatrix
Definition: PaStiXSupport.h:529
PastixLLT(const MatrixType &matrix)
Definition: PaStiXSupport.h:538
PastixBase< PastixLLT< MatrixType, _UpLo > > Base
Definition: PaStiXSupport.h:528
Interface to the PaStix solver.
Definition: PaStiXSupport.h:413
PastixLU()
Definition: PaStiXSupport.h:421
void grabMatrix(const MatrixType &matrix, ColSpMatrix &out)
Definition: PaStiXSupport.h:476
MatrixType::StorageIndex StorageIndex
Definition: PaStiXSupport.h:418
_MatrixType MatrixType
Definition: PaStiXSupport.h:415
Array< int, IPARM_SIZE, 1 > m_iparm
Definition: PaStiXSupport.h:247
PastixLU(const MatrixType &matrix)
Definition: PaStiXSupport.h:426
Base::ColSpMatrix ColSpMatrix
Definition: PaStiXSupport.h:417
void analyzePattern(const MatrixType &matrix)
Definition: PaStiXSupport.h:448
void factorize(const MatrixType &matrix)
Definition: PaStiXSupport.h:461
PastixBase< PastixLU< MatrixType > > Base
Definition: PaStiXSupport.h:416
ColSpMatrix m_transposedStructure
Definition: PaStiXSupport.h:503
bool m_structureIsUptodate
Definition: PaStiXSupport.h:504
void compute(const MatrixType &matrix)
Definition: PaStiXSupport.h:436
void init()
Definition: PaStiXSupport.h:469
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:247
Definition: SparseCompressedBase.h:159
TransposeReturnType transpose()
Definition: SparseMatrixBase.h:354
A versatible sparse matrix representation.
Definition: SparseMatrix.h:98
Index outerSize() const
Definition: SparseMatrix.h:145
Index rows() const
Definition: SparseMatrix.h:138
const StorageIndex * outerIndexPtr() const
Definition: SparseMatrix.h:168
const Scalar * valuePtr() const
Definition: SparseMatrix.h:150
Index cols() const
Definition: SparseMatrix.h:140
const StorageIndex * innerIndexPtr() const
Definition: SparseMatrix.h:159
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:626
A base class for sparse solvers.
Definition: SparseSolverBase.h:68
void _solve_impl(const SparseMatrixBase< Rhs > &b, SparseMatrixBase< Dest > &dest) const
Definition: SparseSolverBase.h:111
bool m_isInitialized
Definition: SparseSolverBase.h:119
Derived & derived()
Definition: SparseSolverBase.h:79
ComputationInfo
Definition: Constants.h:440
@ NumericalIssue
Definition: Constants.h:444
@ InvalidInput
Definition: Constants.h:449
@ Success
Definition: Constants.h:442
const unsigned int RowMajorBit
Definition: Constants.h:66
void fortran_to_c_numbering(MatrixType &mat)
Definition: PaStiXSupport.h:111
void c_to_fortran_numbering(MatrixType &mat)
Definition: PaStiXSupport.h:97
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)
Definition: PaStiXSupport.h:67
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Flags
Special flags for archives.
Definition: cereal.hpp:185
Definition: document.h:416
_MatrixType::RealScalar RealScalar
Definition: PaStiXSupport.h:63
_MatrixType::Scalar Scalar
Definition: PaStiXSupport.h:62
_MatrixType::StorageIndex StorageIndex
Definition: PaStiXSupport.h:64
_MatrixType MatrixType
Definition: PaStiXSupport.h:61
_MatrixType::StorageIndex StorageIndex
Definition: PaStiXSupport.h:55
_MatrixType::RealScalar RealScalar
Definition: PaStiXSupport.h:54
_MatrixType MatrixType
Definition: PaStiXSupport.h:52
_MatrixType::Scalar Scalar
Definition: PaStiXSupport.h:53
_MatrixType::StorageIndex StorageIndex
Definition: PaStiXSupport.h:46
_MatrixType::Scalar Scalar
Definition: PaStiXSupport.h:44
_MatrixType::RealScalar RealScalar
Definition: PaStiXSupport.h:45
_MatrixType MatrixType
Definition: PaStiXSupport.h:43
Definition: PaStiXSupport.h:38