Unify std::numeric_limits and device::numeric_limits within numext namespace

This commit is contained in:
Gael Guennebaud 2016-01-22 15:02:21 +01:00
parent 7b68cf2e0f
commit 06971223ef
2 changed files with 9 additions and 15 deletions

View File

@ -71,11 +71,7 @@ template<typename T> struct GenericNumTraits
EIGEN_DEVICE_FUNC
static inline Real epsilon()
{
#if defined(__CUDA_ARCH__)
return internal::device::numeric_limits<T>::epsilon();
#else
return std::numeric_limits<T>::epsilon();
#endif
return numext::numeric_limits<T>::epsilon();
}
EIGEN_DEVICE_FUNC
static inline Real dummy_precision()
@ -87,20 +83,12 @@ template<typename T> struct GenericNumTraits
EIGEN_DEVICE_FUNC
static inline T highest() {
#if defined(__CUDA_ARCH__)
return (internal::device::numeric_limits<T>::max)();
#else
return (std::numeric_limits<T>::max)();
#endif
return (numext::numeric_limits<T>::max)();
}
EIGEN_DEVICE_FUNC
static inline T lowest() {
#if defined(__CUDA_ARCH__)
return IsInteger ? (internal::device::numeric_limits<T>::min)() : (-(internal::device::numeric_limits<T>::max)());
#else
return IsInteger ? (std::numeric_limits<T>::min)() : (-(std::numeric_limits<T>::max)());
#endif
return IsInteger ? (numext::numeric_limits<T>::min)() : (-(numext::numeric_limits<T>::max)());
}
};

View File

@ -375,6 +375,12 @@ template<typename T> EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b =
template<typename T> EIGEN_STRONG_INLINE void swap(T &a, T &b) { std::swap(a,b); }
#endif
#if defined(__CUDA_ARCH__)
using internal::device::numeric_limits;
#else
using std::numeric_limits;
#endif
// Integer division with rounding up.
// T is assumed to be an integer type with a>=0, and b>0
template<typename T>