23#define ICNTL(I) icntl[(I)-1]
26#define USE_COMM_WORLD -987654
39template <
class Scalar>
45 void printMatrixInfo()
49 const char *s =
"UNKNOWN";
54 std::cout <<
"MUMPS" <<
" solver, n=" << n <<
", nnz=" << N <<
", matrix is " << s << std::endl;
70 std::vector<MUMPS_INT>& ridx,
71 std::vector<MUMPS_INT>& cidx,
72 std::vector<Scalar>& values,
76 assert(cidx.size()==N && values.size()==N);
85 for (MUMPS_INT i=0; i<N; ++i)
86 if (cidx[i] > ridx[i])
97 mumps_par.ICNTL(3) = 0;
98 callMumps(&mumps_par);
125 callMumps(&mumps_par);
127 mumps_par.ICNTL(3) = 0;
128 mumps_par.ICNTL(14) += 5;
138 for (
int k=0; k<N; k++)
146 && this->options.mumps.inertia)
148 mumps_par.ICNTL(24) = 1;
151 callMumps(&mumps_par);
152 if (mumps_par.info[0] < 0)
161 callMumps(&mumps_par);
162 if (mumps_par.info[0] < 0)
165 switch(mumps_par.info[0])
169 size_t entries = mumps_par.info[1]<0? -1000000*mumps_par.info[1]: mumps_par.info[1];
170 errmsg =
"\nAllocation of " + std::to_string(entries) +
" scalar entries (" + std::to_string(entries*
sizeof(Scalar)/1024/1024) +
"MB) failed.";
176 throw DirectSolverException(
"MUMPS factorization failed with error " + std::to_string(mumps_par.info[0])+errmsg,__FILE__,__LINE__);
180 && this->options.mumps.inertia) {
191 void solve(std::vector<Scalar>
const& b, std::vector<Scalar>& x,
bool transpose=
false)
const
211 void solve(std::vector<Scalar>& b)
const
221 callMumps(&mumps_par);
222 if (mumps_par.info[0] < 0)
235 void callMumps(SMUMPS_STRUC_C* mumpsPar)
const
240 void callMumps(DMUMPS_STRUC_C* mumpsPar)
const
247 using MumpsStruct = std::conditional_t<std::is_same<Scalar, float>::value, SMUMPS_STRUC_C, DMUMPS_STRUC_C>;
248 mutable MumpsStruct mumps_par;
To be raised if a direct solver fails.
Abstract base class for matrix factorizations.
Factorization of sparse linear systems with mumps.
void solve(std::vector< Scalar > const &b, std::vector< Scalar > &x, bool transpose=false) const
Solves the system for the given right hand side.
void solve(Scalar const *b, Scalar *x, bool transpose=false) const
Solves the system for the given right hand side .
void solve(std::vector< Scalar > &b) const
Solves the system for the given right hand side.
size_t size() const
reports the dimension of the system
MUMPSFactorization(MUMPS_INT n_, std::vector< MUMPS_INT > &ridx, std::vector< MUMPS_INT > &cidx, std::vector< Scalar > &values, typename Base::Options options)
Constructor taking input data in triplet format (aka coordinate format).
void solve(Scalar *b) const
Solves the system for the given right hand side .
void analyze(MUMPS_INT *irn, MUMPS_INT *jcn)
void factorize(Scalar *a)
int zeroPivots
number of zero eigenvalues (if inertia detection for symmetric matrix was enabled)
int negativePivots
number of negative eigenvalues (if inertia detection for symmetric matrix was enabled)
struct Kaskade::Factorization::Info::Mumps mumps
double zeroPivotThreshold
Threshold that defines which pivots will be considered as zero. See CNTL(3) in MUMPS documentation.
The Options struct allows to specify several options of factorization.
MatrixProperties matrixProperty
We can specify the properties of the matrix, which might be taken into account for selecing an orderi...
struct Kaskade::FactorizationOptions::Mumps mumps
int verbosity
How detailed information should be reported.