diff options
author | Gael Guennebaud <g.gael@free.fr> | 2017-06-09 11:53:49 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2017-06-09 11:53:49 +0200 |
commit | 498aa95a8b2b505c919efff8857a6fd2a5bbc172 (patch) | |
tree | 37423f1ea652aefd0b7f22e41722be76cb2d77fd /Eigen/src/Core/MathFunctions.h | |
parent | d58882277999508b1b97624771433422897e9aee (diff) |
bug #1424: add numext::abs specialization for unsigned integer types.
Diffstat (limited to 'Eigen/src/Core/MathFunctions.h')
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 5ec6c395e..0be4a25da 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -1232,11 +1232,19 @@ double log(const double &x) { return ::log(x); } template<typename T> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE -typename NumTraits<T>::Real abs(const T &x) { +typename internal::enable_if<NumTraits<T>::IsSigned || NumTraits<T>::IsComplex,typename NumTraits<T>::Real>::type +abs(const T &x) { EIGEN_USING_STD_MATH(abs); return abs(x); } +template<typename T> +EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE +typename internal::enable_if<!(NumTraits<T>::IsSigned || NumTraits<T>::IsComplex),typename NumTraits<T>::Real>::type +abs(const T &x) { + return x; +} + #if defined(__SYCL_DEVICE_ONLY__) EIGEN_ALWAYS_INLINE float abs(float x) { return cl::sycl::fabs(x); } EIGEN_ALWAYS_INLINE double abs(double x) { return cl::sycl::fabs(x); } |