22#ifndef UTILS_MATH_INT_POW_HPP
23#define UTILS_MATH_INT_POW_HPP
31template <
class T,
unsigned n,
class =
void>
struct int_pow_impl {
33 return x * int_pow_impl<T, (n - 1) / 2>{}(x * x);
38template <
class T,
unsigned n>
39struct int_pow_impl<T, n, std::enable_if_t<n % 2 == 0>> {
41 return int_pow_impl<T, n / 2>{}(x * x);
45template <
class T>
struct int_pow_impl<T, 1> {
49template <
class T>
struct int_pow_impl<T, 0> {
62 return detail::int_pow_impl<T, n>{}(x);
DEVICE_QUALIFIER constexpr T int_pow(T x)
Calculate integer powers.