summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/matlab/selfCheck.m
blob: 55c8de8cce4162d703df13f49b91c655ee2070d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function ret = selfCheck(in1, path, tol)

r1 = size(in1, 1);
c1 = size(in1, 2);

ret = 1;

file = [path, '/expected.m'];
fd = fopen(file, 'r');

[in2, count] = fscanf(fd, '%d');

if(count ~= (r1*c1) )
    fprintf(1, 'Dimensions mismatch: Expected %d\t Observed %d\n', count, (r1*c1));
    ret = -1;
else
    ret = 1;
    for i=1:(r1*c1)
        if( (abs(in1(i)) - abs(in2(i)) > tol) || (abs(in2(i)) - abs(in1(i))) > tol)
            fprintf(1, 'Checking Error: Index %d\tExpected %d\tObserved %d\n', i, in2(i), in1(i));
            ret = -1;
            break;
        end
    end

end