[426] | 1 | #include "mat_checks.h" |
---|
| 2 | |
---|
[477] | 3 | namespace UnitTest { |
---|
[426] | 4 | |
---|
[477] | 5 | bool AreClose ( const itpp::vec &expected, const itpp::vec &actual, |
---|
| 6 | double tolerance ) { |
---|
| 7 | if ( expected.length() != actual.length() ) { |
---|
| 8 | return false; |
---|
| 9 | } |
---|
[428] | 10 | |
---|
[477] | 11 | for ( int i = 0; i < expected.length(); ++i ) { |
---|
| 12 | if ( !AreClose ( expected ( i ), actual ( i ), tolerance ) ) { |
---|
| 13 | return false; |
---|
| 14 | } |
---|
[428] | 15 | } |
---|
| 16 | |
---|
[477] | 17 | return true; |
---|
[428] | 18 | } |
---|
| 19 | |
---|
[477] | 20 | bool AreClose ( const itpp::vec &expected, const itpp::vec &actual, |
---|
| 21 | const itpp::vec &tolerance ) { |
---|
| 22 | if ( ( expected.length() != actual.length() ) || |
---|
| 23 | ( actual.length() != tolerance.length() ) ) { |
---|
| 24 | return false; |
---|
| 25 | } |
---|
[465] | 26 | |
---|
[477] | 27 | for ( int i = 0; i < expected.length(); ++i ) { |
---|
| 28 | if ( !AreClose ( expected ( i ), actual ( i ), tolerance ( i ) ) ) { |
---|
| 29 | return false; |
---|
| 30 | } |
---|
[465] | 31 | } |
---|
| 32 | |
---|
[477] | 33 | return true; |
---|
[465] | 34 | } |
---|
| 35 | |
---|
[477] | 36 | bool AreClose ( const itpp::mat &expected, const itpp::mat &actual, double tolerance ) { |
---|
| 37 | if ( ( expected.rows() != actual.rows() ) || |
---|
| 38 | ( expected.cols() != actual.cols() ) ) { |
---|
[426] | 39 | return false; |
---|
| 40 | } |
---|
| 41 | |
---|
[477] | 42 | for ( int i = 0; i < expected.rows(); ++i ) { |
---|
| 43 | for ( int j = 0; j < expected.cols(); ++j ) { |
---|
| 44 | if ( !AreClose ( expected ( i, j ), actual ( i, j ), tolerance ) ) { |
---|
| 45 | return false; |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | return true; |
---|
[426] | 51 | } |
---|
| 52 | |
---|
| 53 | } |
---|
[456] | 54 | |
---|
| 55 | const char *CurrentContext::config_name = "???"; |
---|
| 56 | |
---|
| 57 | int CurrentContext::index = -1; |
---|
| 58 | |
---|
[477] | 59 | CurrentContext::CurrentContext ( const char *name, int idx ) { |
---|
| 60 | config_name = name; |
---|
| 61 | index = idx; |
---|
[456] | 62 | } |
---|
| 63 | |
---|
[477] | 64 | CurrentContext::~CurrentContext() { |
---|
| 65 | config_name = "???"; |
---|
| 66 | index = -1; |
---|
[456] | 67 | } |
---|