Revision 426, 465 bytes
(checked in by vbarta, 15 years ago)
|
added unit & stress tests for ldmat & chmat (as well as other descendants of square_mat)
|
Line | |
---|
1 | #include "mat_checks.h" |
---|
2 | |
---|
3 | namespace UnitTest |
---|
4 | { |
---|
5 | |
---|
6 | bool AreClose(const itpp::mat &expected, const itpp::mat &actual, double tolerance) { |
---|
7 | if ((expected.rows() != actual.rows()) || |
---|
8 | (expected.cols() != actual.cols())) { |
---|
9 | return false; |
---|
10 | } |
---|
11 | |
---|
12 | for (int i = 0; i < expected.rows(); ++i) { |
---|
13 | for (int j = 0; j < expected.cols(); ++j) { |
---|
14 | if (!AreClose(expected(i, j), actual(i, j), tolerance)) { |
---|
15 | return false; |
---|
16 | } |
---|
17 | } |
---|
18 | } |
---|
19 | |
---|
20 | return true; |
---|
21 | } |
---|
22 | |
---|
23 | } |
---|