From d40232423a6fd1beed600e72c2473a1dcd20f1e2 Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Sun, 10 Dec 2023 21:57:47 +0100 Subject: [PATCH] Turns saturated(abs) into abs[saturated] --- benchmarks/module/core/abs/saturated/abs.hpp | 4 ++-- include/eve/module/core/pedantic/impl/maxmag.hpp | 4 ++-- include/eve/module/core/pedantic/impl/minmag.hpp | 4 ++-- include/eve/module/core/regular/impl/absmax.hpp | 8 ++++---- include/eve/module/core/regular/sqr.hpp | 4 ++-- include/eve/module/core/saturated/impl/absmin.hpp | 4 ++-- include/eve/module/core/saturated/impl/maxabs.hpp | 4 ++-- include/eve/module/core/saturated/impl/maxmag.hpp | 4 ++-- include/eve/module/core/saturated/impl/minabs.hpp | 4 ++-- include/eve/module/core/saturated/impl/minmag.hpp | 4 ++-- include/eve/module/core/saturated/impl/negabsmax.hpp | 4 ++-- include/eve/module/core/saturated/impl/negabsmin.hpp | 4 ++-- include/eve/module/core/saturated/impl/sqr.hpp | 5 ++--- include/eve/traits/overload/default_behaviors.hpp | 2 +- test/doc/core/regular/deco.cpp | 2 +- test/doc/core/saturated/abs.cpp | 2 +- test/random/module/core/abs.cpp | 2 +- test/unit/module/core/negabsmin.cpp | 2 +- test/unit/module/core/sqr.cpp | 2 +- 19 files changed, 34 insertions(+), 35 deletions(-) diff --git a/benchmarks/module/core/abs/saturated/abs.hpp b/benchmarks/module/core/abs/saturated/abs.hpp index ef6e6b45d1..0c5a04851d 100644 --- a/benchmarks/module/core/abs/saturated/abs.hpp +++ b/benchmarks/module/core/abs/saturated/abs.hpp @@ -16,6 +16,6 @@ int main() auto arg0 = eve::bench::random_(lmin,lmax); eve::bench::experiment xp; - run (EVE_NAME(saturated(eve::abs)) , xp, eve::saturated(eve::abs), arg0); - run (EVE_NAME(saturated(eve::abs)) , xp, eve::saturated(eve::abs), arg0); + run (EVE_NAME(eve::abs[saturated]) , xp, eve::abs[saturated], arg0); + run (EVE_NAME(eve::abs[saturated]) , xp, eve::abs[saturated], arg0); } diff --git a/include/eve/module/core/pedantic/impl/maxmag.hpp b/include/eve/module/core/pedantic/impl/maxmag.hpp index cdaa60884f..2109f5225d 100644 --- a/include/eve/module/core/pedantic/impl/maxmag.hpp +++ b/include/eve/module/core/pedantic/impl/maxmag.hpp @@ -39,8 +39,8 @@ template 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 ) { auto tmp = if_else(is_not_greater_equal(aa, bb), b, pedantic(eve::max)(a, b)); diff --git a/include/eve/module/core/pedantic/impl/minmag.hpp b/include/eve/module/core/pedantic/impl/minmag.hpp index d22b0a3e0f..b2d0810ea4 100644 --- a/include/eve/module/core/pedantic/impl/minmag.hpp +++ b/include/eve/module/core/pedantic/impl/minmag.hpp @@ -39,8 +39,8 @@ template 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 ) { auto tmp = if_else(is_not_greater_equal(bb, aa), b, pedantic(eve::min)(a, b)); diff --git a/include/eve/module/core/regular/impl/absmax.hpp b/include/eve/module/core/regular/impl/absmax.hpp index b2d2f48f66..b273885cf7 100644 --- a/include/eve/module/core/regular/impl/absmax.hpp +++ b/include/eve/module/core/regular/impl/absmax.hpp @@ -77,12 +77,12 @@ absmax_(EVE_SUPPORTS(cpu_), Ts tup) noexcept else return eve::abs(kumi::apply( [&](auto... m) { return max(m...); }, tup)); } -template +template 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 == 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 == 1) return eve::abs[d](get<0>(tup)); + else return eve::abs[d](kumi::apply( [&](auto... m) { return d(max)(m...); }, tup)); } diff --git a/include/eve/module/core/regular/sqr.hpp b/include/eve/module/core/regular/sqr.hpp index 6c2c7bc01f..8f3eba5580 100644 --- a/include/eve/module/core/regular/sqr.hpp +++ b/include/eve/module/core/regular/sqr.hpp @@ -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. //! @@ -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** diff --git a/include/eve/module/core/saturated/impl/absmin.hpp b/include/eve/module/core/saturated/impl/absmin.hpp index 31c0549271..b3ada95612 100644 --- a/include/eve/module/core/saturated/impl/absmin.hpp +++ b/include/eve/module/core/saturated/impl/absmin.hpp @@ -34,7 +34,7 @@ absmin_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v { - return saturated(eve::abs)(eve::min(a, b)); + return eve::abs[saturated](eve::min(a, b)); } //================================================================================================ @@ -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...)); } } diff --git a/include/eve/module/core/saturated/impl/maxabs.hpp b/include/eve/module/core/saturated/impl/maxabs.hpp index ec7fa1a3ed..5738361d32 100644 --- a/include/eve/module/core/saturated/impl/maxabs.hpp +++ b/include/eve/module/core/saturated/impl/maxabs.hpp @@ -34,7 +34,7 @@ maxabs_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v { - return eve::max(saturated(eve::abs)(a), saturated(eve::abs)(b)); + return eve::max(eve::abs[saturated](a), eve::abs[saturated](b)); } //================================================================================================ @@ -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)...); } } diff --git a/include/eve/module/core/saturated/impl/maxmag.hpp b/include/eve/module/core/saturated/impl/maxmag.hpp index f57a3bfc5d..107c5038ee 100644 --- a/include/eve/module/core/saturated/impl/maxmag.hpp +++ b/include/eve/module/core/saturated/impl/maxmag.hpp @@ -35,8 +35,8 @@ template 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 ) { auto tmp = if_else(is_not_greater_equal(aa, bb), b, eve::max(a, b)); diff --git a/include/eve/module/core/saturated/impl/minabs.hpp b/include/eve/module/core/saturated/impl/minabs.hpp index a05f27b50b..4a9af11e72 100644 --- a/include/eve/module/core/saturated/impl/minabs.hpp +++ b/include/eve/module/core/saturated/impl/minabs.hpp @@ -34,7 +34,7 @@ minabs_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v { - return eve::min(saturated(eve::abs)(a), saturated(eve::abs)(b)); + return eve::min(eve::abs[saturated](a), eve::abs[saturated](b)); } //================================================================================================ @@ -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)...); } } diff --git a/include/eve/module/core/saturated/impl/minmag.hpp b/include/eve/module/core/saturated/impl/minmag.hpp index 7a4dd29cec..43e7095cca 100644 --- a/include/eve/module/core/saturated/impl/minmag.hpp +++ b/include/eve/module/core/saturated/impl/minmag.hpp @@ -36,8 +36,8 @@ template 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 ) { auto tmp = if_else(is_not_greater_equal(bb, aa), b, eve::min(a, b)); diff --git a/include/eve/module/core/saturated/impl/negabsmax.hpp b/include/eve/module/core/saturated/impl/negabsmax.hpp index 6d6346de9c..5785ac395c 100644 --- a/include/eve/module/core/saturated/impl/negabsmax.hpp +++ b/include/eve/module/core/saturated/impl/negabsmax.hpp @@ -34,7 +34,7 @@ negabsmax_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v { - return saturated(minus)(saturated(eve::abs)(eve::max(a, b))); + return saturated(minus)(eve::abs[saturated](eve::max(a, b))); } //================================================================================================ @@ -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...))); } } diff --git a/include/eve/module/core/saturated/impl/negabsmin.hpp b/include/eve/module/core/saturated/impl/negabsmin.hpp index acba6ddf19..efd783c6bd 100644 --- a/include/eve/module/core/saturated/impl/negabsmin.hpp +++ b/include/eve/module/core/saturated/impl/negabsmin.hpp @@ -34,7 +34,7 @@ negabsmin_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v { - return saturated(minus)(saturated(eve::abs)(eve::min(a, b))); + return saturated(minus)(eve::abs[saturated](eve::min(a, b))); } //================================================================================================ @@ -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...))); } } diff --git a/include/eve/module/core/saturated/impl/sqr.hpp b/include/eve/module/core/saturated/impl/sqr.hpp index 71a7de3270..2af955e59c 100644 --- a/include/eve/module/core/saturated/impl/sqr.hpp +++ b/include/eve/module/core/saturated/impl/sqr.hpp @@ -28,12 +28,11 @@ sqr_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a0) noexcept if constexpr( floating_value ) { return sqr(a0); } else if constexpr( scalar_value ) { - 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); } diff --git a/include/eve/traits/overload/default_behaviors.hpp b/include/eve/traits/overload/default_behaviors.hpp index 5b64574dfc..a5bb798d3f 100644 --- a/include/eve/traits/overload/default_behaviors.hpp +++ b/include/eve/traits/overload/default_behaviors.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace eve { diff --git a/test/doc/core/regular/deco.cpp b/test/doc/core/regular/deco.cpp index 8eddf0c509..5d46931dbe 100644 --- a/test/doc/core/regular/deco.cpp +++ b/test/doc/core/regular/deco.cpp @@ -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; } diff --git a/test/doc/core/saturated/abs.cpp b/test/doc/core/saturated/abs.cpp index ca4cdb7e58..459d7a01b1 100644 --- a/test/doc/core/saturated/abs.cpp +++ b/test/doc/core/saturated/abs.cpp @@ -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; } diff --git a/test/random/module/core/abs.cpp b/test/random/module/core/abs.cpp index 7f0bc1d608..244fe42939 100644 --- a/test/random/module/core/abs.cpp +++ b/test/random/module/core/abs.cpp @@ -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( eve::inc(vmin), vmax ), std_abs, eve::abs ); - EVE_ULP_RANGE_CHECK ( T, eve::uniform_prng( vmin, vmax ), std_abs, eve::saturated(eve::abs) ); + EVE_ULP_RANGE_CHECK ( T, eve::uniform_prng( vmin, vmax ), std_abs, eve::abs[saturated] ); } else { diff --git a/test/unit/module/core/negabsmin.cpp b/test/unit/module/core/negabsmin.cpp index d63cddd5a9..bcb8548697 100644 --- a/test/unit/module/core/negabsmin.cpp +++ b/test/unit/module/core/negabsmin.cpp @@ -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; - 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); diff --git a/test/unit/module/core/sqr.cpp b/test/unit/module/core/sqr.cpp index 56fbf4dfcd..c0f1286bfc 100644 --- a/test/unit/module/core/sqr.cpp +++ b/test/unit/module/core/sqr.cpp @@ -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));