Skip to content

Commit

Permalink
Supports integral power in eve::powm1 and eve::pow1p
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Sep 3, 2023
1 parent c7f4009 commit f53e249
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions include/eve/module/math/regular/impl/pow1p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@

namespace eve::detail
{
template<floating_ordered_value T, floating_ordered_value U>
template<floating_ordered_value T, ordered_value U>
auto
pow1p_(EVE_SUPPORTS(cpu_), T const& a, U const& b) noexcept
-> decltype(pow(a, b))
{
return arithmetic_call(pow1p, a, b);
if constexpr(integral_value<U>)
return pow(dec(a), b);
else
return arithmetic_call(pow1p, a, b);
}

template<floating_ordered_value T>
Expand Down
9 changes: 6 additions & 3 deletions include/eve/module/math/regular/impl/powm1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@

namespace eve::detail
{
template<floating_ordered_value T, floating_ordered_value U>
template<floating_ordered_value T, ordered_value U>
auto
powm1_(EVE_SUPPORTS(cpu_), T const& a, U const& b) noexcept
-> decltype(pow(a, b))
{
return arithmetic_call(powm1, a, b);
if constexpr(integral_value<U>)
return dec(pow(a, b));
else
return arithmetic_call(powm1, a, b);
}

template<floating_ordered_value T>
template<ordered_value T>
auto
powm1_(EVE_SUPPORTS(cpu_), T const& x, T const& y) noexcept
{
Expand Down
2 changes: 2 additions & 0 deletions test/unit/module/math/pow1p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ TTS_CASE_TPL("Check return types of pow1p", eve::test::simd::ieee_reals)
TTS_EXPR_IS(eve::pow1p(v_t(), v_t()), v_t);
TTS_EXPR_IS(eve::pow1p(T(), v_t()), T);
TTS_EXPR_IS(eve::pow1p(v_t(), T()), T);
TTS_EXPR_IS(eve::pow1p(v_t(), int()), v_t);
TTS_EXPR_IS(eve::pow1p(T(), int()), T);
};

//==================================================================================================
Expand Down
3 changes: 2 additions & 1 deletion test/unit/module/math/powm1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ TTS_CASE_TPL("Check return types of powm1", eve::test::simd::ieee_reals)
TTS_EXPR_IS(eve::powm1(T(), T()), T);
TTS_EXPR_IS(eve::powm1(v_t(), v_t()), v_t);
TTS_EXPR_IS(eve::powm1(T(), v_t()), T);
};
TTS_EXPR_IS(eve::powm1(v_t(), int()), v_t);
TTS_EXPR_IS(eve::powm1(T(), int()), T);};

//==================================================================================================
// powm1 tests
Expand Down

0 comments on commit f53e249

Please sign in to comment.