root/library/tests/mat_checks.cpp @ 428

Revision 428, 0.8 kB (checked in by vbarta, 15 years ago)

moved enorm tests to testsuite

Line 
1#include "mat_checks.h"
2
3namespace UnitTest
4{
5
6bool 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
21bool 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}
Note: See TracBrowser for help on using the browser.