8 #ifndef OPENFPM_NUMERICS_SRC_SOLVERS_UMFPACK_SOLVER_HPP_
9 #define OPENFPM_NUMERICS_SRC_SOLVERS_UMFPACK_SOLVER_HPP_
11 #define UMFPACK_NONE 0
13 #define SOLVER_NOOPTION 0
14 #define SOLVER_PRINT_RESIDUAL_NORM_INFINITY 1
15 #define SOLVER_PRINT_DETERMINANT 2
17 #if defined(HAVE_EIGEN) && defined(HAVE_SUITESPARSE)
21 #include "Vector/Vector.hpp"
22 #include "Eigen/UmfPackSupport"
23 #include <Eigen/SparseLU>
33 std::cerr <<
"Error Umfpack only support double precision, and int ad id type" <<
"/n";
38 std::cerr <<
"Error Umfpack only support double precision, and int ad id type" <<
"/n";
60 return solve(A,b,opt);
79 Eigen::UmfPackLU<Eigen::SparseMatrix<double,0,int> > solver;
82 auto mat_ei = A.getMat();
84 Eigen::Matrix<double, Eigen::Dynamic, 1> x_ei;
94 solver.compute(mat_ei);
96 if(solver.info()!=Eigen::Success)
99 std::cout << __FILE__ <<
":" << __LINE__ <<
" solver failed" <<
"\n";
106 x_ei = solver.solve(b_ei);
108 if (opt & SOLVER_PRINT_RESIDUAL_NORM_INFINITY)
110 Eigen::Matrix<double, Eigen::Dynamic, 1> res;
111 res = mat_ei * x_ei - b_ei;
113 std::cout <<
"Infinity norm: " << res.lpNorm<Eigen::Infinity>() <<
"\n";
116 if (opt & SOLVER_PRINT_DETERMINANT)
118 std::cout <<
" Determinant: " << solver.determinant() <<
"\n";
135 #include "Vector/Vector.hpp"
146 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error Umfpack only support double precision" <<
"/n";
152 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error Umfpack only support double precision" <<
"/n";
166 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error in order to use umfpack you must compile OpenFPM with linear algebra support" <<
"/n";
176 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error in order to use umfpack you must compile OpenFPM with linear algebra support" <<
"/n";
size_t getProcessUnitID()
Get the process unit id.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support...
static Vector< T > solve(const SparseMatrix< T, impl > &A, const Vector< T > &b)
stub solve
Implementation of VCluster class.
int & getVec()
stub getVec
Sparse Matrix implementation.
static Vector< double > solve(SparseMatrix< double, id_type, impl > &A, const Vector< double > &b, size_t opt=UMFPACK_NONE)
stub solve
stub when library compiled without eigen
void best_solve()
stub solve
void best_solve()
stub solve