13 #include <Eigen/SparseCore> 17 #include <Eigen/Cholesky> 18 #include <Eigen/Jacobi> 19 #include <Eigen/Householder> 20 #include <Eigen/IterativeLinearSolvers> 21 #include <unsupported/Eigen/IterativeSolvers> 23 #include <unsupported/Eigen/SparseExtra> 24 #include <Eigen/SparseLU> 28 #ifdef EIGEN_METIS_SUPPORT 29 #include <Eigen/MetisSupport> 32 #ifdef EIGEN_CHOLMOD_SUPPORT 33 #include <Eigen/CholmodSupport> 36 #ifdef EIGEN_UMFPACK_SUPPORT 37 #include <Eigen/UmfPackSupport> 40 #ifdef EIGEN_PARDISO_SUPPORT 41 #include <Eigen/PardisoSupport> 44 #ifdef EIGEN_SUPERLU_SUPPORT 45 #include <Eigen/SuperLUSupport> 48 #ifdef EIGEN_PASTIX_SUPPORT 49 #include <Eigen/PaStiXSupport> 53 #define EIGEN_UMFPACK 10 54 #define EIGEN_SUPERLU 20 55 #define EIGEN_PASTIX 30 56 #define EIGEN_PARDISO 40 57 #define EIGEN_SPARSELU_COLAMD 50 58 #define EIGEN_SPARSELU_METIS 51 59 #define EIGEN_BICGSTAB 60 60 #define EIGEN_BICGSTAB_ILUT 61 61 #define EIGEN_GMRES 70 62 #define EIGEN_GMRES_ILUT 71 63 #define EIGEN_SIMPLICIAL_LDLT 80 64 #define EIGEN_CHOLMOD_LDLT 90 65 #define EIGEN_PASTIX_LDLT 100 66 #define EIGEN_PARDISO_LDLT 110 67 #define EIGEN_SIMPLICIAL_LLT 120 68 #define EIGEN_CHOLMOD_SUPERNODAL_LLT 130 69 #define EIGEN_CHOLMOD_SIMPLICIAL_LLT 140 70 #define EIGEN_PASTIX_LLT 150 71 #define EIGEN_PARDISO_LLT 160 73 #define EIGEN_CG_PRECOND 180 75 using namespace Eigen;
96 out <<
"<?xml version='1.0' encoding='UTF-8'?> \n";
97 out <<
"<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
98 out <<
"<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
99 out <<
"\n\n<!-- Generated by the Eigen library -->\n";
101 out <<
"\n<BENCH> \n" ;
105 out <<
" <AVAILSOLVER> \n";
106 #ifdef EIGEN_UMFPACK_SUPPORT 108 out <<
" <TYPE> LU </TYPE> \n";
109 out <<
" <PACKAGE> UMFPACK </PACKAGE> \n";
110 out <<
" </SOLVER> \n";
112 #ifdef EIGEN_SUPERLU_SUPPORT 114 out <<
" <TYPE> LU </TYPE> \n";
115 out <<
" <PACKAGE> SUPERLU </PACKAGE> \n";
116 out <<
" </SOLVER> \n";
118 #ifdef EIGEN_CHOLMOD_SUPPORT 120 out <<
" <TYPE> LLT SP</TYPE> \n";
121 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
122 out <<
" </SOLVER> \n";
125 out <<
" <TYPE> LLT</TYPE> \n";
126 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
127 out <<
" </SOLVER> \n";
130 out <<
" <TYPE> LDLT </TYPE> \n";
131 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
132 out <<
" </SOLVER> \n";
134 #ifdef EIGEN_PARDISO_SUPPORT 136 out <<
" <TYPE> LU </TYPE> \n";
137 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
138 out <<
" </SOLVER> \n";
141 out <<
" <TYPE> LLT </TYPE> \n";
142 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
143 out <<
" </SOLVER> \n";
146 out <<
" <TYPE> LDLT </TYPE> \n";
147 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
148 out <<
" </SOLVER> \n";
150 #ifdef EIGEN_PASTIX_SUPPORT 152 out <<
" <TYPE> LU </TYPE> \n";
153 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
154 out <<
" </SOLVER> \n";
157 out <<
" <TYPE> LLT </TYPE> \n";
158 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
159 out <<
" </SOLVER> \n";
162 out <<
" <TYPE> LDLT </TYPE> \n";
163 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
164 out <<
" </SOLVER> \n";
168 out <<
" <TYPE> BICGSTAB </TYPE> \n";
169 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
170 out <<
" </SOLVER> \n";
173 out <<
" <TYPE> BICGSTAB_ILUT </TYPE> \n";
174 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
175 out <<
" </SOLVER> \n";
178 out <<
" <TYPE> GMRES_ILUT </TYPE> \n";
179 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
180 out <<
" </SOLVER> \n";
183 out <<
" <TYPE> LDLT </TYPE> \n";
184 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
185 out <<
" </SOLVER> \n";
188 out <<
" <TYPE> LLT </TYPE> \n";
189 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
190 out <<
" </SOLVER> \n";
192 out <<
" <SOLVER ID='" <<
EIGEN_CG <<
"'>\n";
193 out <<
" <TYPE> CG </TYPE> \n";
194 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
195 out <<
" </SOLVER> \n";
198 out <<
" <TYPE> LU_COLAMD </TYPE> \n";
199 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
200 out <<
" </SOLVER> \n";
202 #ifdef EIGEN_METIS_SUPPORT 204 out <<
" <TYPE> LU_METIS </TYPE> \n";
205 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
206 out <<
" </SOLVER> \n";
208 out <<
" </AVAILSOLVER> \n";
213 template<
typename Solver,
typename Scalar>
228 std::cerr <<
"Solver failed ... \n";
232 compute_time = timer.
value();
233 statbuf <<
" <TIME>\n";
234 statbuf <<
" <COMPUTE> " << timer.
value() <<
"</COMPUTE>\n";
235 std::cout<<
"COMPUTE TIME : " << timer.
value() <<std::endl;
242 std::cerr <<
"Solver failed ... \n";
246 solve_time = timer.
value();
247 statbuf <<
" <SOLVE> " << timer.
value() <<
"</SOLVE>\n";
248 std::cout<<
"SOLVE TIME : " << timer.
value() <<std::endl;
250 total_time = solve_time + compute_time;
251 statbuf <<
" <TOTAL> " << total_time <<
"</TOTAL>\n";
252 std::cout<<
"TOTAL TIME : " << total_time <<std::endl;
253 statbuf <<
" </TIME>\n";
257 rel_error = (refX - x).norm()/refX.norm();
263 rel_error = (b-temp).norm()/b.norm();
265 statbuf <<
" <ERROR> " << rel_error <<
"</ERROR>\n";
266 std::cout<<
"REL. ERROR : " << rel_error <<
"\n\n" ;
267 if ( rel_error <=
RelErr )
278 template<
typename Solver,
typename Scalar>
281 std::ofstream statbuf(statFile.c_str(), std::ios::app);
282 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
283 call_solver(solver, solver_id, A, b, refX,statbuf);
284 statbuf <<
" </SOLVER_STAT>\n";
288 template<
typename Solver,
typename Scalar>
291 solver.setTolerance(
RelErr);
294 std::ofstream statbuf(statFile.c_str(), std::ios::app);
295 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
296 call_solver(solver, solver_id, A, b, refX,statbuf);
297 statbuf <<
" <ITER> "<< solver.iterations() <<
"</ITER>\n";
298 statbuf <<
" </SOLVER_STAT>\n";
299 std::cout <<
"ITERATIONS : " << solver.iterations() <<
"\n\n\n";
304 template <
typename Scalar>
312 #ifdef EIGEN_UMFPACK_SUPPORT 314 cout <<
"Solving with UMFPACK LU ... \n";
320 #ifdef EIGEN_SUPERLU_SUPPORT 322 cout <<
"\nSolving with SUPERLU ... \n";
329 #ifdef EIGEN_PASTIX_SUPPORT 331 cout <<
"\nSolving with PASTIX LU ... \n";
338 #ifdef EIGEN_PARDISO_SUPPORT 340 cout <<
"\nSolving with PARDISO LU ... \n";
347 cout <<
"\n Solving with Sparse LU AND COLAMD ... \n";
351 #ifdef EIGEN_METIS_SUPPORT 353 cout <<
"\n Solving with Sparse LU AND METIS ... \n";
361 cout <<
"\nSolving with BiCGSTAB ... \n";
367 cout <<
"\nSolving with BiCGSTAB and ILUT ... \n";
381 cout <<
"\nSolving with GMRES and ILUT ... \n";
391 cout <<
"\nSolving with Simplicial LDLT ... \n";
397 #ifdef EIGEN_CHOLMOD_SUPPORT 399 cout <<
"\nSolving with CHOLMOD LDLT ... \n";
407 #ifdef EIGEN_PASTIX_SUPPORT 409 cout <<
"\nSolving with PASTIX LDLT ... \n";
416 #ifdef EIGEN_PARDISO_SUPPORT 418 cout <<
"\nSolving with PARDISO LDLT ... \n";
431 cout <<
"\nSolving with SIMPLICIAL LLT ... \n";
437 #ifdef EIGEN_CHOLMOD_SUPPORT 440 cout <<
"\nSolving with CHOLMOD LLT (Supernodal)... \n";
445 cout <<
"\nSolving with CHOLMOD LLT (Simplicial) ... \n";
452 #ifdef EIGEN_PASTIX_SUPPORT 454 cout <<
"\nSolving with PASTIX LLT ... \n";
461 #ifdef EIGEN_PARDISO_SUPPORT 463 cout <<
"\nSolving with PARDISO LLT ... \n";
471 cout <<
"\nSolving with CG ... \n";
489 template <
typename Scalar>
490 void Browse_Matrices(
const string folder,
bool statFileExists, std::string& statFile,
int maxiters,
double tol)
500 std::ofstream statbuf(statFile.c_str(), std::ios::app);
501 statbuf <<
"<LINEARSYSTEM> \n";
502 statbuf <<
" <MATRIX> \n";
503 statbuf <<
" <NAME> " << it.
matname() <<
" </NAME>\n";
504 statbuf <<
" <SIZE> " << it.
matrix().
rows() <<
" </SIZE>\n";
505 statbuf <<
" <ENTRIES> " << it.
matrix().
nonZeros() <<
"</ENTRIES>\n";
508 statbuf <<
" <SYMMETRY> Symmetric </SYMMETRY>\n" ;
510 statbuf <<
" <POSDEF> YES </POSDEF>\n";
512 statbuf <<
" <POSDEF> NO </POSDEF>\n";
517 statbuf <<
" <SYMMETRY> NonSymmetric </SYMMETRY>\n" ;
518 statbuf <<
" <POSDEF> NO </POSDEF>\n";
520 statbuf <<
" </MATRIX> \n";
524 cout<<
"\n\n===================================================== \n";
525 cout<<
" ====== SOLVING WITH MATRIX " << it.
matname() <<
" ====\n";
526 cout<<
" =================================================== \n\n";
530 SelectSolvers<Scalar>(it.
matrix(), it.
sym(), it.
rhs(), refX, statFile);
534 std::ofstream statbuf(statFile.c_str(), std::ios::app);
536 <<
"'></BEST_SOLVER>\n";
537 statbuf <<
" </LINEARSYSTEM> \n";
545 int idx = 1, found=
false;
546 while (idx<argc && !found){
547 if (option.compare(args[idx]) == 0){
#define EIGEN_SIMPLICIAL_LDLT
void setMode(CholmodMode mode)
void printStatheader(std::ofstream &out)
void SelectSolvers(const SparseMatrix< Scalar > &A, unsigned int sym, Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
A sparse LU factorization and solver based on UmfPack.
double test_precision< double >()
void Browse_Matrices(const string folder, bool statFileExists, std::string &statFile, int maxiters, double tol)
#define EIGEN_CHOLMOD_LDLT
#define EIGEN_BICGSTAB_ILUT
A sparse direct LU factorization and solver based on the SuperLU library.
bool get_options(int argc, char **args, string option, string *value=0)
void printBenchStyle(std::ofstream &out)
Namespace containing all symbols from the Eigen library.
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
BiCGSTAB< SparseMatrix< double > > solver
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
void call_itersolver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
A direct sparse LDLT Cholesky factorizations without square root.
Sparse supernodal LU factorization for general matrices.
#define EIGEN_SPARSELU_METIS
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
float test_precision< float >()
#define EIGEN_PARDISO_LLT
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library...
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Iterator to browse matrices from a specified folder.
A sparse direct LU factorization and solver based on the PARDISO library.
A general Cholesky factorization and solver based on Cholmod.
Eigen::SparseMatrix< double > SpMat
#define EIGEN_SIMPLICIAL_LLT
double value(int TIMER=CPU_TIMER) const
NumTraits< T >::Real test_precision()
A GMRES solver for sparse square problems.
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Interface to the PaStix solver.
#define EIGEN_SPARSELU_COLAMD
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library...
A bi conjugate gradient stabilized solver for sparse square problems.
#define EIGEN_PASTIX_LDLT
A direct sparse LLT Cholesky factorizations.
#define EIGEN_CHOLMOD_SUPERNODAL_LLT
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
#define EIGEN_PARDISO_LDLT
void call_directsolver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
void call_solver(Solver &solver, const int solver_id, const typename Solver::MatrixType &A, const Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::ofstream &statbuf)