diff options
author | Akshay Naresh Modi <nareshmodi@google.com> | 2020-04-06 23:38:57 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-04-06 23:38:57 +0000 |
commit | bcc0e9e15ceb2fc90acb64843bd2d6161d5f0c71 (patch) | |
tree | ac1bf5b6f31b1fdd083cc60f0ea4c2d12b90418d | |
parent | 54a0a9c9dd83aad42e79238ec8f0932b2a5e7881 (diff) |
Add numeric_limits min and max for bool
This will allow (among other things) computation of argmax and argmin of bool tensors
-rw-r--r-- | Eigen/src/Core/NumTraits.h | 2 | ||||
-rwxr-xr-x | Eigen/src/Core/util/Meta.h | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Eigen/src/Core/NumTraits.h b/Eigen/src/Core/NumTraits.h index 12a7cde6b..80f909630 100644 --- a/Eigen/src/Core/NumTraits.h +++ b/Eigen/src/Core/NumTraits.h @@ -284,6 +284,8 @@ private: // Empty specialization for void to allow template specialization based on NumTraits<T>::Real with T==void and SFINAE. template<> struct NumTraits<void> {}; +template<> NumTraits<bool> : GenericNumTraits<bool> {}; + } // end namespace Eigen #endif // EIGEN_NUMTRAITS_H diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 301077fab..e9e2f1873 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -359,6 +359,15 @@ template<> struct numeric_limits<unsigned long long> EIGEN_DEVICE_FUNC static unsigned long long (min)() { return 0; } }; +template<> struct numeric_limits<bool> +{ + EIGEN_DEVICE_FUNC + static bool epsilon() { return false; } + EIGEN_DEVICE_FUNC + static bool (max)() { return true; } + EIGEN_DEVICE_FUNC + static bool (min)() { return false; } +}; } |