Changeset 292


Ignore:
Timestamp:
Apr 22, 2005, 12:15:45 PM (18 years ago)
Author:
Peter
Message:

enabled printouts from failure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/test_nni.cc

    r290 r292  
    2121int main(const int argc,const char* argv[])
    2222{
    23   bool print=false;
    24   if (argc>1 && argv[1]==std::string("-p"))
    25     print=true;
    26 
     23  bool print = (argc>1 && argv[1]==std::string("-p"));
    2724  bool ok = true;
    2825  uint neighbours=3;
     
    4946  theplu::gslapi::matrix control(control_stream);
    5047  control-=knni.imputed_data();
     48  // Jari, should we use GSL defined round off errors? Anyway, the
     49  // hardcoded number below should be changed.
     50  double error_bound = 5e-13;
    5151  for (unsigned int i=0; i<control.rows(); i++)
    5252    for (unsigned int j=0; j<control.columns(); j++)
    53       // Jari, should we use GSL defined round off errors? Anyway, the
    54       // hardcoded number below should be changed.
    55       if (fabs(control(i,j))>5e-13) {
     53      if (fabs(control(i,j))>error_bound) {
    5654        if (print)
    57           std::cerr << "test_nni: kNNI FAILED, cannot reproduce test result\n";
     55          std::cerr << "kNNI FAILED, error on row " << i << " and "
     56                    << "column " << j << " is " << fabs(control(i,j))
     57                    << ". Expected less than " << error_bound << std::endl;
    5858        ok=false; // calculation result out of accepted error bounds
    5959      }
    6060      else
    6161        if (!((control(i,j)==control(i,j)))) {
    62           if (print){
    63             std::cerr << "test_nni: kNNI FAILED, nan (not a number) "
    64                       << "encountered in test\n";
    65           }
     62          if (print)
     63            std::cerr << "kNNI FAILED, nan (not a number) "
     64                      << "encountered in test on row " << i
     65                      << " and column " << j << std::endl;
    6666          ok =false; // calucaltion error detected
    6767        }
     
    8383      // Jari, should we use GSL defined round off errors? Anyway, the
    8484      // hardcoded number below should be changed.
    85       if (fabs(control(i,j))>5e-13) {
     85      if (fabs(control(i,j))>error_bound) {
    8686        if (print)
    87           std::cerr << "test_nni: WeNNI FAILED, cannot reproduce test result\n";
     87          std::cerr << "WeNNI FAILED, error on row " << i << " and "
     88                    << "column " << j << " is " << fabs(control(i,j))
     89                    << ". Expected less than " << error_bound << std::endl;
    8890        ok=false; // calculation result out of accepted error bounds
    8991      }
    9092      else
    9193        if (!((control(i,j)==control(i,j)))) {
    92           if (print) {
    93             std::cerr << "test_nni: WeNNI FAILED, nan (not a number) "
    94                       << "encountered in test\n";
    95           }
     94          if (print)
     95            std::cerr << "WeNNI FAILED, nan (not a number) "
     96                      << "encountered in test on row " << i
     97                      << " and column " << j << std::endl;
    9698          ok=false; // calucaltion error detected
    9799        }
Note: See TracChangeset for help on using the changeset viewer.