mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 04:09:10 +08:00
Only use std::isnan and std::isinf if they are available
This commit is contained in:
parent
085aa8e601
commit
0339502a4f
@ -790,14 +790,26 @@ bool (isfinite)(const std::complex<T>& x)
|
|||||||
using std::imag;
|
using std::imag;
|
||||||
return isfinite(real(x)) && isfinite(imag(x));
|
return isfinite(real(x)) && isfinite(imag(x));
|
||||||
}
|
}
|
||||||
|
#import <iostream>
|
||||||
template<typename T>
|
// Let's be conservative and enable the std::isnan implementation only if we are sure it exists
|
||||||
EIGEN_DEVICE_FUNC
|
#if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
|
||||||
bool (isNaN)(const T& x)
|
&& (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC) \
|
||||||
{
|
|| defined(EIGEN_HAS_C99_MATH)
|
||||||
using std::isnan;
|
template<typename T>
|
||||||
return isnan(x);
|
EIGEN_DEVICE_FUNC
|
||||||
}
|
bool (isNaN)(const T& x)
|
||||||
|
{
|
||||||
|
using std::isnan;
|
||||||
|
return isnan(x);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template<typename T>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
bool (isNaN)(const T& x)
|
||||||
|
{
|
||||||
|
return x == x;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
@ -809,13 +821,25 @@ bool (isNaN)(const std::complex<T>& x)
|
|||||||
return isnan(real(x)) || isnan(imag(x));
|
return isnan(real(x)) || isnan(imag(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
// Let's be conservative and enable the std::isinf implementation only if we are sure it exists
|
||||||
EIGEN_DEVICE_FUNC
|
#if (__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
|
||||||
bool (isInf)(const T& x)
|
&& (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC) \
|
||||||
{
|
|| defined(EIGEN_HAS_C99_MATH)
|
||||||
using std::isinf;
|
template<typename T>
|
||||||
return isinf(x);
|
EIGEN_DEVICE_FUNC
|
||||||
}
|
bool (isInf)(const T& x)
|
||||||
|
{
|
||||||
|
using std::isinf;
|
||||||
|
return isinf(x);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template<typename T>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
bool (isInf)(const T& x)
|
||||||
|
{
|
||||||
|
return x>NumTraits<T>::highest() || x<NumTraits<T>::lowest();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
|
@ -398,6 +398,14 @@
|
|||||||
#define EIGEN_HAS_CONSTEXPR 1
|
#define EIGEN_HAS_CONSTEXPR 1
|
||||||
#endif
|
#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))
|
||||||
|
#define EIGEN_HAS_C99_MATH 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Allows to disable some optimizations which might affect the accuracy of the result.
|
/** Allows to disable some optimizations which might affect the accuracy of the result.
|
||||||
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
|
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
|
||||||
* They currently include:
|
* They currently include:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user