Add numeric_limits min and max for bool

This will allow (among other things) computation of argmax and argmin of bool tensors
This commit is contained in:
Akshay Naresh Modi 2020-04-06 23:38:57 +00:00 committed by Rasmus Munk Larsen
parent 54a0a9c9dd
commit bcc0e9e15c
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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; }
};
}