8#ifndef OPENFPM_NUMERICS_SRC_SOLVERS_UMFPACK_SOLVER_HPP_
9#define OPENFPM_NUMERICS_SRC_SOLVERS_UMFPACK_SOLVER_HPP_
13#define SOLVER_NOOPTION 0
14#define SOLVER_PRINT_RESIDUAL_NORM_INFINITY 1
15#define SOLVER_PRINT_DETERMINANT 2
19#if defined(HAVE_EIGEN) && defined(HAVE_SUITESPARSE)
23#include "Vector/Vector.hpp"
24#include "Eigen/UmfPackSupport"
25#include <Eigen/SparseLU>
35 std::cerr <<
"Error Umfpack only support double precision, and int ad id type" <<
"/n";
40 std::cerr <<
"Error Umfpack only support double precision, and int ad id type" <<
"/n";
49 Eigen::UmfPackLU<Eigen::SparseMatrix<double,0,int> > solver;
51 Eigen::SparseMatrix<double,0,int> mat_ei;
66 return solve(A,b,opt);
87 Eigen::Matrix<double, Eigen::Dynamic, 1> x_ei;
90 auto b_ei = b.getVec();
97 solver.compute(mat_ei);
99 if(solver.info()!=Eigen::Success)
102 std::cout << __FILE__ <<
":" << __LINE__ <<
" solver failed" <<
"\n";
109 x_ei = solver.solve(b_ei);
113 Eigen::Matrix<double, Eigen::Dynamic, 1> res;
114 res = mat_ei * x_ei - b_ei;
116 std::cout <<
"Infinity norm: " << res.lpNorm<Eigen::Infinity>() <<
"\n";
119 if (opt & SOLVER_PRINT_DETERMINANT)
121 std::cout <<
" Determinant: " << solver.determinant() <<
"\n";
123 if (opt & SOLVER_PRINT)
125 std::cout << mat_ei <<
"\n";
126 std::cout << b_ei <<
"\n";
153 Eigen::Matrix<double, Eigen::Dynamic, 1> x_ei;
156 auto b_ei = b.getVec();
163 x_ei = solver.solve(b_ei);
165 if (opt & SOLVER_PRINT_RESIDUAL_NORM_INFINITY)
167 std::cout <<
"umfpack_solver: unsupported you have to pass the matrix for the option SOLVER_PRINT_RESIDUAL_NORM_INFINITY " <<
"\n";
170 if (opt & SOLVER_PRINT_DETERMINANT)
172 std::cout <<
" Determinant: " << solver.determinant() <<
"\n";
189#include "Vector/Vector.hpp"
200 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error Umfpack only support double precision" <<
"/n";
206 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error Umfpack only support double precision" <<
"/n";
212 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error Umfpack only support double precision" <<
"/n";
226 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error in order to use umfpack you must compile OpenFPM with linear algebra support" <<
"/n";
236 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error in order to use umfpack you must compile OpenFPM with linear algebra support" <<
"/n";
242 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error in order to use umfpack you must compile OpenFPM with linear algebra support" <<
"/n";
Sparse Matrix implementation.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support.
static Vector< double > solve(SparseMatrix< double, id_type, impl > &A, const Vector< double > &b, size_t opt=UMFPACK_NONE)
stub solve
void best_solve()
stub solve
static Vector< double, EIGEN_BASE > try_solve(SparseMatrix< double, int, EIGEN_BASE > &A, const Vector< double, EIGEN_BASE > &b, size_t opt=UMFPACK_NONE)
stub solve
stub when library compiled without eigen
static Vector< T > solve(const SparseMatrix< T, id_type, impl > &A, const Vector< T, impl > &b)
stub solve
void best_solve()
stub solve
static Vector< T, impl > try_solve(SparseMatrix< T, id_type, impl > &A, const Vector< T, impl > &b, size_t opt=UMFPACK_NONE)
stub solve