2012-06-16 11:59:12 +08:00
|
|
|
function EQUALITY(name,expected,actual,tol)
|
2011-11-04 08:27:43 +08:00
|
|
|
% test equality of two vectors/matrices up to tolerance
|
|
|
|
|
|
|
|
if nargin<4,tol=1e-9;end
|
|
|
|
|
2012-06-21 23:56:22 +08:00
|
|
|
sameSize = size(expected)==size(actual);
|
|
|
|
if all(sameSize)
|
|
|
|
equal = abs(expected-actual)<tol;
|
2012-11-13 05:40:13 +08:00
|
|
|
if ~all(equal(:))
|
2012-06-21 23:56:22 +08:00
|
|
|
warning(['EQUALITY ' name ' fails']);
|
|
|
|
expected
|
|
|
|
actual
|
|
|
|
abs(expected-actual)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
warning(['EQUALITY ' name ' fails: non-matching size']);
|
|
|
|
size(expected)
|
|
|
|
size(actual)
|
2011-11-04 08:27:43 +08:00
|
|
|
end
|