acado/acado — pull request #37 by roryyorke (2013-07-18 17:55:10+00:00)
Title: Isequal uses fabs 2

Code previously used maximum of signed arguments to decide whether to
use relative or absolute tolerance check. If this function is to also
be used to compare negative numbers of large magnitude, the absolute
value of its arguments should be used.

Before the fix, this code

#include "acado_toolkit.hpp"

int main()
{
std::cout << ACADO::acadoIsEqual(10000,10000+1e-7) << "\n";
std::cout << ACADO::acadoIsEqual(10000,10000-1e-7) << "\n";
std::cout << ACADO::acadoIsEqual(-10000,-10000+1e-7) << "\n";
std::cout << ACADO::acadoIsEqual(-10000,-10000-1e-7) << "\n";
}

produces this:

1
1
0
0

and after it produces this:

1
1
1
1