From 0737a4594a1c2a5eb814b6da060ffcab8749d1f6 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 19 Nov 2020 07:44:42 -0500 Subject: [PATCH] better flag name and docs --- gtsam/base/Vector.cpp | 4 ++-- gtsam/base/Vector.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gtsam/base/Vector.cpp b/gtsam/base/Vector.cpp index d2f3ae868..658ab9a0d 100644 --- a/gtsam/base/Vector.cpp +++ b/gtsam/base/Vector.cpp @@ -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::max()) && - check_relative) { + check_relative_also) { return true; } diff --git a/gtsam/base/Vector.h b/gtsam/base/Vector.h index 49b7e6d9d..ed90a7126 100644 --- a/gtsam/base/Vector.h +++ b/gtsam/base/Vector.h @@ -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