Revision 428, 0.8 kB
(checked in by vbarta, 15 years ago)
|
moved enorm tests to testsuite
|
Line | |
---|
1 | #include "mat_checks.h" |
---|
2 | |
---|
3 | namespace UnitTest |
---|
4 | { |
---|
5 | |
---|
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 | |
---|
21 | bool AreClose(const itpp::mat &expected, const itpp::mat &actual, double tolerance) { |
---|
22 | if ((expected.rows() != actual.rows()) || |
---|
23 | (expected.cols() != actual.cols())) { |
---|
24 | return false; |
---|
25 | } |
---|
26 | |
---|
27 | for (int i = 0; i < expected.rows(); ++i) { |
---|
28 | for (int j = 0; j < expected.cols(); ++j) { |
---|
29 | if (!AreClose(expected(i, j), actual(i, j), tolerance)) { |
---|
30 | return false; |
---|
31 | } |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | return true; |
---|
36 | } |
---|
37 | |
---|
38 | } |
---|