Changeset 1064 for library/tests/mat_checks.cpp
- Timestamp:
- 06/09/10 14:00:40 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/mat_checks.cpp
r722 r1064 6 6 bool AreClose ( const itpp::vec &expected, const itpp::vec &actual, 7 7 double tolerance ) { 8 9 10 8 if ( expected.length() != actual.length() ) { 9 return false; 10 } 11 11 12 13 14 15 16 12 for ( int i = 0; i < expected.length(); ++i ) { 13 if ( !AreClose ( expected ( i ), actual ( i ), tolerance ) ) { 14 return false; 15 } 16 } 17 17 18 18 return true; 19 19 } 20 20 21 21 bool AreClose ( const itpp::vec &expected, const itpp::vec &actual, 22 22 const itpp::vec &tolerance ) { 23 24 25 26 23 if ( ( expected.length() != actual.length() ) || 24 ( actual.length() != tolerance.length() ) ) { 25 return false; 26 } 27 27 28 29 30 31 32 28 for ( int i = 0; i < expected.length(); ++i ) { 29 if ( !AreClose ( expected ( i ), actual ( i ), tolerance ( i ) ) ) { 30 return false; 31 } 32 } 33 33 34 34 return true; 35 35 } 36 36 37 37 bool AreClose ( const itpp::mat &expected, const itpp::mat &actual, double tolerance ) { 38 39 40 41 38 if ( ( expected.rows() != actual.rows() ) || 39 ( expected.cols() != actual.cols() ) ) { 40 return false; 41 } 42 42 43 44 45 46 47 48 49 43 for ( int i = 0; i < expected.rows(); ++i ) { 44 for ( int j = 0; j < expected.cols(); ++j ) { 45 if ( !AreClose ( expected ( i, j ), actual ( i, j ), tolerance ) ) { 46 return false; 47 } 48 } 49 } 50 50 51 51 return true; 52 52 } 53 53 … … 59 59 60 60 CurrentContext::CurrentContext ( const char *name, int idx ) { 61 62 61 config_name = name; 62 index = idx; 63 63 } 64 64 65 65 CurrentContext::~CurrentContext() { 66 67 66 config_name = "???"; 67 index = -1; 68 68 } 69 69 70 70 std::string CurrentContext::format_context ( int ln ) { 71 72 71 std::stringstream ss; 72 ss << "error at " << config_name << '[' << index << ']'; 73 73 74 75 76 74 if ( ln >= 0 ) { 75 ss << ", harness line " << ln; 76 } 77 77 78 79 78 ss << ": "; 79 return ss.str(); 80 80 }