Skip to content

Commit

Permalink
average modified to fit cayley-dickson
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Aug 27, 2023
1 parent eac3271 commit 40be733
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/eve/module/core/regular/impl/average.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ average_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept
{
if constexpr(has_native_abi_v<T>)
{
if constexpr( integral_value<T> ) return (a & b) + ((a ^ b) >> 1); //compute ceil( (x+y)/2 )
else return fma(a, half(eve::as(a)), b * half(eve::as(a)));
if constexpr( integral_value<T> )
return (a & b) + ((a ^ b) >> 1); //compute ceil( (x+y)/2 )
else
{
using u_t = underlying_type_t<T>;
const auto h = eve::half(eve::as<u_t>());
return fma(a, h, b * h);
}
}
else return apply_over(average, a, b);
}
Expand Down

0 comments on commit 40be733

Please sign in to comment.