diff --git a/include/eve/module/core/pedantic/core.hpp b/include/eve/module/core/pedantic/core.hpp index b239aa2c2a..204abf5f48 100644 --- a/include/eve/module/core/pedantic/core.hpp +++ b/include/eve/module/core/pedantic/core.hpp @@ -7,12 +7,5 @@ //================================================================================================== #pragma once -#include -#include -#include -#include -#include #include #include -#include -#include diff --git a/include/eve/module/core/pedantic/diff_of_prod.hpp b/include/eve/module/core/pedantic/diff_of_prod.hpp deleted file mode 100644 index 053e224d06..0000000000 --- a/include/eve/module/core/pedantic/diff_of_prod.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/frexp.hpp b/include/eve/module/core/pedantic/frexp.hpp deleted file mode 100644 index 214e47fcaa..0000000000 --- a/include/eve/module/core/pedantic/frexp.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/impl/diff_of_prod.hpp b/include/eve/module/core/pedantic/impl/diff_of_prod.hpp deleted file mode 100644 index 3f4f99b69b..0000000000 --- a/include/eve/module/core/pedantic/impl/diff_of_prod.hpp +++ /dev/null @@ -1,48 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include - -namespace eve::detail -{ - template - EVE_FORCEINLINE auto diff_of_prod_(EVE_SUPPORTS(cpu_) - , pedantic_type const & - , const T& a - , const U& b - , const V& c - , const W& d - ) noexcept -> decltype(a*b+c*d) - { - using r_t = decltype(a*b+c*d); - return pedantic(diff_of_prod)(r_t(a), r_t(b), r_t(c), r_t(d)); - } - - template - EVE_FORCEINLINE auto diff_of_prod_(EVE_SUPPORTS(cpu_) - , pedantic_type const & - , const T& a - , const T& b - , const T& c - , const T& d - ) noexcept - { - if constexpr(std::is_integral_v>) - return fms(a, b, c*d); - else - { - T mcd = c * d; - T err = fma[pedantic](-c, d, mcd); - T dop = fms[pedantic](a, b, mcd); - return if_else(is_finite(err), dop + err, dop); - } - } -} diff --git a/include/eve/module/core/pedantic/impl/is_not_flint.hpp b/include/eve/module/core/pedantic/impl/is_not_flint.hpp deleted file mode 100644 index 9225a79ea5..0000000000 --- a/include/eve/module/core/pedantic/impl/is_not_flint.hpp +++ /dev/null @@ -1,33 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -is_not_flint_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - using u_t = underlying_type_t; - if constexpr( integral_value ) return true_(eve::as()); - else if constexpr( floating_value ) return is_nez(frac(a)) || (a > eve::maxflint(eve::as())); - } - else return apply_over(pedantic(is_not_flint), a); -} -} diff --git a/include/eve/module/core/pedantic/impl/negatenz.hpp b/include/eve/module/core/pedantic/impl/negatenz.hpp deleted file mode 100644 index 870c05cf1d..0000000000 --- a/include/eve/module/core/pedantic/impl/negatenz.hpp +++ /dev/null @@ -1,44 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE T -negatenz_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - T const& b) noexcept requires has_native_abi_v -{ - if constexpr( signed_value ) { return a * pedantic(signnz)(b); } - else { return a; } -} - -template -EVE_FORCEINLINE auto -negatenz_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - U const& b) noexcept --> decltype(negatenz(a, b)) -{ - return arithmetic_call(pedantic(negatenz), a, b); -} - -} diff --git a/include/eve/module/core/pedantic/impl/next.hpp b/include/eve/module/core/pedantic/impl/next.hpp deleted file mode 100644 index f3fccda703..0000000000 --- a/include/eve/module/core/pedantic/impl/next.hpp +++ /dev/null @@ -1,78 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -next_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto pz = bitinteger(a); - auto z = bitfloating(inc(pz)); - auto test = is_negative(a) && is_positive(z); - if constexpr( scalar_value ) { return test ? (z == 0 ? T(-0.) : bitfloating(pz)) : z; } - else { return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); } - } - else if constexpr( integral_value ) { return inc[saturated2](a); } - } - else { return apply_over(pedantic(next), a); } -} - -////////////////////////////////////////////////////////////// -// two parameters -////////////////////////////////////////////////////////////// - -template -EVE_FORCEINLINE constexpr auto -next_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, U const& n) noexcept -{ - if constexpr( has_native_abi_v && has_native_abi_v ) - { - if constexpr( floating_value ) - { - using i_t = as_integer_t; - auto pz = dec(bitinteger(a) + to_(n)); - auto z = bitfloating(inc(pz)); - auto test = is_negative(a) && is_positive(z); - if constexpr( scalar_value && scalar_value ) - { - if( is_nan(a) ) return a; - return test ? (z == 0 ? T(-0.) : bitfloating(pz)) : z; - } - else { return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); } - } - else if constexpr( integral_value ) { return saturated(add)(a, to_(n)); } - } - else { return apply_over(pedantic(next), a, n); } -} -} diff --git a/include/eve/module/core/pedantic/impl/nextafter.hpp b/include/eve/module/core/pedantic/impl/nextafter.hpp deleted file mode 100644 index e51fd79a36..0000000000 --- a/include/eve/module/core/pedantic/impl/nextafter.hpp +++ /dev/null @@ -1,58 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -namespace eve::detail -{ -////////////////////////////////////////////////////////////// -// decorated calls -template -EVE_FORCEINLINE constexpr auto -nextafter_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - U const& b) noexcept --> decltype(nextafter(a, b)) -{ - return arithmetic_call(pedantic(nextafter), a, b); -} - -template -EVE_FORCEINLINE constexpr auto -nextafter_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - T const& b) noexcept requires has_native_abi_v -{ - if constexpr( scalar_value ) - { - if( is_unordered(a, b) ) return allbits(eve::as(a)); - return (a < b) ? next(a) : ((b < a) ? prev(a) : a); - } - else if constexpr( simd_value ) - { - return if_else( - is_unordered(a, b), allbits, if_else(a < b, next(a), if_else(b < a, prev(a), a))); - } -} -} diff --git a/include/eve/module/core/pedantic/impl/prev.hpp b/include/eve/module/core/pedantic/impl/prev.hpp deleted file mode 100644 index 9eb13fc93f..0000000000 --- a/include/eve/module/core/pedantic/impl/prev.hpp +++ /dev/null @@ -1,96 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -prev_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto nz = bitinteger(a); - auto z = bitfloating(dec(nz)); - auto test = is_negative(z) && is_positive(a); - if constexpr( scalar_value ) - { - if( is_nan(a) ) return a; - return test ? (a == 0 ? T(-0.) : bitfloating(nz)) : z; - } - else - { - return if_else(is_nan(a), - allbits, - if_else(test, if_else(is_eqz(a), mzero(eve::as(a)), bitfloating(nz)), z)); - } - } - else if constexpr( integral_value ) { return dec[saturated2](a); } - } - else { return apply_over(pedantic(prev), a); } -} - -////////////////////////////////////////////////////////////// -// two parameters -////////////////////////////////////////////////////////////// -template -EVE_FORCEINLINE constexpr auto -prev_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, U const& n) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - using iT = as_integer_t; - auto nz = inc(bitinteger(a) - to_(n)); - auto z = bitfloating(dec(nz)); - auto test = is_negative(z) && is_positive(a); - if constexpr( scalar_value && scalar_value ) - { - if( is_nan(a) ) return a; - return test ? (nz == 0 ? T(-0.) : bitfloating(nz)) : z; - } - else - { - return if_else(is_nan(a), - allbits, - if_else(test, if_else(is_eqz(nz), mzero(eve::as()), bitfloating(nz)), z)); - } - } - else if constexpr( integral_value ) { return saturated(sub)(a, to_(n)); } - } - else { return apply_over(pedantic(prev), a, n); } -} -} diff --git a/include/eve/module/core/pedantic/impl/signnz.hpp b/include/eve/module/core/pedantic/impl/signnz.hpp deleted file mode 100644 index 576a831537..0000000000 --- a/include/eve/module/core/pedantic/impl/signnz.hpp +++ /dev/null @@ -1,59 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE T -signnz_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( unsigned_value ) { return one(eve::as(a)); } - else if constexpr( floating_value ) - { - auto r = bit_or(one(eve::as(a)), bitofsign(a)); - if constexpr( eve::platform::supports_nans ) - { - if constexpr( scalar_value ) { return is_nan(a) ? a : r; } - else { return if_else(is_nan(a), eve::allbits, r); } - } - else { return r; } - } - else if constexpr( signed_value ) - { - using elt_t = element_type_t; - return (a >> (sizeof(elt_t) * 8 - 2)) | T(1); - } - } - else { return apply_over(pedantic(signnz), a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked case -template -EVE_FORCEINLINE auto -signnz_(EVE_SUPPORTS(cpu_), C const& cond, pedantic_type const&, U const& t) noexcept -{ - return mask_op(cond, pedantic(signnz), t); -} -} diff --git a/include/eve/module/core/pedantic/impl/sum_of_prod.hpp b/include/eve/module/core/pedantic/impl/sum_of_prod.hpp deleted file mode 100644 index 60a5c8b5de..0000000000 --- a/include/eve/module/core/pedantic/impl/sum_of_prod.hpp +++ /dev/null @@ -1,49 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include - -namespace eve::detail -{ - template - EVE_FORCEINLINE auto sum_of_prod_(EVE_SUPPORTS(cpu_) - , pedantic_type const & - , const T& a - , const U& b - , const V& c - , const W& d - ) noexcept -> decltype(a*b+c*d) - { - using r_t = decltype(a*b+c*d); - return pedantic(sum_of_prod)(r_t(a), r_t(b), r_t(c), r_t(d)); - } - - template - EVE_FORCEINLINE T sum_of_prod_(EVE_SUPPORTS(cpu_) - , pedantic_type const & - , const T& a - , const T& b - , const T& c - , const T& d - ) noexcept - { - if constexpr(std::is_integral_v>) - return fma(a, b, c*d); - else - { - T mcd = -c * d; - T err = fma[pedantic](c, d, mcd); - T dop = fms[pedantic](a, b, mcd); - T r = if_else(is_finite(err), dop + err, dop); - return r; - } - } -} diff --git a/include/eve/module/core/pedantic/negatenz.hpp b/include/eve/module/core/pedantic/negatenz.hpp deleted file mode 100644 index 03acf0905f..0000000000 --- a/include/eve/module/core/pedantic/negatenz.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/next.hpp b/include/eve/module/core/pedantic/next.hpp deleted file mode 100644 index 3a28b64874..0000000000 --- a/include/eve/module/core/pedantic/next.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/nextafter.hpp b/include/eve/module/core/pedantic/nextafter.hpp deleted file mode 100644 index 2aa87dd7d1..0000000000 --- a/include/eve/module/core/pedantic/nextafter.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/prev.hpp b/include/eve/module/core/pedantic/prev.hpp deleted file mode 100644 index 3e140f4a78..0000000000 --- a/include/eve/module/core/pedantic/prev.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/signnz.hpp b/include/eve/module/core/pedantic/signnz.hpp deleted file mode 100644 index ca8858e08a..0000000000 --- a/include/eve/module/core/pedantic/signnz.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/pedantic/sum_of_prod.hpp b/include/eve/module/core/pedantic/sum_of_prod.hpp deleted file mode 100644 index d3d70ce457..0000000000 --- a/include/eve/module/core/pedantic/sum_of_prod.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/regular/diff_of_prod.hpp b/include/eve/module/core/regular/diff_of_prod.hpp index a276e09df6..7f36737ba8 100644 --- a/include/eve/module/core/regular/diff_of_prod.hpp +++ b/include/eve/module/core/regular/diff_of_prod.hpp @@ -7,10 +7,26 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct diff_of_prod_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T a, U b, V c, W d) const + { return EVE_DISPATCH_CALL(a, b, c, d); } + + EVE_CALLABLE_OBJECT(diff_of_prod_t, diff_of_prod_); + }; + //================================================================================================ //! @addtogroup core_accuracy //! @{ @@ -55,7 +71,7 @@ namespace eve //! * eve::raw //! //! The call `eve::raw(eve::diff_of_prod)(x, y, z, t)` computes a raw -//! version of eve::diff_of_prod, i.e. the naive formula +//! version of eve::diff_of_prod, i.e. the naive formula (in fact `fms(x, y, z, t)`) //! //! * eve::pedantic //! @@ -64,15 +80,32 @@ namespace eve //! //! @} //================================================================================================ + inline constexpr auto diff_of_prod = functor; -namespace tag -{ - struct diff_of_prod_; -} -template<> struct supports_conditional : std::false_type -{}; - -EVE_MAKE_CALLABLE(diff_of_prod_, diff_of_prod); + namespace detail + { + template + EVE_FORCEINLINE constexpr common_value_t + diff_of_prod_(EVE_REQUIRES(cpu_), O const & o, + T const &aa, U const &bb, + V const &cc, W const &dd) noexcept + { + using r_t = common_value_t; + r_t a = r_t(aa); + r_t b = r_t(bb); + r_t c = r_t(cc); + r_t d = r_t(dd); + r_t cd = c*d; + if constexpr(O::contains(raw2)) + { + return fms(a, b, cd); + } + else + { + auto err = fnma[o](c, d, cd); + auto dop = fms[o](a, b, cd); + return if_else(is_finite(err), dop + err, dop); + } + } + } } - -#include diff --git a/include/eve/module/core/regular/impl/simd/x86/negate.hpp b/include/eve/module/core/regular/impl/simd/x86/negate.hpp index 2bf965d3e9..cbe9fc387c 100644 --- a/include/eve/module/core/regular/impl/simd/x86/negate.hpp +++ b/include/eve/module/core/regular/impl/simd/x86/negate.hpp @@ -14,29 +14,31 @@ namespace eve::detail { // ----------------------------------------------------------------------------------------------- // 128 bits implementation -template -EVE_FORCEINLINE wide - negate_(EVE_SUPPORTS(ssse3_), - wide a0, - wide a1) noexcept requires std::same_as, x86_128_> -{ - if( sizeof(T) == 8 ) return map(negate, a0, a1); - else if( sizeof(T) == 4 ) return _mm_sign_epi32(a0, a1); - else if( sizeof(T) == 2 ) return _mm_sign_epi16(a0, a1); - else if( sizeof(T) == 1 ) return _mm_sign_epi8(a0, a1); -} + template + EVE_FORCEINLINE wide negate_(EVE_REQUIRES(ssse3_), + O const& opts, + wide a0, + wide a1) noexcept + requires std::same_as, x86_128_> + { + if( sizeof(T) == 8 ) return negate.behavior(cpu_{}, opts, a0, a1); + else if( sizeof(T) == 4 ) return _mm_sign_epi32(a0, a1); + else if( sizeof(T) == 2 ) return _mm_sign_epi16(a0, a1); + else if( sizeof(T) == 1 ) return _mm_sign_epi8(a0, a1); + } // ----------------------------------------------------------------------------------------------- // 256 bits implementation -template -EVE_FORCEINLINE wide - negate_(EVE_SUPPORTS(avx2_), - wide a0, - wide a1) noexcept requires std::same_as, x86_256_> -{ - if( sizeof(T) == 8 ) return negate_(EVE_RETARGET(sse2_), a0, a1); - else if( sizeof(T) == 4 ) return _mm256_sign_epi32(a0, a1); - else if( sizeof(T) == 2 ) return _mm256_sign_epi16(a0, a1); - else if( sizeof(T) == 1 ) return _mm256_sign_epi8(a0, a1); -} + template + EVE_FORCEINLINE wide negate_(EVE_REQUIRES(avx2_), + O const& opts, + wide a0, + wide a1) noexcept + requires std::same_as, x86_256_> + { + if( sizeof(T) == 8 ) return negate.behavior(cpu_{}, opts, a0, a1); + else if( sizeof(T) == 4 ) return _mm256_sign_epi32(a0, a1); + else if( sizeof(T) == 2 ) return _mm256_sign_epi16(a0, a1); + else if( sizeof(T) == 1 ) return _mm256_sign_epi8(a0, a1); + } } diff --git a/include/eve/module/core/regular/negate.hpp b/include/eve/module/core/regular/negate.hpp index 00683f3d9a..f73e88d366 100644 --- a/include/eve/module/core/regular/negate.hpp +++ b/include/eve/module/core/regular/negate.hpp @@ -8,10 +8,21 @@ #pragma once #include -#include +#include +#include namespace eve { + template + struct negate_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T a, U b) const + { return EVE_DISPATCH_CALL(a, b); } + + EVE_CALLABLE_OBJECT(negate_t, negate_); + }; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ @@ -57,10 +68,24 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(negate_, negate); -} + inline constexpr auto negate = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr common_value_t + negate_(EVE_REQUIRES(cpu_), O const &, T const &aa, U const &bb) noexcept + { + using r_t = common_value_t; + r_t a = r_t(aa); + r_t b = r_t(bb); + if constexpr( signed_value ) + return a * sign(b); + else + return if_else(is_nez(b), a, eve::zero); + } + } +} #if defined(EVE_INCLUDE_X86_HEADER) # include diff --git a/include/eve/module/core/regular/negatenz.hpp b/include/eve/module/core/regular/negatenz.hpp index 79e150adda..631ea36f1c 100644 --- a/include/eve/module/core/regular/negatenz.hpp +++ b/include/eve/module/core/regular/negatenz.hpp @@ -8,10 +8,23 @@ #pragma once #include -#include +#include +#include +#include + namespace eve { + template + struct negatenz_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T a, U b) const + { return EVE_DISPATCH_CALL(a, b); } + + EVE_CALLABLE_OBJECT(negatenz_t, negatenz_); + }; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ @@ -58,7 +71,21 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(negatenz_, negatenz); -} + inline constexpr auto negatenz = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr common_value_t + negatenz_(EVE_REQUIRES(cpu_), O const &o, T const &aa, U const &bb) noexcept + { + using r_t = common_value_t; + r_t a = r_t(aa); + r_t b = r_t(bb); + if constexpr( signed_value ) + return a * signnz[o](b); + else + return a; + } + } +} diff --git a/include/eve/module/core/regular/next.hpp b/include/eve/module/core/regular/next.hpp index c4a387d4b9..e262bf6580 100644 --- a/include/eve/module/core/regular/next.hpp +++ b/include/eve/module/core/regular/next.hpp @@ -7,18 +7,43 @@ //================================================================================================== #pragma once -#include -#include -#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include #include - -#include +#include +#include +#include +#include +#include namespace eve { + template + struct next_t : strict_elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const noexcept + { return EVE_DISPATCH_CALL(v); } + + template + constexpr EVE_FORCEINLINE as_wide_as_t operator()(T v, N n) const noexcept + { + EVE_ASSERT(eve::all(is_gez(n)), "[eve::next] : second parameter must be positive"); + return EVE_DISPATCH_CALL(v, n); + } + + EVE_CALLABLE_OBJECT(next_t, next_); + }; + //================================================================================================ //! @addtogroup core_internal //! @{ @@ -66,55 +91,106 @@ namespace eve //! //! * eve::pedantic //! -//! The call `eve::pedantic(eve::next)(x, ...)` provides a pedantic +//! The call `eve::next[eve::pedantic](x, ...)` provides a pedantic //! version of `next` which ensures that the successor of eve::mzero is eve::zero //! for floating points entries //! //! * eve::saturated //! -//! The call `eve::pedantic(eve::next)(x, ...)` provides a pedantic -//! version of `next` which ensures that eve::minf and eve::nan are fixed points. +//! The call `eve::next[eve::saturated](x, ...)` provides a saturated +//! version of `next` which ensures that x is never less than the result of the call. //! //! @} //================================================================================================ -namespace tag -{ - struct next_; -} + inline constexpr auto next = functor; -namespace detail -{ - template - EVE_FORCEINLINE void - check(EVE_MATCH_CALL(eve::tag::next_), C const&, T const&, [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::next] : second parameter must be positive"); - } - template - EVE_FORCEINLINE void check(EVE_MATCH_CALL(eve::tag::next_), T const&, [[maybe_unused]] U const& n) + namespace detail { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::next] : second parameter must be positive"); - } + template + EVE_FORCEINLINE constexpr T + next_(EVE_REQUIRES(cpu_), O const &, T const &a) noexcept + { + if constexpr( floating_value ) + { + if constexpr(O::contains(pedantic2)) + { + auto pz = bitinteger(a); + auto z = bitfloating(inc(pz)); + auto test = is_negative(a) && is_positive(z); + auto nxt = if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); + if constexpr(O::contains(saturated2)) + { + nxt = if_else(a == inf(as(a)), a, nxt); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); + } + return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), nxt); + } + else if constexpr(O::contains(saturated2)) + { + auto z = if_else(a == inf(as(a)), a, next(a)); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); + else return z; + } + else + return bitfloating(inc(bitinteger(a))); + } + else + { + if constexpr(O::contains(saturated2) || O::contains(pedantic2)) + { + return if_else(a == valmax(as(a)), a, inc(a)); + } + else + { + return inc(a); + } + } + } - template - EVE_FORCEINLINE void check(EVE_MATCH_CALL(saturated_type, eve::tag::next_), - C const&, - T const&, - [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::next] : second parameter must be positive"); - } - template - EVE_FORCEINLINE void - check(EVE_MATCH_CALL(saturated_type, eve::tag::next_), T const&, [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), - "[[eve::saturated([eve::next)] : second parameter must be positive"); + template + EVE_FORCEINLINE constexpr as_wide_as_t + next_(EVE_REQUIRES(cpu_), O const &, T const &a, N const &n) noexcept + { + if constexpr( floating_value ) + { + if constexpr(O::contains(pedantic2)) + { + using i_t = as_integer_t; + auto pz = dec(bitinteger(a) + to_(n)); + auto z = bitfloating(inc(pz)); + auto test = is_negative(a) && is_positive(z); + if constexpr( scalar_value && scalar_value ) + { + if( is_nan(a) ) return a; + return test ? (z == 0 ? T(-0.) : bitfloating(pz)) : z; + } + else { return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); } + } + else if constexpr(O::contains(saturated2)) + { + auto nxt = next(a, n); + auto z = if_else(a != inf(as(a)) && nxt == nan(as(a)), inf(as(a)), nxt); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); + else return z; + } + else + { + using i_t = as_integer_t; + return bitfloating(bitinteger(a) + to_(n)); + } + } + else + { + if constexpr(O::contains(saturated2) || O::contains(pedantic2)) + { + auto tmp = next(a, n); + return if_else(a > tmp, a, tmp); + } + else + { + return a+to_(n); + } + } + } } - -} - -EVE_MAKE_CALLABLE(next_, next); } - -#include diff --git a/include/eve/module/core/regular/nextafter.hpp b/include/eve/module/core/regular/nextafter.hpp index 050cc1c5a8..a0be45a02c 100644 --- a/include/eve/module/core/regular/nextafter.hpp +++ b/include/eve/module/core/regular/nextafter.hpp @@ -7,19 +7,25 @@ //================================================================================================== #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +# namespace eve { + template + struct nextafter_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T t, U u) const noexcept + { return EVE_DISPATCH_CALL(t, u); } + + EVE_CALLABLE_OBJECT(nextafter_t, nextafter_); + }; + //================================================================================================ //! @addtogroup core_internal //! @{ @@ -58,6 +64,12 @@ namespace eve //! //! @groupheader{Semantic Modifiers} //! +//! * pedantic Call +//! +//! The call `eve::nextafter[pedantic](x, ...)` provides a +//! version of `nextafter` for which floating plus zero and minus zero are distinct +//! for x. +//! //! * Masked Call //! //! The call `eve::nextafter[mask](x, ...)` provides a masked @@ -66,7 +78,21 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(nextafter_, nextafter); -} + inline constexpr auto nextafter = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr common_value_t + nextafter_(EVE_REQUIRES(cpu_), O const& o, T const& xx, U const & yy) noexcept + { + using r_t = common_value_t; + auto a = r_t(xx); + auto b = r_t(yy); + if constexpr( scalar_value ) + return (a < b) ? next[o](a) : ((a > b) ? prev[o](a) : a); + else if constexpr( simd_value ) + return if_else(a < b, next[o](a), if_else(a > b, prev[o](a), a)); + } + } +} diff --git a/include/eve/module/core/regular/oneminus.hpp b/include/eve/module/core/regular/oneminus.hpp index 47efe78a37..2711c33e0b 100644 --- a/include/eve/module/core/regular/oneminus.hpp +++ b/include/eve/module/core/regular/oneminus.hpp @@ -7,10 +7,27 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct oneminus_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T a) const + { return EVE_DISPATCH_CALL(a); } + + EVE_CALLABLE_OBJECT(oneminus_t, oneminus_); + }; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ @@ -65,8 +82,34 @@ namespace eve //! //! @} //================================================================================================ + inline constexpr auto oneminus = functor; -EVE_MAKE_CALLABLE(oneminus_, oneminus); + namespace detail + { + template + EVE_FORCEINLINE constexpr T + oneminus_(EVE_REQUIRES(cpu_), O const &, T v) noexcept + { + using elt_t = element_type_t; + if constexpr( std::is_floating_point_v || !O::contains(saturated2) ) + { + return one(eve::as()) - v; + } + else + { + if constexpr( std::is_unsigned_v ) + { + return binarize(is_eqz(v)); + } + else if constexpr( scalar_value ) + { + return (v <= valmin(eve::as(v)) + 2) ? valmax(eve::as(v)) : oneminus(v); + } + else if constexpr( simd_value ) + { + return if_else(v < valmin(eve::as(v)) + 2, valmax(eve::as(v)), oneminus(v)); + } + } + } + } } - -#include diff --git a/include/eve/module/core/regular/prev.hpp b/include/eve/module/core/regular/prev.hpp index fa7860de14..a5930785d8 100644 --- a/include/eve/module/core/regular/prev.hpp +++ b/include/eve/module/core/regular/prev.hpp @@ -12,14 +12,37 @@ #include #include #include +#include +#include #include #include #include - -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct prev_t : strict_elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const noexcept + { return EVE_DISPATCH_CALL(v); } + + template + constexpr EVE_FORCEINLINE as_wide_as_t operator()(T v, N n) const noexcept + { + EVE_ASSERT(eve::all(is_gez(n)), "[eve::prev] : second parameter must be positive"); + return EVE_DISPATCH_CALL(v, n); + } + + EVE_CALLABLE_OBJECT(prev_t, prev_); + }; + //================================================================================================ //! @addtogroup core_internal //! @{ @@ -65,45 +88,109 @@ namespace eve //! version of `prev` which is //! equivalent to `if_else(mask, prev(x, ...), x)` //! -//! @} +//! * eve::pedantic +//! +//! The call `eve::prev[eve::pedantic](x, ...)` provides a pedantic +//! version of `prev` which ensures that the predecessor of eve::zero is eve::mzero +//! for floating points entries +//! +//! * eve::saturated +//! +//! The call `eve::prev[eve::saturated](x, ...)` provides a saturated +//! version of `prev` which ensures that that x is never greater than the result of the call. +//!//! @} //================================================================================================ -namespace tag -{ - struct prev_; -} + inline constexpr auto prev = functor; -namespace detail -{ - template - EVE_FORCEINLINE void - check(EVE_MATCH_CALL(eve::tag::prev_), C const&, T const&, [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::prev] : second parameter must be positive"); - } - template - EVE_FORCEINLINE void check(EVE_MATCH_CALL(eve::tag::prev_), T const&, [[maybe_unused]] U const& n) + namespace detail { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::prev] : second parameter must be positive"); - } + template + EVE_FORCEINLINE constexpr T + prev_(EVE_REQUIRES(cpu_), O const &, T const &a) noexcept + { + if constexpr( floating_value ) + { + if constexpr(O::contains(pedantic2)) + { + auto pz = bitinteger(a); + auto z = bitfloating(dec(pz)); + auto test = is_negative(z) && is_positive(a); + auto prv = if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); + prv = if_else(is_nan(a), eve::allbits, prv); + if constexpr(O::contains(saturated2)) + { + prv = if_else(a == minf(as(a)), a, prv); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, prv); + } + return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), prv); + } + else if constexpr(O::contains(saturated2)) + { + auto prv = prev(a); + auto z = if_else(a == minf(as(a)), a, prv); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); + else return z; + } + else + return bitfloating(dec(bitinteger(a))); + } + else + { + if constexpr(O::contains(saturated2) || O::contains(pedantic2)) + { + return if_else(a == valmin(as(a)), a, dec(a)); + } + else + { + return dec(a); + } + } + } - template - EVE_FORCEINLINE void check(EVE_MATCH_CALL(saturated_type, eve::tag::prev_), - C const&, - T const&, - [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), "[eve::prev] : second parameter must be positive"); - } - template - EVE_FORCEINLINE void - check(EVE_MATCH_CALL(saturated_type, eve::tag::prev_), T const&, [[maybe_unused]] U const& n) - { - EVE_ASSERT(eve::all(is_gez(n)), - "[[eve::saturated([eve::prev)] : second parameter must be positive"); + template + EVE_FORCEINLINE constexpr as_wide_as_t + prev_(EVE_REQUIRES(cpu_), O const &, T const &a, N const &n) noexcept + { + if constexpr( floating_value ) + { + if constexpr(O::contains(pedantic2)) + { + using i_t = as_integer_t; + auto pz = inc(bitinteger(a) - to_(n)); + auto z = bitfloating(dec(pz)); + auto test = is_negative(z) && is_positive(a); + if constexpr( scalar_value && scalar_value ) + { + if( is_nan(a) ) return a; + return test ? (z == 0 ? T(-0.) : bitfloating(pz)) : z; + } + else { return if_else(test, if_else(is_eqz(z), mzero(eve::as()), bitfloating(pz)), z); } + } + else if constexpr(O::contains(saturated2)) + { + auto prv = prev(a, n); + auto z = if_else(a > prv || is_nan(prv), minf(as(a)), prv); + if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); + else return z; + } + else + { + using i_t = as_integer_t; + return bitfloating(bitinteger(a) - to_(n)); + } + } + else + { + if constexpr(O::contains(saturated2) || O::contains(pedantic2)) + { + auto tmp = prev(a, n); + return if_else(a < tmp, a, tmp); + } + else + { + return a-to_(n); + } + } + } } } - -EVE_MAKE_CALLABLE(prev_, prev); -} - -#include diff --git a/include/eve/module/core/regular/signnz.hpp b/include/eve/module/core/regular/signnz.hpp index dac690286a..7379a9985c 100644 --- a/include/eve/module/core/regular/signnz.hpp +++ b/include/eve/module/core/regular/signnz.hpp @@ -7,10 +7,26 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct signnz_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T a) const + { return EVE_DISPATCH_CALL(a); } + + EVE_CALLABLE_OBJECT(signnz_t, signnz_); + }; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ @@ -45,11 +61,9 @@ namespace eve //! * If x is [positive](@ref eve::is_positive), 1 is returned. //! * If x is [negative](@ref eve::is_negative), -1 is returned. //! -//! * Moreover for [floating real value](@ref eve::floating_value) -//! if x is `Nan`, the result is `Nan` +//! * Note that is_negative and is_positive only look at the sign bit and a Nan has +//! generally unpredicable sign bit. //! -//! value containing the [elementwise](@ref glossary_elementwise) -//! never zero sign of `x` //! //! @groupheader{Example} //! @@ -62,9 +76,42 @@ namespace eve //! The call `eve;::signnz[mask](x)` provides a masked version of `eve::signnz` which is //! equivalent to `if_else (mask, signnz(x), x)`. //! +//! * pedantic Call +//! +//! The call `eve;::signnz[pedantic](x)` returns nan for nan input`. +//! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(signnz_, signnz); -} + inline constexpr auto signnz = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr T + signnz_(EVE_REQUIRES(cpu_), O const &, T const &a) noexcept + { + if constexpr( unsigned_value ) + { + return one(eve::as(a)); + } + else if constexpr( floating_value ) + { + auto r = bit_or(one(eve::as(a)), bitofsign(a)); + if constexpr( eve::platform::supports_nans && O::contains(pedantic2)) + { + if constexpr( scalar_value ) + return is_nan(a) ? a : r; + else + return if_else(is_nan(a), eve::allbits, r); + } + else + return r; + } + else if constexpr( integral_value ) + { + using elt_t = element_type_t; + return (a >> (sizeof(elt_t) * 8 - 2)) | T(1); + } + } + } +} diff --git a/include/eve/module/core/regular/sqr.hpp b/include/eve/module/core/regular/sqr.hpp index 9f153eda4e..0bce8f1f98 100644 --- a/include/eve/module/core/regular/sqr.hpp +++ b/include/eve/module/core/regular/sqr.hpp @@ -7,10 +7,24 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { +template +struct sqr_t : elementwise_callable +{ + template + constexpr EVE_FORCEINLINE T operator()(T v) const noexcept + { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(sqr_t, sqr_); +}; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ @@ -75,15 +89,28 @@ namespace eve //! //! @} //================================================================================================ -// namespace tag -// { -// struct sqr_; -// } + inline constexpr auto sqr = functor; -// template<> struct supports_optimized_conversion : std::true_type -// {}; + namespace detail + { -EVE_MAKE_CALLABLE(sqr_, sqr); + template + EVE_FORCEINLINE constexpr T + sqr_(EVE_REQUIRES(cpu_), O const &, T const &a0) noexcept + { + if constexpr(O::contains(saturated2)) + { + if constexpr( scalar_value ) + { + return (eve::abs[saturated2](a0) > sqrtvalmax(eve::as(a0))) ? valmax(eve::as(a0)) : sqr(a0); + } + else + { + return if_else(eve::abs[saturated2](a0) > sqrtvalmax(eve::as(a0)), valmax(eve::as(a0)), sqr(a0)); + } + } + else + return mul(a0, a0); + } + } } - -#include diff --git a/include/eve/module/core/regular/sum_of_prod.hpp b/include/eve/module/core/regular/sum_of_prod.hpp index 6e844b1fd8..a8d9a084a2 100644 --- a/include/eve/module/core/regular/sum_of_prod.hpp +++ b/include/eve/module/core/regular/sum_of_prod.hpp @@ -7,10 +7,26 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct sum_of_prod_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T a, U b, V c, W d) const + { return EVE_DISPATCH_CALL(a, b, c, d); } + + EVE_CALLABLE_OBJECT(sum_of_prod_t, sum_of_prod_); + }; + //================================================================================================ //! @addtogroup core_accuracy //! @{ @@ -54,9 +70,8 @@ namespace eve //! //! * eve::raw //! -//! The call `eve::raw(eve::diff_of_prod)(x, y, z, t)` computes a raw -//! version of eve::sum_of_prod, i.e. the naive formula -//! +//! The call `eve::raw(eve::sum_of_prod)(x, y, z, t)` computes a raw +//! version of eve::sum_of_prod, i.e. the naive formula (in fact `fma(x, y, z, t)`) //! //! * eve::pedantic //! @@ -65,14 +80,32 @@ namespace eve //! //! @} //================================================================================================ -namespace tag -{ - struct sum_of_prod_; -} -template<> struct supports_conditional : std::false_type -{}; + inline constexpr auto sum_of_prod = functor; -EVE_MAKE_CALLABLE(sum_of_prod_, sum_of_prod); + namespace detail + { + template + EVE_FORCEINLINE constexpr common_value_t + sum_of_prod_(EVE_REQUIRES(cpu_), O const & o, + T const &aa, U const &bb, + V const &cc, W const &dd) noexcept + { + using r_t = common_value_t; + r_t a = r_t(aa); + r_t b = r_t(bb); + r_t c = r_t(cc); + r_t d = r_t(dd); + r_t cd = c*d; + if constexpr(O::contains(raw2)) + { + return fma(a, b, cd); + } + else + { + auto err = fms[o](c, d, cd); + auto dop = fma[o](a, b, cd); + return if_else(is_finite(err), dop + err, dop); + } + } + } } - -#include diff --git a/include/eve/module/core/saturated/core.hpp b/include/eve/module/core/saturated/core.hpp index a6fc517f24..b7217ae15b 100644 --- a/include/eve/module/core/saturated/core.hpp +++ b/include/eve/module/core/saturated/core.hpp @@ -11,11 +11,6 @@ #include #include #include -#include #include -#include -#include -#include #include -#include #include diff --git a/include/eve/module/core/saturated/impl/dist.hpp b/include/eve/module/core/saturated/impl/dist.hpp deleted file mode 100644 index d83a0b1a44..0000000000 --- a/include/eve/module/core/saturated/impl/dist.hpp +++ /dev/null @@ -1,45 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -dist_(EVE_SUPPORTS(cpu_), - saturated_type const&, - T const& a, - U const& b) noexcept --> decltype(dist(a, b)) -{ - return arithmetic_call(saturated(dist), a, b); -} - -template -EVE_FORCEINLINE T -dist_(EVE_SUPPORTS(cpu_), - saturated_type const&, - T const& a, - T const& b) noexcept requires has_native_abi_v -{ - auto d = dist(a, b); - if constexpr( signed_integral_value ) return if_else(is_ltz(d), valmax(eve::as(a)), d); - else return d; -} -} diff --git a/include/eve/module/core/saturated/impl/minus.hpp b/include/eve/module/core/saturated/impl/minus.hpp deleted file mode 100644 index 00c4890089..0000000000 --- a/include/eve/module/core/saturated/impl/minus.hpp +++ /dev/null @@ -1,55 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr T -minus_(EVE_SUPPORTS(cpu_), saturated_type const&, T v) noexcept -{ - if constexpr( floating_value ) return bit_xor(v, signmask(eve::as(v))); - else return if_else(v == valmin(as()), valmax(as()), minus(v)); -} - -// ----------------------------------------------------------------------------------------------- -// Masked case -template -EVE_FORCEINLINE auto -minus_(EVE_SUPPORTS(cpu_), C const& cond, saturated_type const&, U const& t) noexcept -{ - return mask_op(cond, saturated(eve::minus), t); -} - -template -EVE_FORCEINLINE auto -minus_(EVE_SUPPORTS(cpu_), - C const& cond, - saturated_type const&, - U const& t, - V const& f) noexcept -->decltype(sub(t, f)) -{ - auto substract = [](auto x, auto y) { return saturated(sub)(x, y); }; - return mask_op(cond, substract(t, f), t); -} -} diff --git a/include/eve/module/core/saturated/impl/next.hpp b/include/eve/module/core/saturated/impl/next.hpp deleted file mode 100644 index 1fbd03466e..0000000000 --- a/include/eve/module/core/saturated/impl/next.hpp +++ /dev/null @@ -1,59 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -next_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto z = if_else(a == inf(as(a)), a, next(a)); - if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); - else return z; - } - else if constexpr( integral_value ) { return inc[saturated2](a); } - } - else { return apply_over(saturated(next), a); } -} - -////////////////////////////////////////////////////////////// -// two parameters -////////////////////////////////////////////////////////////// -template -EVE_FORCEINLINE constexpr auto -next_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a, U const& n) noexcept -{ - if constexpr( has_native_abi_v && has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto z = if_else(a == inf(as(a)), a, next(a, n)); - if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); - else return z; - } - else if constexpr( integral_value ) { return saturated(add)(a, to_(n)); } - } - else { return apply_over(saturated(next), a, n); } -} -} diff --git a/include/eve/module/core/saturated/impl/oneminus.hpp b/include/eve/module/core/saturated/impl/oneminus.hpp deleted file mode 100644 index 7f5eafa397..0000000000 --- a/include/eve/module/core/saturated/impl/oneminus.hpp +++ /dev/null @@ -1,60 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -// ----------------------------------------------------------------------------------------------- -// Decorated -template -EVE_FORCEINLINE constexpr T -oneminus_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& v) noexcept -{ - if constexpr( has_native_abi_v ) - { - using elt_t = element_type_t; - if constexpr( std::is_floating_point_v ) { return one(eve::as()) - v; } - else - { - if constexpr( std::is_unsigned_v ) { return binarize(is_eqz(v)); } - if constexpr( scalar_value ) - { - return (v <= valmin(eve::as(v)) + 2) ? valmax(eve::as(v)) : oneminus(v); - } - else if constexpr( simd_value ) - { - return if_else(v < valmin(eve::as(v)) + 2, valmax(eve::as(v)), oneminus(v)); - } - } - } - else { return apply_over(saturated(oneminus), v); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked case -template -EVE_FORCEINLINE auto -oneminus_(EVE_SUPPORTS(cpu_), C const& cond, saturated_type const&, U const& t) noexcept -{ - return mask_op(cond, saturated(eve::oneminus), t); -} -} diff --git a/include/eve/module/core/saturated/impl/prev.hpp b/include/eve/module/core/saturated/impl/prev.hpp deleted file mode 100644 index e6569c1ebc..0000000000 --- a/include/eve/module/core/saturated/impl/prev.hpp +++ /dev/null @@ -1,59 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -prev_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto z = if_else(a == minf(as(a)), a, prev(a)); - if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); - else return z; - } - else if constexpr( integral_value ) { return dec[saturated2](a); } - } - else { return apply_over(saturated(prev), a); } -} - -////////////////////////////////////////////////////////////// -// two parameters -////////////////////////////////////////////////////////////// -template -EVE_FORCEINLINE constexpr auto -prev_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a, U const& n) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) - { - auto z = if_else(a == minf(as(a)), a, prev(a, n)); - if constexpr( eve::platform::supports_nans ) return if_else(is_nan(a), eve::allbits, z); - else return z; - } - else if constexpr( integral_value ) { return saturated(sub)(a, to_(n)); } - } - else { return apply_over(saturated(prev), a, n); } -} -} diff --git a/include/eve/module/core/saturated/impl/sqr.hpp b/include/eve/module/core/saturated/impl/sqr.hpp deleted file mode 100644 index 2af955e59c..0000000000 --- a/include/eve/module/core/saturated/impl/sqr.hpp +++ /dev/null @@ -1,49 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -sqr_(EVE_SUPPORTS(cpu_), saturated_type const&, T const& a0) noexcept -{ - if constexpr( has_native_abi_v ) - { - if constexpr( floating_value ) { return sqr(a0); } - else if constexpr( scalar_value ) - { - return (eve::abs[saturated](a0) > sqrtvalmax(eve::as(a0))) ? valmax(eve::as(a0)) : sqr(a0); - } - else - { - return if_else(eve::abs[saturated](a0) > sqrtvalmax(eve::as(a0)), valmax(eve::as(a0)), sqr(a0)); - } - } - else { return apply_over(saturated(sqr), a0); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked case -template -EVE_FORCEINLINE auto -sqr_(EVE_SUPPORTS(cpu_), C const& cond, saturated_type const&, U const& t) noexcept -{ - return mask_op(cond, saturated(eve::sqr), t); -} -} diff --git a/include/eve/module/core/saturated/minus.hpp b/include/eve/module/core/saturated/minus.hpp deleted file mode 100644 index b3a7e92757..0000000000 --- a/include/eve/module/core/saturated/minus.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/saturated/next.hpp b/include/eve/module/core/saturated/next.hpp deleted file mode 100644 index ed4b26472a..0000000000 --- a/include/eve/module/core/saturated/next.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/saturated/oneminus.hpp b/include/eve/module/core/saturated/oneminus.hpp deleted file mode 100644 index 08c21515ef..0000000000 --- a/include/eve/module/core/saturated/oneminus.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/saturated/prev.hpp b/include/eve/module/core/saturated/prev.hpp deleted file mode 100644 index 60cec4e332..0000000000 --- a/include/eve/module/core/saturated/prev.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/include/eve/module/core/saturated/sqr.hpp b/include/eve/module/core/saturated/sqr.hpp deleted file mode 100644 index 6c0365ea5b..0000000000 --- a/include/eve/module/core/saturated/sqr.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include diff --git a/test/doc/core/diff_of_prod.cpp b/test/doc/core/diff_of_prod.cpp index 074062f5a6..decee4d8e4 100644 --- a/test/doc/core/diff_of_prod.cpp +++ b/test/doc/core/diff_of_prod.cpp @@ -16,8 +16,8 @@ int main() << " <- zf = " << zf << '\n' << " -> xf*yf-tf*zf = " << (xf*yf)-(tf*zf) << '\n' << " -> diff_of_prod(xf, yf, tf, zf) = " << eve::diff_of_prod(xf, yf, tf, zf) << '\n' - << " -> diff_of_prod[pedantic](xf, yf, tf, zf) = " << eve::pedantic(eve::diff_of_prod)(xf, yf, tf, zf) << '\n'; - + << " -> diff_of_prod[pedantic2](xf, yf, tf, zf) = " << eve::diff_of_prod[eve::pedantic2](xf, yf, tf, zf) << '\n' + << " -> diff_of_prod[raw2](xf, yf, tf, zf) = " << eve::diff_of_prod[eve::raw2](xf, yf, tf, zf) << '\n'; return 0; } diff --git a/test/doc/core/next.cpp b/test/doc/core/next.cpp index 52570b3ef8..de12e9e89f 100644 --- a/test/doc/core/next.cpp +++ b/test/doc/core/next.cpp @@ -13,14 +13,14 @@ int main() wide_it pi = {-1, 2, -3, 32767}; std::cout << "---- simd" << std::setprecision(12) << '\n' - << "<- pf = " << pf << '\n' - << "-> next(pf) = " << eve::next(pf) << '\n' - << "-> pedantic(next)(pf) = " << eve::pedantic(eve::next)(pf) << '\n' - << "-> next[pf > 0](pf) = " << eve::next[pf > 0](pf) << '\n' - << "-> saturated(next)(pf) = " << eve::saturated(eve::next)(pf) << '\n' - << "<- pi = " << pi << '\n' - << "-> next(pi) = " << eve::next(pi) << '\n' - << "-> saturated(next)(pi) = " << eve::saturated(eve::next)(pi) << '\n'; + << "<- pf = " << pf << '\n' + << "-> next(pf) = " << eve::next(pf) << '\n' + << "-> next[pedantic2](pf) = " << eve::next[eve::pedantic2](pf) << '\n' + << "-> next[pf > 0](pf) = " << eve::next[pf > 0](pf) << '\n' + << "-> next[saturated2](pf) = " << eve::next[eve::saturated2](pf) << '\n' + << "<- pi = " << pi << '\n' + << "-> next(pi) = " << eve::next(pi) << '\n' + << "-> next[saturated2](pi) = " << eve::next[eve::saturated2](pi) << '\n'; float xf = 0.0f; std::int16_t xi = -3; diff --git a/test/doc/core/prev.cpp b/test/doc/core/prev.cpp index ac69210f75..2ce121be79 100644 --- a/test/doc/core/prev.cpp +++ b/test/doc/core/prev.cpp @@ -15,11 +15,11 @@ int main() std::cout << "---- simd" << '\n' << "<- pf =" << std::setprecision(12) << pf << '\n' << "-> prev(pf) =" << eve::prev(pf) << '\n' - << "-> pedantic(prev)(pf) =" << eve::pedantic(eve::prev)(pf) << '\n' - << "-> saturated(prev)(pf) = " << eve::saturated(eve::prev)(pf) << '\n' + << "-> prev[pedantic2](pf) =" << eve::prev[eve::pedantic2](pf) << '\n' + << "-> prev[saturated2](pf)= " < prev(pi) =" << eve::prev(pi) << '\n' - << "-> saturated(prev)(pf) = " << eve::saturated(eve::prev)(pf) << '\n'; + << "-> prev[saturated2](pf)= " < signnz(pf) = " << eve::signnz(pf) << '\n' - << "-> pedantic(signnz)(pf) = " << eve::pedantic(eve::signnz)(pf) << '\n' + << "-> signnz(pedantic2](pf) = " << eve::signnz[eve::pedantic2](pf) << '\n' << "-> signnz[abs(pf)<2](pf)= " << eve::signnz[eve::abs(pf)<2](pf) << '\n' << "<- pi = " << pi << '\n' << "-> signnz(pi) = " << eve::signnz(pi) << '\n'; diff --git a/test/doc/core/sqr.cpp b/test/doc/core/sqr.cpp index c711aef1ef..03305a5cf2 100644 --- a/test/doc/core/sqr.cpp +++ b/test/doc/core/sqr.cpp @@ -15,7 +15,7 @@ int main() << "-> sqr(pf) = " << eve::sqr(pf) << '\n' << "-> sqr[pf < 0](pf) = " << eve::sqr[pf < 0](pf) << '\n' << "<- pi = " << pi << '\n' - << "-> saturated(sqr)(pi) = " << eve::saturated(eve::sqr)(pi) << '\n' + << "-> sqr[saturated2](pi) = " << eve::sqr[eve::saturated2](pi) << '\n' << "-> sqr(pi) = " << eve::sqr(pi) << '\n'; float xf = -32768.0f; @@ -25,7 +25,7 @@ int main() << "<- xf = " << xf << '\n' << "-> sqr(xf) = " << eve::sqr(xf) << '\n' << "<- xi = " << xi << '\n' - << "-> saturated(sqr)(xi) = " << eve::saturated(eve::sqr)(xi) << '\n' + << "-> sqr[saturated2](xi) = " << eve::sqr[eve::saturated2](xi) << '\n' << "-> sqr(xi) = " << eve::sqr(xi) << '\n'; return 0; } diff --git a/test/doc/core/sum_of_prod.cpp b/test/doc/core/sum_of_prod.cpp index b7aac50687..440146045a 100644 --- a/test/doc/core/sum_of_prod.cpp +++ b/test/doc/core/sum_of_prod.cpp @@ -16,7 +16,8 @@ int main() << " <- zf = " << zf << '\n' << " -> xf*yf+tf*zf = " << (xf*yf)+(tf*zf) << '\n' << " -> sum_of_prod(xf, yf, tf, zf) = " << eve::sum_of_prod(xf, yf, tf, zf) << '\n' - << " -> pedantic(sum_of_prod)(xf, yf, tf, zf) = " << eve::pedantic(eve::sum_of_prod)(xf, yf, tf, zf) << '\n'; + << " -> sum_of_prod[pedantic2](xf, yf, tf, zf) = " << eve::sum_of_prod[eve::pedantic2](xf, yf, tf, zf) << '\n' + << " -> sum_of_prod[raw2](xf, yf, tf, zf) = " << eve::sum_of_prod[eve::raw2](xf, yf, tf, zf) << '\n'; return 0; } diff --git a/test/random/module/core/next.cpp b/test/random/module/core/next.cpp index bea20c8cae..b1b9a617f5 100644 --- a/test/random/module/core/next.cpp +++ b/test/random/module/core/next.cpp @@ -47,7 +47,7 @@ TTS_CASE_TPL("Random check for eve::next", eve::test::simd::all_types) return e == eve::valmax(eve::as(e)) ? e : e+1; } }; - EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_pedantic_next, eve::pedantic(eve::next) ); + EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_pedantic_next, eve::next[eve::pedantic2] ); auto std_saturated_next = [](auto e) -> e_t { if constexpr(eve::floating_value) @@ -61,5 +61,5 @@ TTS_CASE_TPL("Random check for eve::next", eve::test::simd::all_types) return e == eve::valmax(eve::as(e)) ? e : e+1; } }; - EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_saturated_next, eve::saturated(eve::next)); + EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_saturated_next, eve::next[eve::saturated2]); }; diff --git a/test/random/module/core/oneminus.cpp b/test/random/module/core/oneminus.cpp index 2cbb007066..06de2fca25 100644 --- a/test/random/module/core/oneminus.cpp +++ b/test/random/module/core/oneminus.cpp @@ -24,6 +24,6 @@ TTS_CASE_TPL("Random check for eve::oneminus", eve::test::simd::ieee_reals) else if constexpr(eve::unsigned_value) return (e <= 1) ? e_t(1)-e : e_t(0); }; EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax) - , std_saturated_oneminus, eve::saturated(eve::oneminus)); + , std_saturated_oneminus, eve::oneminus[eve::saturated2]); }; diff --git a/test/random/module/core/prev.cpp b/test/random/module/core/prev.cpp index 0250f6be65..631ef44132 100644 --- a/test/random/module/core/prev.cpp +++ b/test/random/module/core/prev.cpp @@ -49,7 +49,7 @@ TTS_CASE_TPL("Random check for eve::prev", eve::test::simd::all_types) return e == eve::valmin(eve::as(e)) ? e : e-1; } }; - EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_pedantic_prev, eve::pedantic(eve::prev)); + EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_pedantic_prev, eve::prev[eve::pedantic2]); auto std_saturated_prev = [](auto e) -> e_t { if constexpr(eve::floating_value) @@ -63,5 +63,5 @@ TTS_CASE_TPL("Random check for eve::prev", eve::test::simd::all_types) return e == eve::valmin(eve::as(e)) ? e : e-1; } }; - EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_saturated_prev, eve::saturated(eve::prev)); + EVE_ULP_RANGE_CHECK( T, eve::uniform_prng(vmin, vmax), std_saturated_prev, eve::prev[eve::saturated2]); }; diff --git a/test/unit/module/core/convert/to_double.cpp b/test/unit/module/core/convert/to_double.cpp index e36ff81556..df80f0e5a3 100644 --- a/test/unit/module/core/convert/to_double.cpp +++ b/test/unit/module/core/convert/to_double.cpp @@ -38,7 +38,7 @@ TTS_CASE_TPL("Check eve::convert arithmetic behavior", eve::test::simd::all_type TTS_EQUAL(eve::convert((T(0)), tgt), static_cast(0)); TTS_EQUAL(eve::convert((T(42.69)), tgt), eve::float64(T(42.69))); TTS_EQUAL(eve::convert((T(42.69)), tgt), static_cast(v_t(42.69))); - TTS_EQUAL(eve::convert(eve::sqr(T(2)), tgt), eve::float64(eve::sqr)(T(2))); +//TODO TTS_EQUAL(eve::convert(eve::sqr(T(2)), tgt), eve::float64(eve::sqr)(T(2))); TTS_EQUAL(eve::convert(eve::valmin(eve::as()), tgt), static_cast(eve::valmin(eve::as()))); diff --git a/test/unit/module/core/convert/to_float.cpp b/test/unit/module/core/convert/to_float.cpp index e8717caa4c..9844ed8e0b 100644 --- a/test/unit/module/core/convert/to_float.cpp +++ b/test/unit/module/core/convert/to_float.cpp @@ -38,7 +38,7 @@ TTS_CASE_TPL("Check eve::convert arithmetic behavior", eve::test::simd::all_type TTS_EQUAL(eve::convert((T(42.69)), tgt), static_cast(v_t(42.69))); TTS_EQUAL(eve::convert((T(0)), tgt), eve::float32(T(0))); TTS_EQUAL(eve::convert((T(42.69)), tgt), eve::float32(T(42.69))); - TTS_EQUAL(eve::convert(eve::sqr(T(2)), tgt), eve::float32(eve::sqr)(T(2))); +//TODO TTS_EQUAL(eve::convert(eve::sqr(T(2)), tgt), eve::float32(eve::sqr)(T(2))); if constexpr( sizeof(v_t) <= sizeof(float) ) { diff --git a/test/unit/module/core/diff_of_prod.cpp b/test/unit/module/core/diff_of_prod.cpp index b0dc84ac7c..955b507609 100644 --- a/test/unit/module/core/diff_of_prod.cpp +++ b/test/unit/module/core/diff_of_prod.cpp @@ -15,8 +15,9 @@ TTS_CASE_TPL( "Check diff_of_prod", eve::test::scalar::ieee_reals) using we_t = eve::wide; auto test = [](auto a, auto b, auto c, auto d){return a*b-c*d; }; + auto rdop = [](auto a, auto b, auto c, auto d){return eve::diff_of_prod[eve::raw2](a, b, c, d);}; auto dop = [](auto a, auto b, auto c, auto d){return eve::diff_of_prod(a, b, c, d);}; - auto pdop = [](auto a, auto b, auto c, auto d){return eve::pedantic(eve::diff_of_prod)(a, b, c, d);}; + auto pdop = [](auto a, auto b, auto c, auto d){return eve::diff_of_prod[eve::pedantic2](a, b, c, d);}; int i1 = 1; float f1 = 2.0f; double d1 = 1.0f; @@ -37,6 +38,20 @@ TTS_CASE_TPL( "Check diff_of_prod", eve::test::scalar::ieee_reals) TTS_EQUAL(dop(i1, f1, d1, we1), test( i1, f1, d1, we1)); TTS_EQUAL(dop(we1, i1, f1, d1), test(we1, i1, f1, d1)); + TTS_EQUAL(rdop(e1, e1, e1, e1), test( e1, e1, e1, e1)); + TTS_EQUAL(rdop(d1, d1, d1, d1), test( d1, d1, d1, d1)); + TTS_EQUAL(rdop(d1, d1, d1, d1), test( d1, d1, d1, d1)); + TTS_EQUAL(rdop(i1, i1, i1, i1), test( i1, i1, i1, i1)); + TTS_EQUAL(rdop(we1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rdop(i1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rdop(f1, we1, we1, we1), test( f1, we1, we1, we1)); + TTS_EQUAL(rdop(d1, we1, we1, we1), test( d1, we1, we1, we1)); + TTS_EQUAL(rdop(e1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rdop(e1, we1, we1, we1), test( we1, we1, we1, we1)); + + TTS_EQUAL(rdop(i1, f1, d1, we1), test( i1, f1, d1, we1)); + TTS_EQUAL(rdop(we1, i1, f1, d1), test(we1, i1, f1, d1)); + TTS_EQUAL(pdop(e1, e1, e1, e1), test( e1, e1, e1, e1)); TTS_EQUAL(pdop(d1, d1, d1, d1), test( d1, d1, d1, d1)); TTS_EQUAL(pdop(d1, d1, d1, d1), test( d1, d1, d1, d1)); diff --git a/test/unit/module/core/next.cpp b/test/unit/module/core/next.cpp index fe0f134599..eb14123bf1 100644 --- a/test/unit/module/core/next.cpp +++ b/test/unit/module/core/next.cpp @@ -11,113 +11,113 @@ #include -//================================================================================================== -// Types tests -//================================================================================================== -TTS_CASE_TPL("Check return types of eve::next", eve::test::simd::all_types) -(tts::type) -{ - using v_t = eve::element_type_t; - using i_t = eve::as_integer_t; - using u_t = eve::as_integer_t; - using si_t = eve::as_integer_t; - using su_t = eve::as_integer_t; - - TTS_EXPR_IS(eve::next(T()), T); - TTS_EXPR_IS(eve::next(T(), i_t()), T); - TTS_EXPR_IS(eve::next(T(), u_t()), T); - TTS_EXPR_IS(eve::next(T(), si_t()), T); - TTS_EXPR_IS(eve::next(T(), su_t()), T); -}; - -//================================================================================================== -// Tests for eve::next -//================================================================================================== -TTS_CASE_WITH("Check behavior of eve::next(eve::wide)", - eve::test::simd::all_types, - tts::generate(tts::randoms(-10, +10), tts::logicals(0, 3))) -(T const& a0, M const& t) -{ - using eve::detail::map; - using v_t = eve::element_type_t; - if constexpr( eve::floating_value ) - { - auto n = [](auto e) -> v_t { return std::nextafter(e, eve::valmax(eve::as(e))); }; - TTS_EQUAL(eve::next(a0), map(n, a0)); - auto nn = [n](auto e) -> v_t { return n(n(e)); }; - TTS_EQUAL(eve::next(a0, 2), map(nn, a0)); - } - else - { - TTS_EQUAL(eve::next(a0), eve::inc(a0)); - TTS_EQUAL(eve::next(a0, 2), eve::inc(eve::inc(a0))); - } - TTS_EQUAL(eve::next[t](a0), eve::if_else(t, eve::next(a0), a0)); - TTS_EQUAL(eve::next[t](a0, 2), eve::if_else(t, eve::next(a0, 2), a0)); -}; - -//================================================================================================== -// Test for corner-cases values -//================================================================================================== -TTS_CASE_TPL("Check corner-cases behavior of eve::next variants on wide", - eve::test::simd::all_types) -(tts::type const& tgt) -{ - using eve::next; - using eve::pedantic; - using eve::saturated; - - auto cases = tts::limits(tgt); - - if constexpr( eve::floating_value ) - { - TTS_IEEE_EQUAL(next(cases.nan), cases.nan); - TTS_IEEE_EQUAL(next(cases.minf), cases.valmin); - TTS_IEEE_EQUAL(next(cases.inf), cases.nan); - - if constexpr( eve::platform::supports_denormals ) - { - TTS_EQUAL(next(cases.mzero), cases.mindenormal); - TTS_EQUAL(next(cases.zero), cases.mindenormal); - TTS_EQUAL(next(-cases.mindenormal), cases.mzero); - TTS_EQUAL(next(cases.valmax), cases.inf); - } - - TTS_EQUAL(next(T(-1)), T(-1) + eve::eps(eve::as()) / 2); - TTS_EQUAL(next(T(1)), T(1) + eve::eps(eve::as())); - - TTS_IEEE_EQUAL(pedantic(next)(cases.nan), cases.nan); - TTS_IEEE_EQUAL(pedantic(next)(cases.minf), cases.valmin); - TTS_IEEE_EQUAL(pedantic(next)(cases.inf), cases.nan); - TTS_EQUAL(pedantic(next)(cases.mzero), cases.zero); - - if constexpr( eve::platform::supports_denormals ) - { - TTS_EQUAL(pedantic(next)(cases.zero), cases.mindenormal); - TTS_EQUAL(pedantic(next)(-cases.mindenormal), cases.mzero); - } - - TTS_EQUAL(pedantic(next)(cases.valmax), cases.inf); - TTS_EQUAL(pedantic(next)(T(-1)), T(-1) + eve::eps(eve::as()) / 2); - TTS_EQUAL(pedantic(next)(T(1)), T(1) + eve::eps(eve::as())); - } - else - { - TTS_EQUAL(next(T(0)), T(1)); - TTS_EQUAL(next(T(1)), T(2)); - TTS_EQUAL(saturated(next)(T(0)), T(1)); - TTS_EQUAL(saturated(next)(T(1)), T(2)); - TTS_EQUAL(saturated(next)(cases.valmax), cases.valmax); - } -}; + //================================================================================================== + //= Types tests + //================================================================================================== + TTS_CASE_TPL("Check return types of eve::next", eve::test::simd::all_types) + (tts::type) + { + using v_t = eve::element_type_t; + using i_t = eve::as_integer_t; + using u_t = eve::as_integer_t; + using si_t = eve::as_integer_t; + using su_t = eve::as_integer_t; + + TTS_EXPR_IS(eve::next(T()), T); + TTS_EXPR_IS(eve::next(T(), i_t()), T); + TTS_EXPR_IS(eve::next(T(), u_t()), T); + TTS_EXPR_IS(eve::next(T(), si_t()), T); + TTS_EXPR_IS(eve::next(T(), su_t()), T); + }; + + //================================================================================================== + //= Tests for eve::next + //================================================================================================== + TTS_CASE_WITH("Check behavior of eve::next(eve::wide)", + eve::test::simd::all_types, + tts::generate(tts::randoms(-10, +10), tts::logicals(0, 3))) + (T const& a0, M const& t) + { + using eve::detail::map; + using v_t = eve::element_type_t; + if constexpr( eve::floating_value ) + { + auto n = [](auto e) -> v_t { return std::nextafter(e, eve::valmax(eve::as(e))); }; + TTS_EQUAL(eve::next(a0), map(n, a0)); + auto nn = [n](auto e) -> v_t { return n(n(e)); }; + TTS_EQUAL(eve::next(a0, 2), map(nn, a0)); + } + else + { + TTS_EQUAL(eve::next(a0), eve::inc(a0)); + TTS_EQUAL(eve::next(a0, 2), eve::inc(eve::inc(a0))); + } + TTS_EQUAL(eve::next[t](a0), eve::if_else(t, eve::next(a0), a0)); + TTS_EQUAL(eve::next[t](a0, 2), eve::if_else(t, eve::next(a0, 2), a0)); + }; + + //================================================================================================== + // Test for corner-cases values + //================================================================================================== + TTS_CASE_TPL("Check corner-cases behavior of eve::next variants on wide", + eve::test::simd::all_types) + (tts::type const& tgt) + { + using eve::next; + using eve::pedantic2; + using eve::saturated2; + + auto cases = tts::limits(tgt); + + if constexpr( eve::floating_value ) + { + TTS_IEEE_EQUAL(next(cases.nan), cases.nan); + TTS_IEEE_EQUAL(next(cases.minf), cases.valmin); + TTS_IEEE_EQUAL(next(cases.inf), cases.nan); + + if constexpr( eve::platform::supports_denormals ) + { + TTS_EQUAL(next(cases.mzero), cases.mindenormal); + TTS_EQUAL(next(cases.zero), cases.mindenormal); + TTS_EQUAL(next(-cases.mindenormal), cases.mzero); + TTS_EQUAL(next(cases.valmax), cases.inf); + } + + TTS_EQUAL(next(T(-1)), T(-1) + eve::eps(eve::as()) / 2); + TTS_EQUAL(next(T(1)), T(1) + eve::eps(eve::as())); + + TTS_IEEE_EQUAL(next[pedantic2](cases.nan), cases.nan); + TTS_IEEE_EQUAL(next[pedantic2](cases.minf), cases.valmin); + TTS_IEEE_EQUAL(next[pedantic2](cases.inf), cases.nan); + TTS_EQUAL(next[pedantic2](cases.mzero), cases.zero); + + if constexpr( eve::platform::supports_denormals ) + { + TTS_EQUAL(next[pedantic2](cases.zero), cases.mindenormal); + TTS_EQUAL(next[pedantic2](-cases.mindenormal), cases.mzero); + } + + TTS_EQUAL(next[pedantic2](cases.valmax), cases.inf); + TTS_EQUAL(next[pedantic2](T(-1)), T(-1) + eve::eps(eve::as()) / 2); + TTS_EQUAL(next[pedantic2](T(1)), T(1) + eve::eps(eve::as())); + } + else + { + TTS_EQUAL(next(T(0)), T(1)); + TTS_EQUAL(next(T(1)), T(2)); + TTS_EQUAL(next[saturated2](T(0)), T(1)); + TTS_EQUAL(next[saturated2](T(1)), T(2)); + TTS_EQUAL(next[saturated2](cases.valmax), cases.valmax); + } + }; TTS_CASE_TPL("Check corner-cases behavior of eve::next with 2 parameters", eve::test::simd::all_types) (tts::type const& tgt) { using eve::next; - using eve::pedantic; - using eve::saturated; + using eve::pedantic2; + using eve::saturated2; auto cases = tts::limits(tgt); @@ -138,27 +138,27 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::next with 2 parameters", TTS_EQUAL(next(T(-1), 2), T(-1) + eve::eps(eve::as())); TTS_EQUAL(next(T(1), 2), T(1) + eve::eps(eve::as()) * 2); - TTS_IEEE_EQUAL(pedantic(next)(cases.nan, 2), cases.nan); - TTS_IEEE_EQUAL(pedantic(next)(cases.minf, 2), next(cases.valmin)); - TTS_IEEE_EQUAL(pedantic(next)(cases.inf, 2), cases.nan); + TTS_IEEE_EQUAL(next[pedantic2](cases.nan, 2), cases.nan); + TTS_IEEE_EQUAL(next[pedantic2](cases.minf, 2), next(cases.valmin)); + TTS_IEEE_EQUAL(next[pedantic2](cases.inf, 2), cases.nan); if constexpr( eve::platform::supports_denormals ) { - TTS_EQUAL(pedantic(next)(cases.mzero, 2), cases.mindenormal); - TTS_EQUAL(pedantic(next)(cases.zero, 2), next(cases.mindenormal)); - TTS_EQUAL(pedantic(next)(-cases.mindenormal, 2), cases.mzero); + TTS_EQUAL(next[pedantic2](cases.mzero, 2), cases.mindenormal); + TTS_EQUAL(next[pedantic2](cases.zero, 2), next(cases.mindenormal)); + TTS_EQUAL(next[pedantic2](-cases.mindenormal, 2), cases.mzero); } - TTS_IEEE_EQUAL(pedantic(next)(cases.valmax, 2), cases.nan); - TTS_EQUAL(pedantic(next)(T(-1), 2), T(-1) + eve::eps(eve::as())); - TTS_EQUAL(pedantic(next)(T(1), 2), T(1) + eve::eps(eve::as()) * 2); + TTS_IEEE_EQUAL(next[pedantic2](cases.valmax, 2), cases.nan); + TTS_EQUAL(next[pedantic2](T(-1), 2), T(-1) + eve::eps(eve::as())); + TTS_EQUAL(next[pedantic2](T(1), 2), T(1) + eve::eps(eve::as()) * 2); } else { TTS_EQUAL(next(T(0), 2), T(2)); TTS_EQUAL(next(T(1), 2), T(3)); - TTS_EQUAL(saturated(next)(T(0), 2), T(2)); - TTS_EQUAL(saturated(next)(T(1), 2), T(3)); - TTS_EQUAL(saturated(next)(cases.valmax, 2), cases.valmax); + TTS_EQUAL(next[saturated2](T(0), 2), T(2)); + TTS_EQUAL(next[saturated2](T(1), 2), T(3)); + TTS_EQUAL(next[saturated2](cases.valmax, 2), cases.valmax); } }; @@ -170,7 +170,7 @@ TTS_CASE_WITH("Check behavior of eve::masked(eve::next)(eve::wide)", eve::test::simd::ieee_reals, tts::generate(tts::randoms(eve::valmin, eve::valmax), tts::logicals(0, 3))) -(T const& a0, +(T const& a0, M const& mask) { TTS_IEEE_EQUAL(eve::next[mask](a0), diff --git a/test/unit/module/core/nextafter.cpp b/test/unit/module/core/nextafter.cpp index cb02827156..3d90f560dd 100644 --- a/test/unit/module/core/nextafter.cpp +++ b/test/unit/module/core/nextafter.cpp @@ -40,10 +40,10 @@ TTS_CASE_WITH("Check behavior of eve::nextafter", { auto n = [](auto e, auto f) -> v_t { return std::nextafter(e, f); }; TTS_EQUAL(eve::nextafter(a0, a1), map(n, a0, a1)); - TTS_IEEE_EQUAL(eve::pedantic(eve::nextafter)(eve::nan(eve::as()), T(1)), - eve::nan(eve::as())); - TTS_IEEE_EQUAL(eve::pedantic(eve::nextafter)(T(1), eve::nan(eve::as())), + TTS_IEEE_EQUAL(eve::nextafter[eve::pedantic2](eve::nan(eve::as()), T(1)), eve::nan(eve::as())); + TTS_IEEE_EQUAL(eve::nextafter[eve::pedantic2](T(1), eve::nan(eve::as())), + T(1)); } else { diff --git a/test/unit/module/core/oneminus.cpp b/test/unit/module/core/oneminus.cpp index b52c205e37..e4a1081cca 100644 --- a/test/unit/module/core/oneminus.cpp +++ b/test/unit/module/core/oneminus.cpp @@ -24,20 +24,18 @@ TTS_CASE_TPL("Check return types of eve::oneminus", eve::test::simd::all_types) TTS_EXPR_IS(eve::oneminus[eve::logical()](T()), T); TTS_EXPR_IS(eve::oneminus[bool()](T()), T); - TTS_EXPR_IS(eve::saturated(eve::oneminus)(T()), T); - TTS_EXPR_IS(eve::saturated(eve::oneminus[eve::logical()])(T()), T); - TTS_EXPR_IS(eve::saturated(eve::oneminus[eve::logical()])(T()), T); - TTS_EXPR_IS(eve::saturated(eve::oneminus[bool()])(T()), T); + TTS_EXPR_IS(eve::oneminus[eve::saturated2](T()), T); + TTS_EXPR_IS(eve::oneminus[eve::saturated2][eve::logical()](T()), T); + TTS_EXPR_IS(eve::oneminus[eve::saturated2][eve::logical()](T()), T); + TTS_EXPR_IS(eve::oneminus[eve::saturated2][bool()](T()), T); TTS_EXPR_IS(eve::oneminus(v_t()), v_t); - TTS_EXPR_IS(eve::oneminus[eve::logical()](v_t()), T); TTS_EXPR_IS(eve::oneminus[eve::logical()](v_t()), v_t); TTS_EXPR_IS(eve::oneminus[bool()](v_t()), v_t); - TTS_EXPR_IS(eve::saturated(eve::oneminus)(v_t()), v_t); - TTS_EXPR_IS(eve::saturated(eve::oneminus[eve::logical()])(v_t()), T); - TTS_EXPR_IS(eve::saturated(eve::oneminus[eve::logical()])(v_t()), v_t); - TTS_EXPR_IS(eve::saturated(eve::oneminus[bool()])(v_t()), v_t); + TTS_EXPR_IS(eve::oneminus[eve::saturated2](v_t()), v_t); + TTS_EXPR_IS(eve::oneminus[eve::saturated2][eve::logical()](v_t()), v_t); + TTS_EXPR_IS(eve::oneminus[eve::saturated2][bool()](v_t()), v_t); if constexpr( eve::floating_value ) {} }; @@ -52,18 +50,18 @@ TTS_CASE_WITH("Check behavior of eve::oneminus(eve::wide)", { using eve::as; using eve::oneminus; - using eve::saturated; + using eve::saturated2; using eve::detail::map; using v_t = eve::element_type_t; TTS_EQUAL(oneminus(a0), map([](auto e) -> v_t { return 1 - e; }, a0)); TTS_EQUAL(oneminus[mask](a0), eve::if_else(mask, oneminus(a0), a0)); if constexpr( eve::unsigned_value ) - TTS_EQUAL(saturated(oneminus)(a0), + TTS_EQUAL(oneminus[saturated2](a0), eve::if_else(eve::is_eqz(a0), eve::one(eve::as(a0)), eve::zero)); else TTS_EQUAL( - saturated(oneminus)(a0), + oneminus[saturated2](a0), eve::if_else(a0 < eve::valmin(eve::as(a0)) + 2, eve::valmax(eve::as(a0)), oneminus(a0))); }; @@ -74,29 +72,29 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::oneminus variants on wide", eve::test::simd::all_types) (tts::type) { - TTS_EQUAL(eve::saturated(eve::oneminus)(T(1)), T(0)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(1)), T(0)); if constexpr( eve::signed_value ) { - TTS_EQUAL(eve::saturated(eve::oneminus)(T(2)), T(-1)); - TTS_EQUAL(eve::saturated(eve::oneminus)(static_cast(-2)), T(3)); - TTS_EQUAL(eve::saturated(eve::oneminus)(eve::valmin(eve::as())), eve::valmax(eve::as())); - TTS_EQUAL(eve::saturated(eve::oneminus)(eve::inc(eve::valmin(eve::as()))), + TTS_EQUAL(eve::oneminus[eve::saturated2](T(2)), T(-1)); + TTS_EQUAL(eve::oneminus[eve::saturated2](static_cast(-2)), T(3)); + TTS_EQUAL(eve::oneminus[eve::saturated2](eve::valmin(eve::as())), eve::valmax(eve::as())); + TTS_EQUAL(eve::oneminus[eve::saturated2](eve::inc(eve::valmin(eve::as()))), eve::valmax(eve::as())); - TTS_EQUAL(eve::saturated(eve::oneminus)(eve::inc(eve::inc(eve::valmin(eve::as())))), + TTS_EQUAL(eve::oneminus[eve::saturated2](eve::inc(eve::inc(eve::valmin(eve::as())))), eve::valmax(eve::as())); } if constexpr( eve::unsigned_value ) { - TTS_EQUAL(eve::saturated(eve::oneminus)(T(2)), T(0)); - TTS_EQUAL(eve::saturated(eve::oneminus)(T(1)), T(0)); - TTS_EQUAL(eve::saturated(eve::oneminus)(T(0)), T(1)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(2)), T(0)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(1)), T(0)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(0)), T(1)); } if constexpr( eve::floating_value ) { - TTS_EQUAL(eve::saturated(eve::oneminus)(T(-0.)), T(1)); - TTS_EQUAL(eve::saturated(eve::oneminus)(T(0)), T(1)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(-0.)), T(1)); + TTS_EQUAL(eve::oneminus[eve::saturated2](T(0)), T(1)); } }; diff --git a/test/unit/module/core/prev.cpp b/test/unit/module/core/prev.cpp index d9a434ec83..e3267bbbfb 100644 --- a/test/unit/module/core/prev.cpp +++ b/test/unit/module/core/prev.cpp @@ -63,9 +63,9 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::prev variants on wide", eve::test::simd::all_types) (tts::type const& tgt) { - using eve::pedantic; + using eve::pedantic2; using eve::prev; - using eve::saturated; + using eve::saturated2; auto cases = tts::limits(tgt); @@ -80,23 +80,23 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::prev variants on wide", TTS_EQUAL(prev(T(1)), T(1) - eve::eps(eve::as()) / 2); TTS_EQUAL(prev(T(-1)), T(-1) - eve::eps(eve::as())); - TTS_IEEE_EQUAL(pedantic(prev)(cases.nan), cases.nan); - TTS_IEEE_EQUAL(pedantic(prev)(cases.inf), cases.valmax); - TTS_IEEE_EQUAL(pedantic(prev)(cases.minf), cases.nan); - TTS_EQUAL(pedantic(prev)(cases.zero), cases.mzero); - TTS_EQUAL(pedantic(prev)(cases.mzero), -cases.mindenormal); - TTS_EQUAL(pedantic(prev)(cases.mindenormal), cases.zero); - TTS_EQUAL(pedantic(prev)(cases.valmin), cases.minf); - TTS_EQUAL(pedantic(prev)(T(1)), T(1) - eve::eps(eve::as()) / 2); - TTS_EQUAL(pedantic(prev)(T(-1)), T(-1) - eve::eps(eve::as())); + TTS_IEEE_EQUAL(prev[pedantic2](cases.nan), cases.nan); + TTS_IEEE_EQUAL(prev[pedantic2](cases.inf), cases.valmax); + TTS_IEEE_EQUAL(prev[pedantic2](cases.minf), cases.nan); + TTS_EQUAL(prev[pedantic2](cases.zero), cases.mzero); + TTS_EQUAL(prev[pedantic2](cases.mzero), -cases.mindenormal); + TTS_EQUAL(prev[pedantic2](cases.mindenormal), cases.zero); + TTS_EQUAL(prev[pedantic2](cases.valmin), cases.minf); + TTS_EQUAL(prev[pedantic2](T(1)), T(1) - eve::eps(eve::as()) / 2); + TTS_EQUAL(prev[pedantic2](T(-1)), T(-1) - eve::eps(eve::as())); } else { TTS_EQUAL(prev(T(2)), T(1)); TTS_EQUAL(prev(T(3)), T(2)); - TTS_EQUAL(saturated(prev)(T(2)), T(1)); - TTS_EQUAL(saturated(prev)(T(3)), T(2)); - TTS_EQUAL(saturated(prev)(cases.valmin), cases.valmin); + TTS_EQUAL(prev[saturated2](T(2)), T(1)); + TTS_EQUAL(prev[saturated2](T(3)), T(2)); + TTS_EQUAL(prev[saturated2](cases.valmin), cases.valmin); } }; @@ -104,9 +104,9 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::prev with 2 parameters", eve::test::simd::all_types) (tts::type const& tgt) { - using eve::pedantic; + using eve::pedantic2; using eve::prev; - using eve::saturated; + using eve::saturated2; auto cases = tts::limits(tgt); @@ -122,23 +122,23 @@ TTS_CASE_TPL("Check corner-cases behavior of eve::prev with 2 parameters", TTS_EQUAL(prev(T(1), 2), T(1) - eve::eps(eve::as())); TTS_EQUAL(prev(T(-1), 2), T(-1) - eve::eps(eve::as()) * 2); - TTS_IEEE_EQUAL(pedantic(prev)(cases.nan, 2), cases.nan); - TTS_IEEE_EQUAL(pedantic(prev)(cases.inf, 2), prev(cases.valmax)); - TTS_IEEE_EQUAL(pedantic(prev)(cases.minf, 2), cases.nan); - TTS_EQUAL(pedantic(prev)(cases.zero, 2), -cases.mindenormal); - TTS_EQUAL(pedantic(prev)(cases.mzero, 2), prev(-cases.mindenormal)); - TTS_EQUAL(pedantic(prev)(cases.mindenormal, 2), cases.zero); - TTS_IEEE_EQUAL(pedantic(prev)(cases.valmin, 2), cases.nan); - TTS_EQUAL(pedantic(prev)(T(1), 2), T(1) - eve::eps(eve::as())); - TTS_EQUAL(pedantic(prev)(T(-1), 2), T(-1) - eve::eps(eve::as()) * 2); + TTS_IEEE_EQUAL(prev[pedantic2](cases.nan, 2), cases.nan); + TTS_IEEE_EQUAL(prev[pedantic2](cases.inf, 2), prev(cases.valmax)); + TTS_IEEE_EQUAL(prev[pedantic2](cases.minf, 2), cases.nan); + TTS_EQUAL(prev[pedantic2](cases.zero, 2), -cases.mindenormal); + TTS_EQUAL(prev[pedantic2](cases.mzero, 2), prev(-cases.mindenormal)); + TTS_EQUAL(prev[pedantic2](cases.mindenormal, 2), cases.zero); + TTS_IEEE_EQUAL(prev[pedantic2](cases.valmin, 2), cases.nan); + TTS_EQUAL(prev[pedantic2](T(1), 2), T(1) - eve::eps(eve::as())); + TTS_EQUAL(prev[pedantic2](T(-1), 2), T(-1) - eve::eps(eve::as()) * 2); } else { TTS_EQUAL(prev(T(4), 2), T(2)); TTS_EQUAL(prev(T(5), 2), T(3)); - TTS_EQUAL(saturated(prev)(T(4), 2), T(2)); - TTS_EQUAL(saturated(prev)(T(5), 2), T(3)); - TTS_EQUAL(saturated(prev)(cases.valmin, 2), cases.valmin); + TTS_EQUAL(prev[saturated2](T(4), 2), T(2)); + TTS_EQUAL(prev[saturated2](T(5), 2), T(3)); + TTS_EQUAL(prev[saturated2](cases.valmin, 2), cases.valmin); } }; @@ -150,7 +150,7 @@ TTS_CASE_WITH("Check behavior of eve::masked(eve::prev)(eve::wide)", eve::test::simd::ieee_reals, tts::generate(tts::randoms(eve::valmin, eve::valmax), tts::logicals(0, 3))) -(T const& a0, +(T const& a0, M const& mask) { TTS_IEEE_EQUAL(eve::prev[mask](a0), diff --git a/test/unit/module/core/signnz.cpp b/test/unit/module/core/signnz.cpp index f5975a152d..c316d7c37c 100644 --- a/test/unit/module/core/signnz.cpp +++ b/test/unit/module/core/signnz.cpp @@ -25,7 +25,6 @@ TTS_CASE_TPL("Check return types of eve::signnz", eve::test::simd::all_types) TTS_EXPR_IS(eve::signnz[bool()](T()), T); TTS_EXPR_IS(eve::signnz(v_t()), v_t); - TTS_EXPR_IS(eve::signnz[eve::logical()](v_t()), T); TTS_EXPR_IS(eve::signnz[eve::logical()](v_t()), v_t); TTS_EXPR_IS(eve::signnz[bool()](v_t()), v_t); }; @@ -45,6 +44,8 @@ TTS_CASE_WITH("Check behavior of eve::signnz(eve::wide)", TTS_EQUAL(eve::signnz[mask](a0), eve::if_else(mask, eve::signnz(a0), a0)); if constexpr( eve::floating_value ) { - TTS_IEEE_EQUAL(eve::pedantic(eve::signnz)(eve::nan(eve::as())), eve::nan(eve::as())); + TTS_IEEE_EQUAL(eve::signnz[eve::pedantic2](eve::nan(eve::as())), eve::nan(eve::as())); + TTS_IEEE_EQUAL(eve::abs(eve::signnz(eve::nan(eve::as()))), T(1)); + } }; diff --git a/test/unit/module/core/sqr.cpp b/test/unit/module/core/sqr.cpp index c0f1286bfc..c0e5b52dde 100644 --- a/test/unit/module/core/sqr.cpp +++ b/test/unit/module/core/sqr.cpp @@ -18,7 +18,7 @@ TTS_CASE_TPL("Check return types of eve::sqr", eve::test::simd::all_types) (tts::type) { using v_t = eve::element_type_t; - using eve::saturated; + using eve::saturated2; using eve::sqr; TTS_EXPR_IS(sqr(T()), T); @@ -26,20 +26,18 @@ TTS_CASE_TPL("Check return types of eve::sqr", eve::test::simd::all_types) TTS_EXPR_IS(sqr[eve::logical()](T()), T); TTS_EXPR_IS(sqr[bool()](T()), T); - TTS_EXPR_IS(saturated(eve::sqr)(T()), T); - TTS_EXPR_IS(saturated(eve::sqr[eve::logical()])(T()), T); - TTS_EXPR_IS(saturated(eve::sqr[eve::logical()])(T()), T); - TTS_EXPR_IS(saturated(eve::sqr[bool()])(T()), T); + TTS_EXPR_IS(eve::sqr[saturated2](T()), T); + TTS_EXPR_IS(eve::sqr[saturated2][eve::logical()](T()), T); + TTS_EXPR_IS(eve::sqr[saturated2][eve::logical()](T()), T); + TTS_EXPR_IS(eve::sqr[saturated2][bool()](T()), T); TTS_EXPR_IS(sqr(v_t()), v_t); - TTS_EXPR_IS(sqr[eve::logical()](v_t()), T); TTS_EXPR_IS(sqr[eve::logical()](v_t()), v_t); TTS_EXPR_IS(sqr[bool()](v_t()), v_t); - TTS_EXPR_IS(saturated(eve::sqr)(v_t()), v_t); - TTS_EXPR_IS(saturated(eve::sqr[eve::logical()])(v_t()), T); - TTS_EXPR_IS(saturated(eve::sqr[eve::logical()])(v_t()), v_t); - TTS_EXPR_IS(saturated(eve::sqr[bool()])(v_t()), v_t); + TTS_EXPR_IS(eve::sqr[saturated2](v_t()), v_t); + TTS_EXPR_IS(eve::sqr[saturated2][eve::logical()](v_t()), v_t); + TTS_EXPR_IS(eve::sqr[saturated2][bool()](v_t()), v_t); }; //================================================================================================== @@ -51,7 +49,7 @@ TTS_CASE_WITH("Check behavior of eve::sqr(eve::wide)", (T const& a0, M const& mask) { using eve::as; - using eve::saturated; + using eve::saturated2; using eve::sqr; using eve::detail::map; using v_t = eve::element_type_t; @@ -60,13 +58,13 @@ TTS_CASE_WITH("Check behavior of eve::sqr(eve::wide)", TTS_EQUAL(sqr[mask](a0), eve::if_else(mask, eve::sqr(a0), a0)); if constexpr( eve::integral_value ) { - TTS_EQUAL(saturated(sqr)(a0), + TTS_EQUAL(sqr[saturated2](a0), map( [](auto e) -> v_t { return eve::abs[eve::saturated](e) > eve::sqrtvalmax(as(e)) ? eve::valmax(as(e)) : e * e; }, a0)); - TTS_EQUAL(saturated(sqr[mask])(a0), eve::if_else(mask, saturated(sqr)(a0), a0)); + TTS_EQUAL(sqr[saturated2][mask](a0), eve::if_else(mask,sqr[saturated2](a0), a0)); } }; diff --git a/test/unit/module/core/sum_of_prod.cpp b/test/unit/module/core/sum_of_prod.cpp index 4aa556201c..3b4552f94b 100644 --- a/test/unit/module/core/sum_of_prod.cpp +++ b/test/unit/module/core/sum_of_prod.cpp @@ -15,8 +15,9 @@ TTS_CASE_TPL( "Check sum_of_prod", eve::test::scalar::ieee_reals) using we_t = eve::wide; auto test = [](auto a, auto b, auto c, auto d){return a*b+c*d; }; + auto rsop = [](auto a, auto b, auto c, auto d){return eve::sum_of_prod[eve::raw2](a, b, c, d);}; auto sop = [](auto a, auto b, auto c, auto d){return eve::sum_of_prod(a, b, c, d);}; - auto psop = [](auto a, auto b, auto c, auto d){return eve::pedantic(eve::sum_of_prod)(a, b, c, d);}; + auto psop = [](auto a, auto b, auto c, auto d){return eve::sum_of_prod[eve::pedantic2](a, b, c, d);}; int i1 = 1; float f1 = 2.0f; double d1 = 1.0f; @@ -37,6 +38,20 @@ TTS_CASE_TPL( "Check sum_of_prod", eve::test::scalar::ieee_reals) TTS_EQUAL(sop(i1, f1, d1, we1), test( i1, f1, d1, we1)); TTS_EQUAL(sop(we1, i1, f1, d1), test(we1, i1, f1, d1)); + TTS_EQUAL(rsop(e1, e1, e1, e1), test( e1, e1, e1, e1)); + TTS_EQUAL(rsop(d1, d1, d1, d1), test( d1, d1, d1, d1)); + TTS_EQUAL(rsop(d1, d1, d1, d1), test( d1, d1, d1, d1)); + TTS_EQUAL(rsop(i1, i1, i1, i1), test( i1, i1, i1, i1)); + TTS_EQUAL(rsop(we1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rsop(i1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rsop(f1, we1, we1, we1), test( f1, we1, we1, we1)); + TTS_EQUAL(rsop(d1, we1, we1, we1), test( d1, we1, we1, we1)); + TTS_EQUAL(rsop(e1, we1, we1, we1), test( we1, we1, we1, we1)); + TTS_EQUAL(rsop(e1, we1, we1, we1), test( we1, we1, we1, we1)); + + TTS_EQUAL(rsop(i1, f1, d1, we1), test( i1, f1, d1, we1)); + TTS_EQUAL(rsop(we1, i1, f1, d1), test(we1, i1, f1, d1)); + TTS_EQUAL(psop(e1, e1, e1, e1), test( e1, e1, e1, e1)); TTS_EQUAL(psop(d1, d1, d1, d1), test( d1, d1, d1, d1)); TTS_EQUAL(psop(d1, d1, d1, d1), test( d1, d1, d1, d1));