spbenchsolver.h File Reference
#include <iostream>
#include <fstream>
#include <Eigen/SparseCore>
#include <bench/BenchTimer.h>
#include <cstdlib>
#include <string>
#include <Eigen/Cholesky>
#include <Eigen/Jacobi>
#include <Eigen/Householder>
#include <Eigen/IterativeLinearSolvers>
#include <unsupported/Eigen/IterativeSolvers>
#include <Eigen/LU>
#include <unsupported/Eigen/SparseExtra>
#include <Eigen/SparseLU>
#include "spbenchstyle.h"

Go to the source code of this file.

Macros

#define EIGEN_UMFPACK   10
 
#define EIGEN_KLU   11
 
#define EIGEN_SUPERLU   20
 
#define EIGEN_PASTIX   30
 
#define EIGEN_PARDISO   40
 
#define EIGEN_SPARSELU_COLAMD   50
 
#define EIGEN_SPARSELU_METIS   51
 
#define EIGEN_BICGSTAB   60
 
#define EIGEN_BICGSTAB_ILUT   61
 
#define EIGEN_GMRES   70
 
#define EIGEN_GMRES_ILUT   71
 
#define EIGEN_SIMPLICIAL_LDLT   80
 
#define EIGEN_CHOLMOD_LDLT   90
 
#define EIGEN_PASTIX_LDLT   100
 
#define EIGEN_PARDISO_LDLT   110
 
#define EIGEN_SIMPLICIAL_LLT   120
 
#define EIGEN_CHOLMOD_SUPERNODAL_LLT   130
 
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT   140
 
#define EIGEN_PASTIX_LLT   150
 
#define EIGEN_PARDISO_LLT   160
 
#define EIGEN_CG   170
 
#define EIGEN_CG_PRECOND   180
 

Functions

template<typename T >
NumTraits< T >::Real test_precision ()
 
template<>
float test_precision< float > ()
 
template<>
double test_precision< double > ()
 
template<>
float test_precision< std::complex< float > > ()
 
template<>
double test_precision< std::complex< double > > ()
 
void printStatheader (std::ofstream &out)
 
template<typename Solver , typename Scalar >
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)
 
template<typename Solver , typename Scalar >
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)
 
template<typename Solver , typename Scalar >
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)
 
template<typename Scalar >
void SelectSolvers (const SparseMatrix< Scalar > &A, unsigned int sym, Matrix< Scalar, Dynamic, 1 > &b, const Matrix< Scalar, Dynamic, 1 > &refX, std::string &statFile)
 
template<typename Scalar >
void Browse_Matrices (const string folder, bool statFileExists, std::string &statFile, int maxiters, double tol)
 
bool get_options (int argc, char **args, string option, string *value=0)
 

Variables

int MaximumIters
 
double RelErr
 
double best_time_val
 
int best_time_id
 

Macro Definition Documentation

◆ EIGEN_BICGSTAB

#define EIGEN_BICGSTAB   60

◆ EIGEN_BICGSTAB_ILUT

#define EIGEN_BICGSTAB_ILUT   61

◆ EIGEN_CG

#define EIGEN_CG   170

◆ EIGEN_CG_PRECOND

#define EIGEN_CG_PRECOND   180

◆ EIGEN_CHOLMOD_LDLT

#define EIGEN_CHOLMOD_LDLT   90

◆ EIGEN_CHOLMOD_SIMPLICIAL_LLT

#define EIGEN_CHOLMOD_SIMPLICIAL_LLT   140

◆ EIGEN_CHOLMOD_SUPERNODAL_LLT

#define EIGEN_CHOLMOD_SUPERNODAL_LLT   130

◆ EIGEN_GMRES

#define EIGEN_GMRES   70

◆ EIGEN_GMRES_ILUT

#define EIGEN_GMRES_ILUT   71

◆ EIGEN_KLU

#define EIGEN_KLU   11

◆ EIGEN_PARDISO

#define EIGEN_PARDISO   40

◆ EIGEN_PARDISO_LDLT

#define EIGEN_PARDISO_LDLT   110

◆ EIGEN_PARDISO_LLT

#define EIGEN_PARDISO_LLT   160

◆ EIGEN_PASTIX

#define EIGEN_PASTIX   30

◆ EIGEN_PASTIX_LDLT

#define EIGEN_PASTIX_LDLT   100

◆ EIGEN_PASTIX_LLT

#define EIGEN_PASTIX_LLT   150

◆ EIGEN_SIMPLICIAL_LDLT

#define EIGEN_SIMPLICIAL_LDLT   80

◆ EIGEN_SIMPLICIAL_LLT

#define EIGEN_SIMPLICIAL_LLT   120

◆ EIGEN_SPARSELU_COLAMD

#define EIGEN_SPARSELU_COLAMD   50

◆ EIGEN_SPARSELU_METIS

#define EIGEN_SPARSELU_METIS   51

◆ EIGEN_SUPERLU

#define EIGEN_SUPERLU   20

◆ EIGEN_UMFPACK

#define EIGEN_UMFPACK   10

Function Documentation

◆ Browse_Matrices()

template<typename Scalar >
void Browse_Matrices ( const string  folder,
bool  statFileExists,
std::string &  statFile,
int  maxiters,
double  tol 
)
510  {
511  MaximumIters = maxiters; // Maximum number of iterations, global variable
512  RelErr = tol; // Relative residual error as stopping criterion for iterative solvers
513  MatrixMarketIterator<Scalar> it(folder);
514  for (; it; ++it) {
515  // print the infos for this linear system
516  if (statFileExists) {
517  std::ofstream statbuf(statFile.c_str(), std::ios::app);
518  statbuf << "<LINEARSYSTEM> \n";
519  statbuf << " <MATRIX> \n";
520  statbuf << " <NAME> " << it.matname() << " </NAME>\n";
521  statbuf << " <SIZE> " << it.matrix().rows() << " </SIZE>\n";
522  statbuf << " <ENTRIES> " << it.matrix().nonZeros() << "</ENTRIES>\n";
523  if (it.sym() != NonSymmetric) {
524  statbuf << " <SYMMETRY> Symmetric </SYMMETRY>\n";
525  if (it.sym() == SPD)
526  statbuf << " <POSDEF> YES </POSDEF>\n";
527  else
528  statbuf << " <POSDEF> NO </POSDEF>\n";
529 
530  } else {
531  statbuf << " <SYMMETRY> NonSymmetric </SYMMETRY>\n";
532  statbuf << " <POSDEF> NO </POSDEF>\n";
533  }
534  statbuf << " </MATRIX> \n";
535  statbuf.close();
536  }
537 
538  cout << "\n\n===================================================== \n";
539  cout << " ====== SOLVING WITH MATRIX " << it.matname() << " ====\n";
540  cout << " =================================================== \n\n";
542  if (it.hasrefX()) refX = it.refX();
543  // Call all suitable solvers for this linear system
544  SelectSolvers<Scalar>(it.matrix(), it.sym(), it.rhs(), refX, statFile);
545 
546  if (statFileExists) {
547  std::ofstream statbuf(statFile.c_str(), std::ios::app);
548  statbuf << " <BEST_SOLVER ID='" << best_time_id << "'></BEST_SOLVER>\n";
549  statbuf << " </LINEARSYSTEM> \n";
550  statbuf.close();
551  }
552  }
553 }
Iterator to browse matrices from a specified folder.
Definition: MatrixMarketIterator.h:42
@ NonSymmetric
Definition: MatrixMarketIterator.h:19
@ SPD
Definition: MatrixMarketIterator.h:19
int MaximumIters
Definition: spbenchsolver.h:83
double RelErr
Definition: spbenchsolver.h:84
int best_time_id
Definition: spbenchsolver.h:86

References best_time_id, Eigen::MatrixMarketIterator< Scalar >::hasrefX(), Eigen::MatrixMarketIterator< Scalar >::matname(), Eigen::MatrixMarketIterator< Scalar >::matrix(), MaximumIters, Eigen::NonSymmetric, Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::nonZeros(), Eigen::MatrixMarketIterator< Scalar >::refX(), RelErr, Eigen::MatrixMarketIterator< Scalar >::rhs(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::rows(), Eigen::SPD, and Eigen::MatrixMarketIterator< Scalar >::sym().

◆ call_directsolver()

template<typename Solver , typename Scalar >
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 
)
297  {
298  std::ofstream statbuf(statFile.c_str(), std::ios::app);
299  statbuf << " <SOLVER_STAT ID='" << solver_id << "'>\n";
300  call_solver(solver, solver_id, A, b, refX, statbuf);
301  statbuf << " </SOLVER_STAT>\n";
302  statbuf.close();
303 }
BiCGSTAB< SparseMatrix< double > > solver
Definition: BiCGSTAB_simple.cpp:5
Scalar * b
Definition: benchVecAdd.cpp:17
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:236

References b, call_solver(), and solver.

Referenced by SelectSolvers().

◆ call_itersolver()

template<typename Solver , typename Scalar >
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 
)
308  {
309  solver.setTolerance(RelErr);
310  solver.setMaxIterations(MaximumIters);
311 
312  std::ofstream statbuf(statFile.c_str(), std::ios::app);
313  statbuf << " <SOLVER_STAT ID='" << solver_id << "'>\n";
314  call_solver(solver, solver_id, A, b, refX, statbuf);
315  statbuf << " <ITER> " << solver.iterations() << "</ITER>\n";
316  statbuf << " </SOLVER_STAT>\n";
317  std::cout << "ITERATIONS : " << solver.iterations() << "\n\n\n";
318 }

References b, call_solver(), MaximumIters, RelErr, and solver.

Referenced by SelectSolvers().

◆ call_solver()

template<typename Solver , typename Scalar >
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 
)
237  {
238  double total_time;
239  double compute_time;
240  double solve_time;
241  double rel_error;
244  timer.reset();
245  timer.start();
246  solver.compute(A);
247  if (solver.info() != Success) {
248  std::cerr << "Solver failed ... \n";
249  return;
250  }
251  timer.stop();
252  compute_time = timer.value();
253  statbuf << " <TIME>\n";
254  statbuf << " <COMPUTE> " << timer.value() << "</COMPUTE>\n";
255  std::cout << "COMPUTE TIME : " << timer.value() << std::endl;
256 
257  timer.reset();
258  timer.start();
259  x = solver.solve(b);
260  if (solver.info() == NumericalIssue) {
261  std::cerr << "Solver failed ... \n";
262  return;
263  }
264  timer.stop();
265  solve_time = timer.value();
266  statbuf << " <SOLVE> " << timer.value() << "</SOLVE>\n";
267  std::cout << "SOLVE TIME : " << timer.value() << std::endl;
268 
269  total_time = solve_time + compute_time;
270  statbuf << " <TOTAL> " << total_time << "</TOTAL>\n";
271  std::cout << "TOTAL TIME : " << total_time << std::endl;
272  statbuf << " </TIME>\n";
273 
274  // Verify the relative error
275  if (refX.size() != 0)
276  rel_error = (refX - x).norm() / refX.norm();
277  else {
278  // Compute the relative residual norm
280  temp = A * x;
281  rel_error = (b - temp).norm() / b.norm();
282  }
283  statbuf << " <ERROR> " << rel_error << "</ERROR>\n";
284  std::cout << "REL. ERROR : " << rel_error << "\n\n";
285  if (rel_error <= RelErr) {
286  // check the best time if convergence
287  if (!best_time_val || (best_time_val > total_time)) {
288  best_time_val = total_time;
289  best_time_id = solver_id;
290  }
291  }
292 }
Definition: BenchTimer.h:55
@ NumericalIssue
Definition: Constants.h:442
@ Success
Definition: Constants.h:440
list x
Definition: plotDoE.py:28
double timer
Definition: oomph_metis_from_parmetis_3.1.1/struct.h:210
double best_time_val
Definition: spbenchsolver.h:85

References b, best_time_id, best_time_val, Eigen::NumericalIssue, RelErr, solver, Eigen::Success, and plotDoE::x.

Referenced by call_directsolver(), and call_itersolver().

◆ get_options()

bool get_options ( int  argc,
char **  args,
string  option,
string *  value = 0 
)
555  {
556  int idx = 1, found = false;
557  while (idx < argc && !found) {
558  if (option.compare(args[idx]) == 0) {
559  found = true;
560  if (value) *value = args[idx + 1];
561  }
562  idx += 2;
563  }
564  return found;
565 }
squared absolute value
Definition: GlobalFunctions.h:87
bool found
Definition: MergeRestartFiles.py:24
args
Definition: compute_granudrum_aor.py:143

References compute_granudrum_aor::args, MergeRestartFiles::found, and Eigen::value.

Referenced by main().

◆ printStatheader()

void printStatheader ( std::ofstream &  out)
109  {
110  // Print XML header
111  // NOTE It would have been much easier to write these XML documents using external libraries like tinyXML or
112  // Xerces-C++.
113 
114  out << "<?xml version='1.0' encoding='UTF-8'?> \n";
115  out << "<?xml-stylesheet type='text/xsl' href='#stylesheet' ?> \n";
116  out << "<!DOCTYPE BENCH [\n<!ATTLIST xsl:stylesheet\n id\t ID #REQUIRED>\n]>";
117  out << "\n\n<!-- Generated by the Eigen library -->\n";
118 
119  out << "\n<BENCH> \n"; // root XML element
120  // Print the xsl style section
122  // List all available solvers
123  out << " <AVAILSOLVER> \n";
124 #ifdef EIGEN_UMFPACK_SUPPORT
125  out << " <SOLVER ID='" << EIGEN_UMFPACK << "'>\n";
126  out << " <TYPE> LU </TYPE> \n";
127  out << " <PACKAGE> UMFPACK </PACKAGE> \n";
128  out << " </SOLVER> \n";
129 #endif
130 #ifdef EIGEN_KLU_SUPPORT
131  out << " <SOLVER ID='" << EIGEN_KLU << "'>\n";
132  out << " <TYPE> LU </TYPE> \n";
133  out << " <PACKAGE> KLU </PACKAGE> \n";
134  out << " </SOLVER> \n";
135 #endif
136 #ifdef EIGEN_SUPERLU_SUPPORT
137  out << " <SOLVER ID='" << EIGEN_SUPERLU << "'>\n";
138  out << " <TYPE> LU </TYPE> \n";
139  out << " <PACKAGE> SUPERLU </PACKAGE> \n";
140  out << " </SOLVER> \n";
141 #endif
142 #ifdef EIGEN_CHOLMOD_SUPPORT
143  out << " <SOLVER ID='" << EIGEN_CHOLMOD_SIMPLICIAL_LLT << "'>\n";
144  out << " <TYPE> LLT SP</TYPE> \n";
145  out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
146  out << " </SOLVER> \n";
147 
148  out << " <SOLVER ID='" << EIGEN_CHOLMOD_SUPERNODAL_LLT << "'>\n";
149  out << " <TYPE> LLT</TYPE> \n";
150  out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
151  out << " </SOLVER> \n";
152 
153  out << " <SOLVER ID='" << EIGEN_CHOLMOD_LDLT << "'>\n";
154  out << " <TYPE> LDLT </TYPE> \n";
155  out << " <PACKAGE> CHOLMOD </PACKAGE> \n";
156  out << " </SOLVER> \n";
157 #endif
158 #ifdef EIGEN_PARDISO_SUPPORT
159  out << " <SOLVER ID='" << EIGEN_PARDISO << "'>\n";
160  out << " <TYPE> LU </TYPE> \n";
161  out << " <PACKAGE> PARDISO </PACKAGE> \n";
162  out << " </SOLVER> \n";
163 
164  out << " <SOLVER ID='" << EIGEN_PARDISO_LLT << "'>\n";
165  out << " <TYPE> LLT </TYPE> \n";
166  out << " <PACKAGE> PARDISO </PACKAGE> \n";
167  out << " </SOLVER> \n";
168 
169  out << " <SOLVER ID='" << EIGEN_PARDISO_LDLT << "'>\n";
170  out << " <TYPE> LDLT </TYPE> \n";
171  out << " <PACKAGE> PARDISO </PACKAGE> \n";
172  out << " </SOLVER> \n";
173 #endif
174 #ifdef EIGEN_PASTIX_SUPPORT
175  out << " <SOLVER ID='" << EIGEN_PASTIX << "'>\n";
176  out << " <TYPE> LU </TYPE> \n";
177  out << " <PACKAGE> PASTIX </PACKAGE> \n";
178  out << " </SOLVER> \n";
179 
180  out << " <SOLVER ID='" << EIGEN_PASTIX_LLT << "'>\n";
181  out << " <TYPE> LLT </TYPE> \n";
182  out << " <PACKAGE> PASTIX </PACKAGE> \n";
183  out << " </SOLVER> \n";
184 
185  out << " <SOLVER ID='" << EIGEN_PASTIX_LDLT << "'>\n";
186  out << " <TYPE> LDLT </TYPE> \n";
187  out << " <PACKAGE> PASTIX </PACKAGE> \n";
188  out << " </SOLVER> \n";
189 #endif
190 
191  out << " <SOLVER ID='" << EIGEN_BICGSTAB << "'>\n";
192  out << " <TYPE> BICGSTAB </TYPE> \n";
193  out << " <PACKAGE> EIGEN </PACKAGE> \n";
194  out << " </SOLVER> \n";
195 
196  out << " <SOLVER ID='" << EIGEN_BICGSTAB_ILUT << "'>\n";
197  out << " <TYPE> BICGSTAB_ILUT </TYPE> \n";
198  out << " <PACKAGE> EIGEN </PACKAGE> \n";
199  out << " </SOLVER> \n";
200 
201  out << " <SOLVER ID='" << EIGEN_GMRES_ILUT << "'>\n";
202  out << " <TYPE> GMRES_ILUT </TYPE> \n";
203  out << " <PACKAGE> EIGEN </PACKAGE> \n";
204  out << " </SOLVER> \n";
205 
206  out << " <SOLVER ID='" << EIGEN_SIMPLICIAL_LDLT << "'>\n";
207  out << " <TYPE> LDLT </TYPE> \n";
208  out << " <PACKAGE> EIGEN </PACKAGE> \n";
209  out << " </SOLVER> \n";
210 
211  out << " <SOLVER ID='" << EIGEN_SIMPLICIAL_LLT << "'>\n";
212  out << " <TYPE> LLT </TYPE> \n";
213  out << " <PACKAGE> EIGEN </PACKAGE> \n";
214  out << " </SOLVER> \n";
215 
216  out << " <SOLVER ID='" << EIGEN_CG << "'>\n";
217  out << " <TYPE> CG </TYPE> \n";
218  out << " <PACKAGE> EIGEN </PACKAGE> \n";
219  out << " </SOLVER> \n";
220 
221  out << " <SOLVER ID='" << EIGEN_SPARSELU_COLAMD << "'>\n";
222  out << " <TYPE> LU_COLAMD </TYPE> \n";
223  out << " <PACKAGE> EIGEN </PACKAGE> \n";
224  out << " </SOLVER> \n";
225 
226 #ifdef EIGEN_METIS_SUPPORT
227  out << " <SOLVER ID='" << EIGEN_SPARSELU_METIS << "'>\n";
228  out << " <TYPE> LU_METIS </TYPE> \n";
229  out << " <PACKAGE> EIGEN </PACKAGE> \n";
230  out << " </SOLVER> \n";
231 #endif
232  out << " </AVAILSOLVER> \n";
233 }
#define EIGEN_PASTIX_LLT
Definition: spbenchsolver.h:74
#define EIGEN_KLU
Definition: spbenchsolver.h:57
#define EIGEN_PASTIX_LDLT
Definition: spbenchsolver.h:69
#define EIGEN_CHOLMOD_SUPERNODAL_LLT
Definition: spbenchsolver.h:72
#define EIGEN_CHOLMOD_SIMPLICIAL_LLT
Definition: spbenchsolver.h:73
#define EIGEN_PARDISO
Definition: spbenchsolver.h:60
#define EIGEN_PASTIX
Definition: spbenchsolver.h:59
#define EIGEN_SIMPLICIAL_LDLT
Definition: spbenchsolver.h:67
#define EIGEN_SUPERLU
Definition: spbenchsolver.h:58
#define EIGEN_SPARSELU_METIS
Definition: spbenchsolver.h:62
#define EIGEN_BICGSTAB
Definition: spbenchsolver.h:63
#define EIGEN_SPARSELU_COLAMD
Definition: spbenchsolver.h:61
#define EIGEN_CHOLMOD_LDLT
Definition: spbenchsolver.h:68
#define EIGEN_PARDISO_LDLT
Definition: spbenchsolver.h:70
#define EIGEN_SIMPLICIAL_LLT
Definition: spbenchsolver.h:71
#define EIGEN_PARDISO_LLT
Definition: spbenchsolver.h:75
#define EIGEN_CG
Definition: spbenchsolver.h:76
#define EIGEN_BICGSTAB_ILUT
Definition: spbenchsolver.h:64
#define EIGEN_GMRES_ILUT
Definition: spbenchsolver.h:66
#define EIGEN_UMFPACK
Definition: spbenchsolver.h:56
void printBenchStyle(std::ofstream &out)
Definition: spbenchstyle.h:13
std::ofstream out("Result.txt")

References EIGEN_BICGSTAB, EIGEN_BICGSTAB_ILUT, EIGEN_CG, EIGEN_CHOLMOD_LDLT, EIGEN_CHOLMOD_SIMPLICIAL_LLT, EIGEN_CHOLMOD_SUPERNODAL_LLT, EIGEN_GMRES_ILUT, EIGEN_KLU, EIGEN_PARDISO, EIGEN_PARDISO_LDLT, EIGEN_PARDISO_LLT, EIGEN_PASTIX, EIGEN_PASTIX_LDLT, EIGEN_PASTIX_LLT, EIGEN_SIMPLICIAL_LDLT, EIGEN_SIMPLICIAL_LLT, EIGEN_SPARSELU_COLAMD, EIGEN_SPARSELU_METIS, EIGEN_SUPERLU, EIGEN_UMFPACK, out(), and printBenchStyle().

Referenced by main().

◆ SelectSolvers()

template<typename Scalar >
void SelectSolvers ( const SparseMatrix< Scalar > &  A,
unsigned int  sym,
Matrix< Scalar, Dynamic, 1 > &  b,
const Matrix< Scalar, Dynamic, 1 > &  refX,
std::string &  statFile 
)
322  {
324  // First, deal with Nonsymmetric and symmetric matrices
325  best_time_id = 0;
326  best_time_val = 0.0;
327 // UMFPACK
328 #ifdef EIGEN_UMFPACK_SUPPORT
329  {
330  cout << "Solving with UMFPACK LU ... \n";
332  call_directsolver(solver, EIGEN_UMFPACK, A, b, refX, statFile);
333  }
334 #endif
335 // KLU
336 #ifdef EIGEN_KLU_SUPPORT
337  {
338  cout << "Solving with KLU LU ... \n";
340  call_directsolver(solver, EIGEN_KLU, A, b, refX, statFile);
341  }
342 #endif
343  // SuperLU
344 #ifdef EIGEN_SUPERLU_SUPPORT
345  {
346  cout << "\nSolving with SUPERLU ... \n";
348  call_directsolver(solver, EIGEN_SUPERLU, A, b, refX, statFile);
349  }
350 #endif
351 
352  // PaStix LU
353 #ifdef EIGEN_PASTIX_SUPPORT
354  {
355  cout << "\nSolving with PASTIX LU ... \n";
357  call_directsolver(solver, EIGEN_PASTIX, A, b, refX, statFile);
358  }
359 #endif
360 
361  // PARDISO LU
362 #ifdef EIGEN_PARDISO_SUPPORT
363  {
364  cout << "\nSolving with PARDISO LU ... \n";
366  call_directsolver(solver, EIGEN_PARDISO, A, b, refX, statFile);
367  }
368 #endif
369 
370  // Eigen SparseLU METIS
371  cout << "\n Solving with Sparse LU AND COLAMD ... \n";
373  call_directsolver(solver, EIGEN_SPARSELU_COLAMD, A, b, refX, statFile);
374 // Eigen SparseLU METIS
375 #ifdef EIGEN_METIS_SUPPORT
376  {
377  cout << "\n Solving with Sparse LU AND METIS ... \n";
379  call_directsolver(solver, EIGEN_SPARSELU_METIS, A, b, refX, statFile);
380  }
381 #endif
382 
383  // BiCGSTAB
384  {
385  cout << "\nSolving with BiCGSTAB ... \n";
387  call_itersolver(solver, EIGEN_BICGSTAB, A, b, refX, statFile);
388  }
389  // BiCGSTAB+ILUT
390  {
391  cout << "\nSolving with BiCGSTAB and ILUT ... \n";
393  call_itersolver(solver, EIGEN_BICGSTAB_ILUT, A, b, refX, statFile);
394  }
395 
396  // GMRES
397  // {
398  // cout << "\nSolving with GMRES ... \n";
399  // GMRES<SpMat> solver;
400  // call_itersolver(solver, EIGEN_GMRES, A, b, refX,statFile);
401  // }
402  // GMRES+ILUT
403  {
404  cout << "\nSolving with GMRES and ILUT ... \n";
406  call_itersolver(solver, EIGEN_GMRES_ILUT, A, b, refX, statFile);
407  }
408 
409  // Hermitian and not necessarily positive-definites
410  if (sym != NonSymmetric) {
411  // Internal Cholesky
412  {
413  cout << "\nSolving with Simplicial LDLT ... \n";
415  call_directsolver(solver, EIGEN_SIMPLICIAL_LDLT, A, b, refX, statFile);
416  }
417 
418 // CHOLMOD
419 #ifdef EIGEN_CHOLMOD_SUPPORT
420  {
421  cout << "\nSolving with CHOLMOD LDLT ... \n";
423  solver.setMode(CholmodLDLt);
424  call_directsolver(solver, EIGEN_CHOLMOD_LDLT, A, b, refX, statFile);
425  }
426 #endif
427 
428 // PASTIX LLT
429 #ifdef EIGEN_PASTIX_SUPPORT
430  {
431  cout << "\nSolving with PASTIX LDLT ... \n";
433  call_directsolver(solver, EIGEN_PASTIX_LDLT, A, b, refX, statFile);
434  }
435 #endif
436 
437 // PARDISO LLT
438 #ifdef EIGEN_PARDISO_SUPPORT
439  {
440  cout << "\nSolving with PARDISO LDLT ... \n";
442  call_directsolver(solver, EIGEN_PARDISO_LDLT, A, b, refX, statFile);
443  }
444 #endif
445  }
446 
447  // Now, symmetric POSITIVE DEFINITE matrices
448  if (sym == SPD) {
449  // Internal Sparse Cholesky
450  {
451  cout << "\nSolving with SIMPLICIAL LLT ... \n";
453  call_directsolver(solver, EIGEN_SIMPLICIAL_LLT, A, b, refX, statFile);
454  }
455 
456 // CHOLMOD
457 #ifdef EIGEN_CHOLMOD_SUPPORT
458  {
459  // CholMOD SuperNodal LLT
460  cout << "\nSolving with CHOLMOD LLT (Supernodal)... \n";
462  solver.setMode(CholmodSupernodalLLt);
464  // CholMod Simplicial LLT
465  cout << "\nSolving with CHOLMOD LLT (Simplicial) ... \n";
466  solver.setMode(CholmodSimplicialLLt);
468  }
469 #endif
470 
471 // PASTIX LLT
472 #ifdef EIGEN_PASTIX_SUPPORT
473  {
474  cout << "\nSolving with PASTIX LLT ... \n";
476  call_directsolver(solver, EIGEN_PASTIX_LLT, A, b, refX, statFile);
477  }
478 #endif
479 
480 // PARDISO LLT
481 #ifdef EIGEN_PARDISO_SUPPORT
482  {
483  cout << "\nSolving with PARDISO LLT ... \n";
485  call_directsolver(solver, EIGEN_PARDISO_LLT, A, b, refX, statFile);
486  }
487 #endif
488 
489  // Internal CG
490  {
491  cout << "\nSolving with CG ... \n";
493  call_itersolver(solver, EIGEN_CG, A, b, refX, statFile);
494  }
495  // CG+IdentityPreconditioner
496  // {
497  // cout << "\nSolving with CG and IdentityPreconditioner ... \n";
498  // ConjugateGradient<SpMat, Lower, IdentityPreconditioner> solver;
499  // call_itersolver(solver,EIGEN_CG_PRECOND, A, b, refX,statFile);
500  // }
501  } // End SPD matrices
502 }
Eigen::SparseMatrix< double > SpMat
Definition: Tutorial_sparse_example.cpp:5
A bi conjugate gradient stabilized solver for sparse square problems.
Definition: BiCGSTAB.h:153
A general Cholesky factorization and solver based on Cholmod.
Definition: CholmodSupport.h:689
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
Definition: ConjugateGradient.h:152
A GMRES solver for sparse square problems.
Definition: GMRES.h:255
Definition: KLUSupport.h:70
A sparse direct Cholesky (LDLT) factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:467
A sparse direct Cholesky (LLT) factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:413
A sparse direct LU factorization and solver based on the PARDISO library.
Definition: PardisoSupport.h:365
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:572
A sparse direct supernodal Cholesky (LLT) factorization and solver based on the PaStiX library.
Definition: PaStiXSupport.h:497
Interface to the PaStix solver.
Definition: PaStiXSupport.h:398
A direct sparse LDLT Cholesky factorizations without square root.
Definition: SimplicialCholesky.h:453
A direct sparse LLT Cholesky factorizations.
Definition: SimplicialCholesky.h:371
Sparse supernodal LU factorization for general matrices.
Definition: SparseLU.h:151
A sparse direct LU factorization and solver based on the SuperLU library.
Definition: SuperLUSupport.h:431
A sparse LU factorization and solver based on UmfPack.
Definition: UmfPackSupport.h:302
@ CholmodSimplicialLLt
Definition: CholmodSupport.h:237
@ CholmodLDLt
Definition: CholmodSupport.h:237
@ CholmodSupernodalLLt
Definition: CholmodSupport.h:237
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:306
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:295

References b, best_time_id, best_time_val, call_directsolver(), call_itersolver(), Eigen::CholmodLDLt, Eigen::CholmodSimplicialLLt, Eigen::CholmodSupernodalLLt, EIGEN_BICGSTAB, EIGEN_BICGSTAB_ILUT, EIGEN_CG, EIGEN_CHOLMOD_LDLT, EIGEN_CHOLMOD_SIMPLICIAL_LLT, EIGEN_CHOLMOD_SUPERNODAL_LLT, EIGEN_GMRES_ILUT, EIGEN_KLU, EIGEN_PARDISO, EIGEN_PARDISO_LDLT, EIGEN_PARDISO_LLT, EIGEN_PASTIX, EIGEN_PASTIX_LDLT, EIGEN_PASTIX_LLT, EIGEN_SIMPLICIAL_LDLT, EIGEN_SIMPLICIAL_LLT, EIGEN_SPARSELU_COLAMD, EIGEN_SPARSELU_METIS, EIGEN_SUPERLU, EIGEN_UMFPACK, Eigen::NonSymmetric, solver, and Eigen::SPD.

◆ test_precision()

template<typename T >
NumTraits<T>::Real test_precision ( )
inline
89  {
91 }
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217

◆ test_precision< double >()

template<>
double test_precision< double > ( )
inline
97  {
98  return 1e-6;
99 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)

References e().

◆ test_precision< float >()

template<>
float test_precision< float > ( )
inline
93  {
94  return 1e-3f;
95 }

Referenced by test_isApprox(), and test_return_by_value().

◆ test_precision< std::complex< double > >()

template<>
double test_precision< std::complex< double > > ( )
inline
105  {
106  return test_precision<double>();
107 }
double test_precision< double >()
Definition: spbenchsolver.h:97

References Eigen::test_precision< double >().

◆ test_precision< std::complex< float > >()

template<>
float test_precision< std::complex< float > > ( )
inline
101  {
102  return test_precision<float>();
103 }
float test_precision< float >()
Definition: spbenchsolver.h:93

References Eigen::test_precision< float >().

Variable Documentation

◆ best_time_id

int best_time_id

◆ best_time_val

double best_time_val

Referenced by call_solver(), and SelectSolvers().

◆ MaximumIters

int MaximumIters

Referenced by Browse_Matrices(), and call_itersolver().

◆ RelErr