From e43ca0320d58587736d8bab7c6ed7212aa6b8d9d Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 11 Apr 2018 15:24:13 +0200 Subject: bug #1520: workaround some -Wfloat-equal warnings by calling std::equal_to --- Eigen/src/Core/util/Meta.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Eigen/src/Core/util/Meta.h') diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 998b8921a..e7729fdc8 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -543,6 +543,26 @@ T div_ceil(const T &a, const T &b) return (a+b-1) / b; } +// The aim of the following functions is to bypass -Wfloat-equal warnings +// when we really want a strict equality comparison on floating points. +template +bool equal_strict(const X& x,const Y& y) { return x == y; } + +template<> +bool equal_strict(const float& x,const float& y) { return std::equal_to()(x,y); } + +template<> +bool equal_strict(const double& x,const double& y) { return std::equal_to()(x,y); } + +template +bool not_equal_strict(const X& x,const Y& y) { return x != y; } + +template<> +bool not_equal_strict(const float& x,const float& y) { return std::not_equal_to()(x,y); } + +template<> +bool not_equal_strict(const double& x,const double& y) { return std::not_equal_to()(x,y); } + } // end namespace numext } // end namespace Eigen -- cgit v1.2.3