29 #ifndef PIRANHA_DETAIL_MONOMIAL_COMMON_HPP 30 #define PIRANHA_DETAIL_MONOMIAL_COMMON_HPP 33 #include <type_traits> 36 #include <piranha/config.hpp> 37 #include <piranha/math.hpp> 38 #include <piranha/mp_integer.hpp> 39 #include <piranha/safe_cast.hpp> 53 template <
typename T,
typename U>
54 using monomial_pow_dispatcher = disjunction_idx<
56 conjunction<std::is_integral<T>, std::is_integral<U>>,
58 conjunction<std::is_same<T, U>, has_mul3<U>>,
60 std::is_same<detected_t<mul_t, T, U>, T>,
63 has_safe_cast<T, detected_t<mul_t, T, U>>>;
66 template <
typename T,
typename U>
67 inline void monomial_pow_mult_exp(T &ret,
const T &exp,
const U &x,
const std::integral_constant<std::size_t, 0u> &)
71 PIRANHA_MAYBE_TLS
integer tmp1, tmp2, tmp3;
74 mul(tmp3, tmp1, tmp2);
78 ret =
static_cast<T
>(tmp3);
82 template <
typename T,
typename U>
83 inline void monomial_pow_mult_exp(T &ret,
const T &exp,
const U &x,
const std::integral_constant<std::size_t, 1u> &)
89 template <
typename T,
typename U>
90 inline void monomial_pow_mult_exp(T &ret,
const T &exp,
const U &x,
const std::integral_constant<std::size_t, 2u> &)
96 template <
typename T,
typename U>
97 inline void monomial_pow_mult_exp(T &ret,
const T &exp,
const U &x,
const std::integral_constant<std::size_t, 3u> &)
103 #if defined(PIRANHA_COMPILER_IS_GCC) 104 #pragma GCC diagnostic push 105 #pragma GCC diagnostic ignored "-Wconversion" 108 #if defined(PIRANHA_COMPILER_IS_GCC) 109 #pragma GCC diagnostic pop 114 template <
typename T,
typename U>
115 using monomial_pow_enabler = enable_if_t<(monomial_pow_dispatcher<T, U>::value < 4u),
int>;
mp_integer< 1 > integer
Alias for piranha::mp_integer with 1 limb of static storage.
auto mul3(T &a, const T &b, const T &c) -> decltype(mul3_impl< T >()(a, b, c))
Ternary multiplication.
safe_cast_type< To, From > safe_cast(const From &x)
Safe cast.