20 #ifndef RAJA_util_math_HPP
21 #define RAJA_util_math_HPP
23 #include "RAJA/config.hpp"
25 #include <type_traits>
39 template<typename T, std::enable_if_t<std::is_integral<T>::value>* =
nullptr>
62 template<typename T, std::enable_if_t<std::is_integral<T>::value>* =
nullptr>
66 for (
size_t s = 1; s < CHAR_BIT *
sizeof(T); s *= 2)
84 template<typename T, std::enable_if_t<std::is_integral<T>::value>* =
nullptr>
88 for (
size_t s = 1; s < CHAR_BIT *
sizeof(T); s *= 2)
100 std::enable_if_t<std::is_integral<L>::value &&
101 std::is_integral<R>::value>* =
nullptr>
105 return lhs & (rhs - R(1));
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
Definition: AlignedRangeIndexSetBuilders.cpp:35
RAJA_HOST_DEVICE constexpr RAJA_INLINE T next_pow2(T n) noexcept
"round up" to the next greatest power of 2
Definition: math.hpp:63
RAJA_HOST_DEVICE constexpr RAJA_INLINE auto power_of_2_mod(L lhs, R rhs) noexcept
compute lhs mod rhs where lhs is non-negative and rhs is a power of 2
Definition: math.hpp:102
RAJA_HOST_DEVICE constexpr RAJA_INLINE T log2(T n) noexcept
evaluate log base 2 of n
Definition: math.hpp:40
RAJA_HOST_DEVICE constexpr RAJA_INLINE T prev_pow2(T n) noexcept
"round down" to the largest power of 2 that is less than or equal to n
Definition: math.hpp:85