gtsam/matlab/+gtsam/EQUALITY.m

20 lines
466 B
Matlab
Raw Normal View History

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
sameSize = size(expected)==size(actual);
if all(sameSize)
equal = abs(expected-actual)<tol;
if ~all(equal(:))
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