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_KLU_SUPPORT
41#include <Eigen/KLUSupport>
44#ifdef EIGEN_PARDISO_SUPPORT
45#include <Eigen/PardisoSupport>
48#ifdef EIGEN_SUPERLU_SUPPORT
49#include <Eigen/SuperLUSupport>
52#ifdef EIGEN_PASTIX_SUPPORT
53#include <Eigen/PaStiXSupport>
57#define EIGEN_UMFPACK 10
59#define EIGEN_SUPERLU 20
60#define EIGEN_PASTIX 30
61#define EIGEN_PARDISO 40
62#define EIGEN_SPARSELU_COLAMD 50
63#define EIGEN_SPARSELU_METIS 51
64#define EIGEN_BICGSTAB 60
65#define EIGEN_BICGSTAB_ILUT 61
67#define EIGEN_GMRES_ILUT 71
68#define EIGEN_SIMPLICIAL_LDLT 80
69#define EIGEN_CHOLMOD_LDLT 90
70#define EIGEN_PASTIX_LDLT 100
71#define EIGEN_PARDISO_LDLT 110
72#define EIGEN_SIMPLICIAL_LLT 120
73#define EIGEN_CHOLMOD_SUPERNODAL_LLT 130
74#define EIGEN_CHOLMOD_SIMPLICIAL_LLT 140
75#define EIGEN_PASTIX_LLT 150
76#define EIGEN_PARDISO_LLT 160
78#define EIGEN_CG_PRECOND 180
101 out <<
"<?xml version='1.0' encoding='UTF-8'?> \n";
102 out <<
"<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
103 out <<
"<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
104 out <<
"\n\n<!-- Generated by the Eigen library -->\n";
106 out <<
"\n<BENCH> \n" ;
110 out <<
" <AVAILSOLVER> \n";
111#ifdef EIGEN_UMFPACK_SUPPORT
113 out <<
" <TYPE> LU </TYPE> \n";
114 out <<
" <PACKAGE> UMFPACK </PACKAGE> \n";
115 out <<
" </SOLVER> \n";
117#ifdef EIGEN_KLU_SUPPORT
119 out <<
" <TYPE> LU </TYPE> \n";
120 out <<
" <PACKAGE> KLU </PACKAGE> \n";
121 out <<
" </SOLVER> \n";
123#ifdef EIGEN_SUPERLU_SUPPORT
125 out <<
" <TYPE> LU </TYPE> \n";
126 out <<
" <PACKAGE> SUPERLU </PACKAGE> \n";
127 out <<
" </SOLVER> \n";
129#ifdef EIGEN_CHOLMOD_SUPPORT
131 out <<
" <TYPE> LLT SP</TYPE> \n";
132 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
133 out <<
" </SOLVER> \n";
136 out <<
" <TYPE> LLT</TYPE> \n";
137 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
138 out <<
" </SOLVER> \n";
141 out <<
" <TYPE> LDLT </TYPE> \n";
142 out <<
" <PACKAGE> CHOLMOD </PACKAGE> \n";
143 out <<
" </SOLVER> \n";
145#ifdef EIGEN_PARDISO_SUPPORT
147 out <<
" <TYPE> LU </TYPE> \n";
148 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
149 out <<
" </SOLVER> \n";
152 out <<
" <TYPE> LLT </TYPE> \n";
153 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
154 out <<
" </SOLVER> \n";
157 out <<
" <TYPE> LDLT </TYPE> \n";
158 out <<
" <PACKAGE> PARDISO </PACKAGE> \n";
159 out <<
" </SOLVER> \n";
161#ifdef EIGEN_PASTIX_SUPPORT
163 out <<
" <TYPE> LU </TYPE> \n";
164 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
165 out <<
" </SOLVER> \n";
168 out <<
" <TYPE> LLT </TYPE> \n";
169 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
170 out <<
" </SOLVER> \n";
173 out <<
" <TYPE> LDLT </TYPE> \n";
174 out <<
" <PACKAGE> PASTIX </PACKAGE> \n";
175 out <<
" </SOLVER> \n";
179 out <<
" <TYPE> BICGSTAB </TYPE> \n";
180 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
181 out <<
" </SOLVER> \n";
184 out <<
" <TYPE> BICGSTAB_ILUT </TYPE> \n";
185 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
186 out <<
" </SOLVER> \n";
189 out <<
" <TYPE> GMRES_ILUT </TYPE> \n";
190 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
191 out <<
" </SOLVER> \n";
194 out <<
" <TYPE> LDLT </TYPE> \n";
195 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
196 out <<
" </SOLVER> \n";
199 out <<
" <TYPE> LLT </TYPE> \n";
200 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
201 out <<
" </SOLVER> \n";
204 out <<
" <TYPE> CG </TYPE> \n";
205 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
206 out <<
" </SOLVER> \n";
209 out <<
" <TYPE> LU_COLAMD </TYPE> \n";
210 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
211 out <<
" </SOLVER> \n";
213#ifdef EIGEN_METIS_SUPPORT
215 out <<
" <TYPE> LU_METIS </TYPE> \n";
216 out <<
" <PACKAGE> EIGEN </PACKAGE> \n";
217 out <<
" </SOLVER> \n";
219 out <<
" </AVAILSOLVER> \n";
224template<
typename Solver,
typename Scalar>
239 std::cerr <<
"Solver failed ... \n";
243 compute_time = timer.
value();
244 statbuf <<
" <TIME>\n";
245 statbuf <<
" <COMPUTE> " << timer.
value() <<
"</COMPUTE>\n";
246 std::cout<<
"COMPUTE TIME : " << timer.
value() <<std::endl;
253 std::cerr <<
"Solver failed ... \n";
257 solve_time = timer.
value();
258 statbuf <<
" <SOLVE> " << timer.
value() <<
"</SOLVE>\n";
259 std::cout<<
"SOLVE TIME : " << timer.
value() <<std::endl;
261 total_time = solve_time + compute_time;
262 statbuf <<
" <TOTAL> " << total_time <<
"</TOTAL>\n";
263 std::cout<<
"TOTAL TIME : " << total_time <<std::endl;
264 statbuf <<
" </TIME>\n";
268 rel_error = (refX -
x).norm()/refX.norm();
274 rel_error = (
b-temp).norm()/
b.norm();
276 statbuf <<
" <ERROR> " << rel_error <<
"</ERROR>\n";
277 std::cout<<
"REL. ERROR : " << rel_error <<
"\n\n" ;
278 if ( rel_error <=
RelErr )
289template<
typename Solver,
typename Scalar>
292 std::ofstream statbuf(statFile.c_str(), std::ios::app);
293 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
295 statbuf <<
" </SOLVER_STAT>\n";
299template<
typename Solver,
typename Scalar>
305 std::ofstream statbuf(statFile.c_str(), std::ios::app);
306 statbuf <<
" <SOLVER_STAT ID='" << solver_id <<
"'>\n";
308 statbuf <<
" <ITER> "<<
solver.iterations() <<
"</ITER>\n";
309 statbuf <<
" </SOLVER_STAT>\n";
310 std::cout <<
"ITERATIONS : " <<
solver.iterations() <<
"\n\n\n";
315template <
typename Scalar>
323 #ifdef EIGEN_UMFPACK_SUPPORT
325 cout <<
"Solving with UMFPACK LU ... \n";
331 #ifdef EIGEN_KLU_SUPPORT
333 cout <<
"Solving with KLU LU ... \n";
339 #ifdef EIGEN_SUPERLU_SUPPORT
341 cout <<
"\nSolving with SUPERLU ... \n";
348 #ifdef EIGEN_PASTIX_SUPPORT
350 cout <<
"\nSolving with PASTIX LU ... \n";
357 #ifdef EIGEN_PARDISO_SUPPORT
359 cout <<
"\nSolving with PARDISO LU ... \n";
366 cout <<
"\n Solving with Sparse LU AND COLAMD ... \n";
370 #ifdef EIGEN_METIS_SUPPORT
372 cout <<
"\n Solving with Sparse LU AND METIS ... \n";
380 cout <<
"\nSolving with BiCGSTAB ... \n";
386 cout <<
"\nSolving with BiCGSTAB and ILUT ... \n";
400 cout <<
"\nSolving with GMRES and ILUT ... \n";
410 cout <<
"\nSolving with Simplicial LDLT ... \n";
416 #ifdef EIGEN_CHOLMOD_SUPPORT
418 cout <<
"\nSolving with CHOLMOD LDLT ... \n";
426 #ifdef EIGEN_PASTIX_SUPPORT
428 cout <<
"\nSolving with PASTIX LDLT ... \n";
435 #ifdef EIGEN_PARDISO_SUPPORT
437 cout <<
"\nSolving with PARDISO LDLT ... \n";
450 cout <<
"\nSolving with SIMPLICIAL LLT ... \n";
456 #ifdef EIGEN_CHOLMOD_SUPPORT
459 cout <<
"\nSolving with CHOLMOD LLT (Supernodal)... \n";
464 cout <<
"\nSolving with CHOLMOD LLT (Simplicial) ... \n";
471 #ifdef EIGEN_PASTIX_SUPPORT
473 cout <<
"\nSolving with PASTIX LLT ... \n";
480 #ifdef EIGEN_PARDISO_SUPPORT
482 cout <<
"\nSolving with PARDISO LLT ... \n";
490 cout <<
"\nSolving with CG ... \n";
508template <
typename Scalar>
509void Browse_Matrices(
const string folder,
bool statFileExists, std::string& statFile,
int maxiters,
double tol)
519 std::ofstream statbuf(statFile.c_str(), std::ios::app);
520 statbuf <<
"<LINEARSYSTEM> \n";
521 statbuf <<
" <MATRIX> \n";
522 statbuf <<
" <NAME> " << it.
matname() <<
" </NAME>\n";
523 statbuf <<
" <SIZE> " << it.
matrix().
rows() <<
" </SIZE>\n";
524 statbuf <<
" <ENTRIES> " << it.
matrix().
nonZeros() <<
"</ENTRIES>\n";
527 statbuf <<
" <SYMMETRY> Symmetric </SYMMETRY>\n" ;
529 statbuf <<
" <POSDEF> YES </POSDEF>\n";
531 statbuf <<
" <POSDEF> NO </POSDEF>\n";
536 statbuf <<
" <SYMMETRY> NonSymmetric </SYMMETRY>\n" ;
537 statbuf <<
" <POSDEF> NO </POSDEF>\n";
539 statbuf <<
" </MATRIX> \n";
543 cout<<
"\n\n===================================================== \n";
544 cout<<
" ====== SOLVING WITH MATRIX " << it.
matname() <<
" ====\n";
545 cout<<
" =================================================== \n\n";
549 SelectSolvers<Scalar>(it.
matrix(), it.
sym(), it.
rhs(), refX, statFile);
553 std::ofstream statbuf(statFile.c_str(), std::ios::app);
555 <<
"'></BEST_SOLVER>\n";
556 statbuf <<
" </LINEARSYSTEM> \n";
562bool get_options(
int argc,
char **args,
string option,
string* value=0)
564 int idx = 1, found=
false;
565 while (idx<argc && !found){
566 if (option.compare(args[idx]) == 0){
568 if(value) *value = args[idx+1];
BiCGSTAB< SparseMatrix< double > > solver
Definition BiCGSTAB_simple.cpp:5
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Eigen::SparseMatrix< double > SpMat
Definition Tutorial_sparse_example.cpp:5
Scalar * b
Definition benchVecAdd.cpp:17
Definition BenchTimer.h:60
double value(int TIMER=CPU_TIMER) const
Definition BenchTimer.h:104
void reset()
Definition BenchTimer.h:75
void stop()
Definition BenchTimer.h:86
void start()
Definition BenchTimer.h:81
A bi conjugate gradient stabilized solver for sparse square problems.
Definition BiCGSTAB.h:159
A general Cholesky factorization and solver based on Cholmod.
Definition CholmodSupport.h:629
void setMode(CholmodMode mode)
Definition CholmodSupport.h:647
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition ConjugateGradient.h:159
A GMRES solver for sparse square problems.
Definition GMRES.h:270
Definition KLUSupport.h:61
Iterator to browse matrices from a specified folder.
Definition MatrixMarketIterator.h:43
MatrixType & matrix()
Definition MatrixMarketIterator.h:74
VectorType & refX()
Definition MatrixMarketIterator.h:145
std::string & matname()
Definition MatrixMarketIterator.h:163
bool hasrefX()
Definition MatrixMarketIterator.h:168
VectorType & rhs()
Definition MatrixMarketIterator.h:113
int sym()
Definition MatrixMarketIterator.h:165
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:505
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:442
A sparse direct LU factorization and solver based on the PARDISO library.
Definition PardisoSupport.h:386
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition PaStiXSupport.h:609
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition PaStiXSupport.h:525
Interface to the PaStix solver.
Definition PaStiXSupport.h:413
A direct sparse LDLT Cholesky factorizations without square root.
Definition SimplicialCholesky.h:430
A direct sparse LLT Cholesky factorizations.
Definition SimplicialCholesky.h:339
Sparse supernodal LU factorization for general matrices.
Definition SparseLU.h:132
A versatible sparse matrix representation.
Definition SparseMatrix.h:98
Index nonZeros() const
Definition SparseCompressedBase.h:56
Index rows() const
Definition SparseMatrix.h:138
A sparse direct LU factorization and solver based on the SuperLU library.
Definition SuperLUSupport.h:489
A sparse LU factorization and solver based on UmfPack.
Definition UmfPackSupport.h:289
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
Definition gnuplot_common_settings.hh:12
@ NumericalIssue
Definition Constants.h:444
@ Success
Definition Constants.h:442
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
@ CholmodSimplicialLLt
Definition CholmodSupport.h:204
@ CholmodLDLt
Definition CholmodSupport.h:204
@ CholmodSupernodalLLt
Definition CholmodSupport.h:204
@ NonSymmetric
Definition MatrixMarketIterator.h:18
@ SPD
Definition MatrixMarketIterator.h:17
#define EIGEN_PASTIX_LLT
Definition spbenchsolver.h:75
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)
Definition spbenchsolver.h:300
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)
Definition spbenchsolver.h:290
#define EIGEN_KLU
Definition spbenchsolver.h:58
bool get_options(int argc, char **args, string option, string *value=0)
Definition spbenchsolver.h:562
#define EIGEN_PASTIX_LDLT
Definition spbenchsolver.h:70
#define EIGEN_CHOLMOD_SUPERNODAL_LLT
Definition spbenchsolver.h:73
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT
Definition spbenchsolver.h:74
#define EIGEN_PARDISO
Definition spbenchsolver.h:61
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)
Definition spbenchsolver.h:225
double test_precision< double >()
Definition spbenchsolver.h:92
#define EIGEN_PASTIX
Definition spbenchsolver.h:60
#define EIGEN_SIMPLICIAL_LDLT
Definition spbenchsolver.h:68
#define EIGEN_SUPERLU
Definition spbenchsolver.h:59
int MaximumIters
Definition spbenchsolver.h:85
#define EIGEN_SPARSELU_METIS
Definition spbenchsolver.h:63
void SelectSolvers(const SparseMatrix< Scalar > &A, unsigned int sym, Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
Definition spbenchsolver.h:316
float test_precision< float >()
Definition spbenchsolver.h:91
double RelErr
Definition spbenchsolver.h:86
#define EIGEN_BICGSTAB
Definition spbenchsolver.h:64
#define EIGEN_SPARSELU_COLAMD
Definition spbenchsolver.h:62
#define EIGEN_CHOLMOD_LDLT
Definition spbenchsolver.h:69
#define EIGEN_PARDISO_LDLT
Definition spbenchsolver.h:71
#define EIGEN_SIMPLICIAL_LLT
Definition spbenchsolver.h:72
#define EIGEN_PARDISO_LLT
Definition spbenchsolver.h:76
int best_time_id
Definition spbenchsolver.h:88
#define EIGEN_CG
Definition spbenchsolver.h:77
double best_time_val
Definition spbenchsolver.h:87
void printStatheader(std::ofstream &out)
Definition spbenchsolver.h:96
void Browse_Matrices(const string folder, bool statFileExists, std::string &statFile, int maxiters, double tol)
Definition spbenchsolver.h:509
NumTraits< T >::Real test_precision()
Definition spbenchsolver.h:90
#define EIGEN_BICGSTAB_ILUT
Definition spbenchsolver.h:65
#define EIGEN_GMRES_ILUT
Definition spbenchsolver.h:67
#define EIGEN_UMFPACK
Definition spbenchsolver.h:57
void printBenchStyle(std::ofstream &out)
Definition spbenchstyle.h:13
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
std::ofstream out("Result.txt")