From 249c48ba001f83978f84bf1befdf4867550ff6ea Mon Sep 17 00:00:00 2001 From: Deanna Hood Date: Mon, 20 Apr 2015 14:57:04 -0400 Subject: [PATCH] Incorporate C++11 check into EIGEN_HAS_C99_MATH macro --- Eigen/src/Core/MathFunctions.h | 52 ++++++++++++---------------------- Eigen/src/Core/util/Macros.h | 10 ++++--- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 944ed9417..a1ea059b7 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -804,26 +804,18 @@ bool (isfinite)(const std::complex& x) using std::imag; return isfinite(real(x)) && isfinite(imag(x)); } -#import -// Let's be conservative and enable the std::isnan implementation only if we are sure it exists -#if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \ -&& (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC) \ -|| defined(EIGEN_HAS_C99_MATH) - template - EIGEN_DEVICE_FUNC - bool (isNaN)(const T& x) - { + +template +EIGEN_DEVICE_FUNC +bool (isNaN)(const T& x) +{ + #ifdef EIGEN_HAS_C99_MATH using std::isnan; return isnan(x); - } -#else - template - EIGEN_DEVICE_FUNC - bool (isNaN)(const T& x) - { - return x == x; - } -#endif + #else + return x != x; + #endif +} template EIGEN_DEVICE_FUNC @@ -835,25 +827,17 @@ bool (isNaN)(const std::complex& x) return isnan(real(x)) || isnan(imag(x)); } -// Let's be conservative and enable the std::isinf implementation only if we are sure it exists -#if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \ -&& (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC) \ -|| defined(EIGEN_HAS_C99_MATH) - template - EIGEN_DEVICE_FUNC - bool (isInf)(const T& x) - { +template +EIGEN_DEVICE_FUNC +bool (isInf)(const T& x) +{ + #ifdef EIGEN_HAS_C99_MATH using std::isinf; return isinf(x); - } -#else - template - EIGEN_DEVICE_FUNC - bool (isInf)(const T& x) - { + #else return x>NumTraits::highest() || x::lowest(); - } -#endif + #endif +} template EIGEN_DEVICE_FUNC diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 414f688ad..7c7a3b8e7 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -403,10 +403,12 @@ #endif // Does the compiler support C99 math? -#if (EIGEN_COMP_GNUC_STRICT || \ - (EIGEN_COMP_ICC && EIGEN_COMP_GNUC) || \ - (EIGEN_COMP_CLANG) || \ - (EIGEN_COMP_MSVC >= 1800)) +#if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \ + && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC) || \ + (EIGEN_COMP_GNUC_STRICT || \ + (EIGEN_COMP_ICC && EIGEN_COMP_GNUC) || \ + (EIGEN_COMP_CLANG) || \ + (EIGEN_COMP_MSVC >= 1800)) #define EIGEN_HAS_C99_MATH 1 #endif