better flag name and docs

release/4.3a0
Varun Agrawal 2020-11-19 07:44:42 -05:00
parent 50643becce
commit 0737a4594a
2 changed files with 7 additions and 5 deletions

View File

@ -39,7 +39,7 @@ namespace gtsam {
* 1. https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
* 2. https://floating-point-gui.de/errors/comparison/
* ************************************************************************* */
bool fpEqual(double a, double b, double tol, bool check_relative) {
bool fpEqual(double a, double b, double tol, bool check_relative_also) {
using std::abs;
using std::isnan;
using std::isinf;
@ -68,7 +68,7 @@ bool fpEqual(double a, double b, double tol, bool check_relative) {
// Check for relative error
else if (abs(a - b) <=
tol * min(larger, std::numeric_limits<double>::max()) &&
check_relative) {
check_relative_also) {
return true;
}

View File

@ -85,13 +85,15 @@ static_assert(
* respectively for the comparison to be true.
* If one is NaN/Inf and the other is not, returns false.
*
* The `check_relative` flag toggles checking for relative error as well. By
* default, the flag is true.
* @param check_relative_also is a flag which toggles additional checking for
* relative error. This means that if either the absolute error or the relative
* error is within the tolerance, the result will be true.
* By default, the flag is true.
*
* Return true if two numbers are close wrt tol.
*/
GTSAM_EXPORT bool fpEqual(double a, double b, double tol,
bool check_relative = true);
bool check_relative_also = true);
/**
* print without optional string, must specify cout yourself