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