root/library/tests/mat_checks.cpp @ 477

Revision 477, 1.4 kB (checked in by mido, 15 years ago)

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

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