Changeset 292
- Timestamp:
- Apr 22, 2005, 12:15:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/test_nni.cc
r290 r292 21 21 int main(const int argc,const char* argv[]) 22 22 { 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")); 27 24 bool ok = true; 28 25 uint neighbours=3; … … 49 46 theplu::gslapi::matrix control(control_stream); 50 47 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; 51 51 for (unsigned int i=0; i<control.rows(); i++) 52 52 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) { 56 54 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; 58 58 ok=false; // calculation result out of accepted error bounds 59 59 } 60 60 else 61 61 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; 66 66 ok =false; // calucaltion error detected 67 67 } … … 83 83 // Jari, should we use GSL defined round off errors? Anyway, the 84 84 // hardcoded number below should be changed. 85 if (fabs(control(i,j))> 5e-13) {85 if (fabs(control(i,j))>error_bound) { 86 86 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; 88 90 ok=false; // calculation result out of accepted error bounds 89 91 } 90 92 else 91 93 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; 96 98 ok=false; // calucaltion error detected 97 99 }
Note: See TracChangeset
for help on using the changeset viewer.