From 2475a1de48cb6f602ab7340d1e1afad15754a103 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 27 Oct 2015 15:39:50 +0100 Subject: bug #1008: stabilize isfinite/isinf/isnan/hasNaN/allFinite functions for fast-math mode. --- Eigen/src/Core/BooleanRedux.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Eigen/src/Core/BooleanRedux.h') diff --git a/Eigen/src/Core/BooleanRedux.h b/Eigen/src/Core/BooleanRedux.h index ba45cf5c3..be4cd9b3a 100644 --- a/Eigen/src/Core/BooleanRedux.h +++ b/Eigen/src/Core/BooleanRedux.h @@ -142,7 +142,11 @@ inline Eigen::Index DenseBase::count() const template inline bool DenseBase::hasNaN() const { +#if EIGEN_COMP_MSVC || (defined __FAST_MATH__) + return derived().array().isNaN().any(); +#else return !((derived().array()==derived().array()).all()); +#endif } /** \returns true if \c *this contains only finite numbers, i.e., no NaN and no +/-INF values. @@ -152,7 +156,11 @@ inline bool DenseBase::hasNaN() const template inline bool DenseBase::allFinite() const { +#if EIGEN_COMP_MSVC || (defined __FAST_MATH__) + return derived().array().isFinite().all(); +#else return !((derived()-derived()).hasNaN()); +#endif } } // end namespace Eigen -- cgit v1.2.3