- Timestamp:
- Dec 22, 2008, 4:00:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/nni_test.cc
r1554 r1669 72 72 std::ifstream control_stream(knni_result.c_str()); 73 73 utility::Matrix control(control_stream); 74 control-=knni.imputed_data(); 75 // error_bound is arbitrarily selected 76 double error_bound = std::numeric_limits<double>::epsilon()*1e4; 74 double error_bound = 1e-11; 77 75 for (unsigned int i=0; i<control.rows(); i++) 78 76 for (unsigned int j=0; j<control.columns(); j++) 79 if ( std::abs(control(i,j))>error_bound) {77 if (!suite.equal_fix(knni.imputed_data()(i,j),control(i,j),error_bound)) { 80 78 suite.err() << "kNNI FAILED, error on row " << i << " and " 81 << "column " << j << " is " << std::abs(control(i,j)) 82 << ". Expected less than " << error_bound << std::endl; 79 << "column " << j << " is" << std::endl; 83 80 suite.add(false); // calculation result out of accepted error bounds 84 81 } 85 else86 if (!((control(i,j)==control(i,j)))) {87 suite.err() << "kNNI FAILED, nan (not a number) "88 << "encountered in test on row " << i89 << " and column " << j << std::endl;90 suite.add(false); // calucaltion error detected91 }92 82 control_stream.close(); 93 83 data_stream.close(); … … 103 93 control_stream.open(wenni_result.c_str()); 104 94 control=utility::Matrix(control_stream); 105 control-=wenni.imputed_data();106 95 for (unsigned int i=0; i<control.rows(); i++) 107 96 for (unsigned int j=0; j<control.columns(); j++) 108 if ( std::abs(control(i,j))>error_bound){97 if (!suite.equal_fix(wenni.imputed_data()(i,j),control(i,j),error_bound)){ 109 98 suite.err() << "WeNNI FAILED, error on row " << i << " and " 110 << "column " << j << " is " << std::abs(control(i,j)) 111 << ". Expected less than " << error_bound << std::endl; 99 << "column " << j << std::endl; 112 100 suite.add(false); // calculation result out of accepted error bounds 113 101 } 114 else115 if (!((control(i,j)==control(i,j)))) {116 suite.err() << "WeNNI FAILED, nan (not a number) "117 << "encountered in test on row " << i118 << " and column " << j << std::endl;119 suite.add(false); // calucaltion error detected120 }121 102 control_stream.close(); 122 103 data_stream.close(); … … 132 113 control_stream.open(knni_result.c_str()); 133 114 control=utility::Matrix(control_stream); 134 control-=wenni2.imputed_data();135 115 for (unsigned int i=0; i<control.rows(); i++) 136 116 for (unsigned int j=0; j<control.columns(); j++) 137 if ( std::abs(control(i,j))>error_bound){117 if (!suite.equal_fix(wenni2.imputed_data()(i,j),control(i,j),error_bound)){ 138 118 suite.err() << "WeNNI binary weight test FAILED.\nError on row " << i 139 << " and column " << j << " is " << std::abs(control(i,j)) 140 << ". Expected less than " << error_bound << std::endl; 119 << " and column " << j << std::endl; 141 120 suite.add(false); // calculation result out of accepted error bounds 142 121 } 143 else144 if (!((control(i,j)==control(i,j)))) {145 suite.err() << "WeNNI binary wieght test FAILED.\n"146 << "nan (not a number) encountered in test on row " << i147 << " and column " << j << std::endl;148 suite.add(false); // calucaltion error detected149 }150 122 control_stream.close(); 151 123 data_stream.close();
Note: See TracChangeset
for help on using the changeset viewer.