spbenchsolver.cpp File Reference

Functions

void bench_printhelp ()
 
int main (int argc, char **args)
 

Function Documentation

◆ bench_printhelp()

void bench_printhelp ( )
3  {
4  cout << " \nbenchsolver : performs a benchmark of all the solvers available in Eigen \n\n";
5  cout << " MATRIX FOLDER : \n";
6  cout << " The matrices for the benchmark should be collected in a folder specified with an environment variable "
7  "EIGEN_MATRIXDIR \n";
8  cout << " The matrices are stored using the matrix market coordinate format \n";
9  cout << " The matrix and associated right-hand side (rhs) files are named respectively as MatrixName.mtx and "
10  "MatrixName_b.mtx.\n";
11  cout << " If the rhs does not exist, a random one is generated. \n";
12  cout << " If a true solution exists, it should be named as MatrixName_x.mtx ; it will be used to compute the norm of "
13  "the error \n";
14  cout << " relative to the computed solutions. \n";
15  cout << " If a matrix is SPD, the matrix should be named as MatrixName_SPD.mtx (then use MatrixName_SPD_b.mtx \n";
16  cout << " and MatrixName_SPD_x.mtx for the rhs and the true solution).\n\n";
17  cout << " OPTIONS : \n";
18  cout << " -h or --help \n print this help and return\n\n";
19  cout << " -d matrixdir \n Use matrixdir as the matrix folder instead of the one specified in the environment "
20  "variable EIGEN_MATRIXDIR\n\n";
21  cout << " -o outputfile.xml \n Output the statistics to a xml file \n\n";
22  cout << " --eps <RelErr> Sets the relative tolerance for iterative solvers (default 1e-08) \n\n";
23  cout << " --maxits <MaxIts> Sets the maximum number of iterations (default 1000) \n\n";
24 }

Referenced by main().

◆ main()

int main ( int argc  ,
char **  args 
)
26  {
27  bool help = (get_options(argc, args, "-h") || get_options(argc, args, "--help"));
28  if (help) {
30  return 0;
31  }
32 
33  // Get the location of the test matrices
34  string matrix_dir;
35  if (!get_options(argc, args, "-d", &matrix_dir)) {
36  if (getenv("EIGEN_MATRIXDIR") == NULL) {
37  std::cerr << "Please, specify the location of the matrices with -d mat_folder or the environment variable "
38  "EIGEN_MATRIXDIR \n";
39  std::cerr << " Run with --help to see the list of all the available options \n";
40  return -1;
41  }
42  matrix_dir = getenv("EIGEN_MATRIXDIR");
43  }
44 
45  std::ofstream statbuf;
46  string statFile;
47 
48  // Get the file to write the statistics
49  bool statFileExists = get_options(argc, args, "-o", &statFile);
50  if (statFileExists) {
51  statbuf.open(statFile.c_str(), std::ios::out);
52  if (statbuf.good()) {
53  statFileExists = true;
54  printStatheader(statbuf);
55  statbuf.close();
56  } else
57  std::cerr << "Unable to open the provided file for writing... \n";
58  }
59 
60  // Get the maximum number of iterations and the tolerance
61  int maxiters = 1000;
62  double tol = 1e-08;
63  string inval;
64  if (get_options(argc, args, "--eps", &inval)) tol = atof(inval.c_str());
65  if (get_options(argc, args, "--maxits", &inval)) maxiters = atoi(inval.c_str());
66 
67  string current_dir;
68  // Test the real-arithmetics matrices
69  Browse_Matrices<double>(matrix_dir, statFileExists, statFile, maxiters, tol);
70 
71  // Test the complex-arithmetics matrices
72  Browse_Matrices<std::complex<double> >(matrix_dir, statFileExists, statFile, maxiters, tol);
73 
74  if (statFileExists) {
75  statbuf.open(statFile.c_str(), std::ios::app);
76  statbuf << "</BENCH> \n";
77  cout << "\n Output written in " << statFile << " ...\n";
78  statbuf.close();
79  }
80 
81  return 0;
82 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
args
Definition: compute_granudrum_aor.py:143
help
Definition: compute_granudrum_aor.py:141
void bench_printhelp()
Definition: spbenchsolver.cpp:3
bool get_options(int argc, char **args, string option, string *value=0)
Definition: spbenchsolver.h:555
void printStatheader(std::ofstream &out)
Definition: spbenchsolver.h:109
std::ofstream out("Result.txt")

References compute_granudrum_aor::args, bench_printhelp(), e(), get_options(), compute_granudrum_aor::help, out(), and printStatheader().