Skip to content

Commit

Permalink
Turns saturated(abs) into abs[saturated]
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Dec 13, 2023
1 parent 2ec4389 commit d402324
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 35 deletions.
4 changes: 2 additions & 2 deletions benchmarks/module/core/abs/saturated/abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ int main()
auto arg0 = eve::bench::random_<EVE_VALUE>(lmin,lmax);

eve::bench::experiment xp;
run<EVE_VALUE> (EVE_NAME(saturated(eve::abs)) , xp, eve::saturated(eve::abs), arg0);
run<EVE_TYPE> (EVE_NAME(saturated(eve::abs)) , xp, eve::saturated(eve::abs), arg0);
run<EVE_VALUE> (EVE_NAME(eve::abs[saturated]) , xp, eve::abs[saturated], arg0);
run<EVE_TYPE> (EVE_NAME(eve::abs[saturated]) , xp, eve::abs[saturated], arg0);
}
4 changes: 2 additions & 2 deletions include/eve/module/core/pedantic/impl/maxmag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ template<ordered_value T>
EVE_FORCEINLINE auto
maxmag_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, T const& b) noexcept
{
auto aa = saturated(eve::abs)(a);
auto bb = saturated(eve::abs)(b);
auto aa = eve::abs[saturated](a);
auto bb = eve::abs[saturated](b);
if constexpr( simd_value<T> )
{
auto tmp = if_else(is_not_greater_equal(aa, bb), b, pedantic(eve::max)(a, b));
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/core/pedantic/impl/minmag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ template<ordered_value T>
EVE_FORCEINLINE auto
minmag_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, T const& b) noexcept
{
auto aa = saturated(eve::abs)(a);
auto bb = saturated(eve::abs)(b);
auto aa = eve::abs[saturated](a);
auto bb = eve::abs[saturated](b);
if constexpr( simd_value<T> )
{
auto tmp = if_else(is_not_greater_equal(bb, aa), b, pedantic(eve::min)(a, b));
Expand Down
8 changes: 4 additions & 4 deletions include/eve/module/core/regular/impl/absmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ absmax_(EVE_SUPPORTS(cpu_), Ts tup) noexcept
else return eve::abs(kumi::apply( [&](auto... m) { return max(m...); }, tup));
}

template<decorator D, kumi::non_empty_product_type Ts>
template<kumi::non_empty_product_type Ts>
auto
absmax_(EVE_SUPPORTS(cpu_), D const & d, Ts tup)
absmax_(EVE_SUPPORTS(cpu_), saturated_type const& d, Ts tup)
{
if constexpr( kumi::size_v<Ts> == 1) return d(eve::abs)(get<0>(tup));
else return d(eve::abs)(kumi::apply( [&](auto... m) { return d(max)(m...); }, tup));
if constexpr( kumi::size_v<Ts> == 1) return eve::abs[d](get<0>(tup));
else return eve::abs[d](kumi::apply( [&](auto... m) { return d(max)(m...); }, tup));
}


Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/core/regular/sqr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace eve
//! square of `x` if it is representable in this type.
//!
//! @note
//! For [integral signed values](@ref eve::value) if `eve::saturated(eve::abs)(x)`
//! For [integral signed values](@ref eve::value) if `eve::abs[saturated](x)`
//! is greater than `eve::Sqrtvalmax(as(x))` the corresponding element result
//! is undefined.
//!
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace eve
//!
//! evaluates to:
//!
//! [`eve::valmax(as(x))`](@ref eve::valmax) as soon as `eve::saturated(eve::abs)(x)`
//! [`eve::valmax(as(x))`](@ref eve::valmax) as soon as `eve::abs[saturated](x)`
//! is greater than `eve::sqrtvalmax(as(x))`.
//!
//! **Example**
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/absmin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ absmin_(EVE_SUPPORTS(cpu_),
T const& a,
T const& b) noexcept requires has_native_abi_v<T>
{
return saturated(eve::abs)(eve::min(a, b));
return eve::abs[saturated](eve::min(a, b));
}

//================================================================================================
Expand All @@ -45,7 +45,7 @@ auto
absmin_(EVE_SUPPORTS(cpu_), saturated_type const&, T0 a0, T1 a1, Ts... args) noexcept
-> decltype(absmin(a0, a1, args...))
{
return saturated(eve::abs)(eve::min(a0, a1, args...));
return eve::abs[saturated](eve::min(a0, a1, args...));
}

}
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/maxabs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ maxabs_(EVE_SUPPORTS(cpu_),
T const& a,
T const& b) noexcept requires has_native_abi_v<T>
{
return eve::max(saturated(eve::abs)(a), saturated(eve::abs)(b));
return eve::max(eve::abs[saturated](a), eve::abs[saturated](b));
}

//================================================================================================
Expand All @@ -45,7 +45,7 @@ auto
maxabs_(EVE_SUPPORTS(cpu_), saturated_type const&, T0 a0, T1 a1, Ts... args) noexcept
-> decltype(maxabs(a0, a1, args...))
{
auto sa = saturated(eve::abs);
auto sa = eve::abs[saturated];
return eve::max(sa(a0), sa(a1), sa(args)...);
}
}
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/maxmag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ template<ordered_value T>
EVE_FORCEINLINE auto
maxmag_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a, T const& b) noexcept
{
auto aa = saturated(eve::abs)(a);
auto bb = saturated(eve::abs)(b);
auto aa = eve::abs[saturated](a);
auto bb = eve::abs[saturated](b);
if constexpr( simd_value<T> )
{
auto tmp = if_else(is_not_greater_equal(aa, bb), b, eve::max(a, b));
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/minabs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ minabs_(EVE_SUPPORTS(cpu_),
T const& a,
T const& b) noexcept requires has_native_abi_v<T>
{
return eve::min(saturated(eve::abs)(a), saturated(eve::abs)(b));
return eve::min(eve::abs[saturated](a), eve::abs[saturated](b));
}

//================================================================================================
Expand All @@ -45,7 +45,7 @@ auto
minabs_(EVE_SUPPORTS(cpu_), saturated_type const&, T0 a0, T1 a1, Ts... args) noexcept
-> decltype(minabs(a0, a1, args...))
{
auto sa = saturated(eve::abs);
auto sa = eve::abs[saturated];
return eve::min(sa(a0), sa(a1), sa(args)...);
}
}
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/minmag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ template<ordered_value T>
EVE_FORCEINLINE auto
minmag_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a, T const& b) noexcept
{
auto aa = saturated(eve::abs)(a);
auto bb = saturated(eve::abs)(b);
auto aa = eve::abs[saturated](a);
auto bb = eve::abs[saturated](b);
if constexpr( simd_value<T> )
{
auto tmp = if_else(is_not_greater_equal(bb, aa), b, eve::min(a, b));
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/negabsmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ negabsmax_(EVE_SUPPORTS(cpu_),
T const& a,
T const& b) noexcept requires has_native_abi_v<T>
{
return saturated(minus)(saturated(eve::abs)(eve::max(a, b)));
return saturated(minus)(eve::abs[saturated](eve::max(a, b)));
}

//================================================================================================
Expand All @@ -45,7 +45,7 @@ auto
negabsmax_(EVE_SUPPORTS(cpu_), saturated_type const&, T0 a0, T1 a1, Ts... args) noexcept
-> decltype(negabsmax(a0, a1, args...))
{
return saturated(minus)(saturated(eve::abs)(eve::max(a0, a1, args...)));
return saturated(minus)(eve::abs[saturated](eve::max(a0, a1, args...)));
}

}
4 changes: 2 additions & 2 deletions include/eve/module/core/saturated/impl/negabsmin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ negabsmin_(EVE_SUPPORTS(cpu_),
T const& a,
T const& b) noexcept requires has_native_abi_v<T>
{
return saturated(minus)(saturated(eve::abs)(eve::min(a, b)));
return saturated(minus)(eve::abs[saturated](eve::min(a, b)));
}

//================================================================================================
Expand All @@ -45,7 +45,7 @@ auto
negabsmin_(EVE_SUPPORTS(cpu_), saturated_type const&, T0 a0, T1 a1, Ts... args) noexcept
-> decltype(mul(a0, a1, args...))
{
return saturated(minus)(saturated(eve::abs)(eve::min(a0, a1, args...)));
return saturated(minus)(eve::abs[saturated](eve::min(a0, a1, args...)));
}

}
5 changes: 2 additions & 3 deletions include/eve/module/core/saturated/impl/sqr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ sqr_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a0) noexcept
if constexpr( floating_value<T> ) { return sqr(a0); }
else if constexpr( scalar_value<T> )
{
return (eve::saturated(eve::abs)(a0) > sqrtvalmax(eve::as(a0))) ? valmax(eve::as(a0))
: sqr(a0);
return (eve::abs[saturated](a0) > sqrtvalmax(eve::as(a0))) ? valmax(eve::as(a0)) : sqr(a0);
}
else
{
return if_else((saturated(abs)(a0) > sqrtvalmax(eve::as(a0))), valmax(eve::as(a0)), sqr(a0));
return if_else(eve::abs[saturated](a0) > sqrtvalmax(eve::as(a0)), valmax(eve::as(a0)), sqr(a0));
}
}
else { return apply_over(saturated(sqr), a0); }
Expand Down
2 changes: 1 addition & 1 deletion include/eve/traits/overload/default_behaviors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <eve/concept/value.hpp>
#include <eve/detail/skeleton.hpp>
#include <eve/detail/overload.hpp>
#include <eve/forward.hpp>

namespace eve
{
Expand Down
2 changes: 1 addition & 1 deletion test/doc/core/regular/deco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main()
std::cout << "---- simd" << '\n'
<< "<- pi = = " << pi << '\n'
<< "-> eve::abs(pi) = = " << eve::abs(pi) << '\n'
<< "-> eve::saturated(eve::abs)(pi) = " << eve::saturated(eve::abs)(pi) << '\n';
<< "-> eve::abs[saturated](pi) = " << eve::abs[saturated](pi) << '\n';

return 0;
}
2 changes: 1 addition & 1 deletion test/doc/core/saturated/abs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ int main()

std::cout << "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> saturated(abs)(pi) = " << eve::saturated(eve::abs)(pi) << '\n';
<< "-> eve::abs[saturated](pi) = " << eve::abs[saturated](pi) << '\n';
return 0;
}
2 changes: 1 addition & 1 deletion test/random/module/core/abs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TTS_CASE_TPL("Random check for eve::abs", eve::test::simd::all_types)
};

EVE_ULP_RANGE_CHECK ( T, eve::uniform_prng<e_t>( eve::inc(vmin), vmax ), std_abs, eve::abs );
EVE_ULP_RANGE_CHECK ( T, eve::uniform_prng<e_t>( vmin, vmax ), std_abs, eve::saturated(eve::abs) );
EVE_ULP_RANGE_CHECK ( T, eve::uniform_prng<e_t>( vmin, vmax ), std_abs, eve::abs[saturated] );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/core/negabsmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TTS_CASE_WITH("Check behavior of negabsmin on all types full range",
using eve::detail::map;
using v_t = eve::element_type_t<T>;

auto m = [](auto a, auto b, auto c) -> v_t { return eve::saturated(eve::minus)(eve::saturated(eve::abs)(eve::min(a, b, c))); };
auto m = [](auto a, auto b, auto c) -> v_t { return eve::saturated(eve::minus)(eve::abs[eve::saturated](eve::min(a, b, c))); };
TTS_ULP_EQUAL(negabsmin((a0), (a1), (a2)), map(m, a0, a1, a2), 2);
TTS_ULP_EQUAL(eve::pedantic(negabsmin)((a0), (a1), (a2)), map(m, a0, a1, a2), 2);
TTS_ULP_EQUAL(eve::numeric(negabsmin)((a0), (a1), (a2)), map(m, a0, a1, a2), 2);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/module/core/sqr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TTS_CASE_WITH("Check behavior of eve::sqr(eve::wide)",
TTS_EQUAL(saturated(sqr)(a0),
map(
[](auto e) -> v_t {
return saturated(eve::abs)(e) > eve::sqrtvalmax(as(e)) ? eve::valmax(as(e))
return eve::abs[eve::saturated](e) > eve::sqrtvalmax(as(e)) ? eve::valmax(as(e))
: e * e;
},
a0));
Expand Down

0 comments on commit d402324

Please sign in to comment.