spbenchsolver.cpp
Go to the documentation of this file.
2 
4 {
5  cout<< " \nbenchsolver : performs a benchmark of all the solvers available in Eigen \n\n";
6  cout<< " MATRIX FOLDER : \n";
7  cout<< " The matrices for the benchmark should be collected in a folder specified with an environment variable 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 \n";
10  cout<< " as MatrixName.mtx and MatrixName_b.mtx. If the rhs does not exist, a random one is generated. \n";
11  cout<< " If a matrix is SPD, the matrix should be named as MatrixName_SPD.mtx \n";
12  cout<< " If a true solution exists, it should be named as MatrixName_x.mtx; \n" ;
13  cout<< " it will be used to compute the norm of the error relative to the computed solutions\n\n";
14  cout<< " OPTIONS : \n";
15  cout<< " -h or --help \n print this help and return\n\n";
16  cout<< " -d matrixdir \n Use matrixdir as the matrix folder instead of the one specified in the environment variable EIGEN_MATRIXDIR\n\n";
17  cout<< " -o outputfile.xml \n Output the statistics to a xml file \n\n";
18  cout<< " --eps <RelErr> Sets the relative tolerance for iterative solvers (default 1e-08) \n\n";
19  cout<< " --maxits <MaxIts> Sets the maximum number of iterations (default 1000) \n\n";
20 
21 }
22 int main(int argc, char ** args)
23 {
24 
25  bool help = ( get_options(argc, args, "-h") || get_options(argc, args, "--help") );
26  if(help) {
28  return 0;
29  }
30 
31  // Get the location of the test matrices
32  string matrix_dir;
33  if (!get_options(argc, args, "-d", &matrix_dir))
34  {
35  if(getenv("EIGEN_MATRIXDIR") == NULL){
36  std::cerr << "Please, specify the location of the matrices with -d mat_folder or the environment variable EIGEN_MATRIXDIR \n";
37  std::cerr << " Run with --help to see the list of all the available options \n";
38  return -1;
39  }
40  matrix_dir = getenv("EIGEN_MATRIXDIR");
41  }
42 
43  std::ofstream statbuf;
44  string statFile ;
45 
46  // Get the file to write the statistics
47  bool statFileExists = get_options(argc, args, "-o", &statFile);
48  if(statFileExists)
49  {
50  statbuf.open(statFile.c_str(), std::ios::out);
51  if(statbuf.good()){
52  statFileExists = true;
53  printStatheader(statbuf);
54  statbuf.close();
55  }
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))
65  tol = atof(inval.c_str());
66  if(get_options(argc, args, "--maxits", &inval))
67  maxiters = atoi(inval.c_str());
68 
69  string current_dir;
70  // Test the real-arithmetics matrices
71  Browse_Matrices<double>(matrix_dir, statFileExists, statFile,maxiters, tol);
72 
73  // Test the complex-arithmetics matrices
74  Browse_Matrices<std::complex<double> >(matrix_dir, statFileExists, statFile, maxiters, tol);
75 
76  if(statFileExists)
77  {
78  statbuf.open(statFile.c_str(), std::ios::app);
79  statbuf << "</BENCH> \n";
80  cout << "\n Output written in " << statFile << " ...\n";
81  statbuf.close();
82  }
83 
84  return 0;
85 }
86 
87 
bench_printhelp
void bench_printhelp()
Definition: spbenchsolver.cpp:3
printStatheader
void printStatheader(std::ofstream &out)
Definition: spbenchsolver.h:96
get_options
bool get_options(int argc, char **args, string option, string *value=0)
Definition: spbenchsolver.h:562
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
spbenchsolver.h
gtsam.examples.DogLegOptimizerExample.help
help
Definition: DogLegOptimizerExample.py:112
out
std::ofstream out("Result.txt")
main
int main(int argc, char **args)
Definition: spbenchsolver.cpp:22
args
Definition: pytypes.h:2210
gtsam::tol
const G double tol
Definition: Group.h:79
NULL
#define NULL
Definition: ccolamd.c:609


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:58