17 #ifndef KOKKOS_NUMERIC_TRAITS_HPP
18 #define KOKKOS_NUMERIC_TRAITS_HPP
19 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE
21 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_NUMERIC_TRAITS
24 #include <Kokkos_Macros.hpp>
25 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
26 #include <Kokkos_ReductionIdentity.hpp>
28 #include <type_traits>
31 namespace Kokkos::Experimental {
33 #define KOKKOS_IMPL_DEFINE_TRAIT(TRAIT, NUMERIC_LIMITS_MEMBER, CONSTRAINT) \
35 template <class T, class Enable = void> \
36 struct TRAIT##_helper {}; \
38 struct TRAIT##_helper<T, std::enable_if_t<std::is_##CONSTRAINT##_v<T>>> { \
39 static constexpr auto value = \
40 std::numeric_limits<T>::NUMERIC_LIMITS_MEMBER; \
44 struct TRAIT : Impl::TRAIT##_helper<T> {}; \
46 inline constexpr auto TRAIT##_v = TRAIT<T>::value;
50 KOKKOS_IMPL_DEFINE_TRAIT(infinity, infinity(), floating_point)
51 KOKKOS_IMPL_DEFINE_TRAIT(finite_min, lowest(), arithmetic )
52 KOKKOS_IMPL_DEFINE_TRAIT(finite_max, max(), arithmetic )
53 KOKKOS_IMPL_DEFINE_TRAIT(epsilon, epsilon(), floating_point)
54 KOKKOS_IMPL_DEFINE_TRAIT(round_error, round_error(), floating_point)
55 KOKKOS_IMPL_DEFINE_TRAIT(norm_min, min(), floating_point)
56 KOKKOS_IMPL_DEFINE_TRAIT(denorm_min, denorm_min(), floating_point)
57 KOKKOS_IMPL_DEFINE_TRAIT(quiet_NaN, quiet_NaN(), floating_point)
58 KOKKOS_IMPL_DEFINE_TRAIT(signaling_NaN, signaling_NaN(), floating_point)
61 KOKKOS_IMPL_DEFINE_TRAIT(digits, digits, arithmetic )
62 KOKKOS_IMPL_DEFINE_TRAIT(digits10, digits10, arithmetic )
63 KOKKOS_IMPL_DEFINE_TRAIT(max_digits10, max_digits10, floating_point)
64 KOKKOS_IMPL_DEFINE_TRAIT(radix, radix, arithmetic )
65 KOKKOS_IMPL_DEFINE_TRAIT(min_exponent, min_exponent, floating_point)
66 KOKKOS_IMPL_DEFINE_TRAIT(min_exponent10, min_exponent10, floating_point)
67 KOKKOS_IMPL_DEFINE_TRAIT(max_exponent, max_exponent, floating_point)
68 KOKKOS_IMPL_DEFINE_TRAIT(max_exponent10, max_exponent10, floating_point)
71 #undef KOKKOS_IMPL_DEFINE_TRAIT
75 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_NUMERIC_TRAITS
76 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
77 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_NUMERIC_TRAITS