From f2a4f2d324685421bf620ee81c3b5561fd4d17b2 Mon Sep 17 00:00:00 2001 From: jtlap Date: Fri, 15 Mar 2024 22:45:17 +0100 Subject: [PATCH] Arc-trigo and other math functions refurbished --- include/eve/module/math/pedantic/atan2.hpp | 11 -- include/eve/module/math/pedantic/impl/arg.hpp | 27 ----- .../eve/module/math/pedantic/impl/atan2.hpp | 66 ----------- .../eve/module/math/pedantic/impl/atan2d.hpp | 34 ------ .../eve/module/math/pedantic/impl/atan2pi.hpp | 33 ------ include/eve/module/math/pedantic/math.hpp | 5 +- include/eve/module/math/regular/acosd.hpp | 29 +++-- include/eve/module/math/regular/acosh.hpp | 49 ++++++-- include/eve/module/math/regular/acot.hpp | 33 +++++- include/eve/module/math/regular/acotd.hpp | 25 +++- include/eve/module/math/regular/acoth.hpp | 35 ++++-- include/eve/module/math/regular/acotpi.hpp | 27 ++++- include/eve/module/math/regular/acsc.hpp | 34 ++++-- include/eve/module/math/regular/acscd.hpp | 28 ++++- include/eve/module/math/regular/acsch.hpp | 28 ++++- include/eve/module/math/regular/acscpi.hpp | 27 ++++- include/eve/module/math/regular/agd.hpp | 30 ++++- include/eve/module/math/regular/asech.hpp | 28 ++++- include/eve/module/math/regular/asin.hpp | 99 ++++++++++++++-- include/eve/module/math/regular/asind.hpp | 27 ++++- include/eve/module/math/regular/asinh.hpp | 73 +++++++++++- include/eve/module/math/regular/asinpi.hpp | 27 ++++- include/eve/module/math/regular/atan.hpp | 30 ++++- include/eve/module/math/regular/atan2.hpp | 71 ++++++++++- include/eve/module/math/regular/atan2d.hpp | 31 ++++- include/eve/module/math/regular/atan2pi.hpp | 30 ++++- include/eve/module/math/regular/atand.hpp | 28 ++++- include/eve/module/math/regular/atanh.hpp | 41 +++++-- include/eve/module/math/regular/atanpi.hpp | 29 ++++- include/eve/module/math/regular/deginrad.hpp | 28 +++-- .../eve/module/math/regular/impl/acosh.hpp | 56 --------- include/eve/module/math/regular/impl/acot.hpp | 42 ------- .../eve/module/math/regular/impl/acotd.hpp | 39 ------ .../eve/module/math/regular/impl/acoth.hpp | 39 ------ .../eve/module/math/regular/impl/acotpi.hpp | 39 ------ include/eve/module/math/regular/impl/acsc.hpp | 38 ------ .../eve/module/math/regular/impl/acscd.hpp | 39 ------ .../eve/module/math/regular/impl/acsch.hpp | 38 ------ .../eve/module/math/regular/impl/acscpi.hpp | 39 ------ include/eve/module/math/regular/impl/agd.hpp | 43 ------- include/eve/module/math/regular/impl/arg.hpp | 31 ----- .../eve/module/math/regular/impl/asech.hpp | 38 ------ include/eve/module/math/regular/impl/asin.hpp | 112 ------------------ .../eve/module/math/regular/impl/asind.hpp | 40 ------- .../eve/module/math/regular/impl/asinh.hpp | 85 ------------- .../eve/module/math/regular/impl/asinpi.hpp | 40 ------- include/eve/module/math/regular/impl/atan.hpp | 42 ------- .../eve/module/math/regular/impl/atan2.hpp | 54 --------- .../eve/module/math/regular/impl/atan2d.hpp | 47 -------- .../eve/module/math/regular/impl/atan2pi.hpp | 45 ------- .../eve/module/math/regular/impl/atand.hpp | 39 ------ .../eve/module/math/regular/impl/atanh.hpp | 49 -------- .../eve/module/math/regular/impl/atanpi.hpp | 39 ------ .../module/math/regular/impl/significants.hpp | 35 ------ include/eve/module/math/regular/radindeg.hpp | 35 +++++- include/eve/module/math/regular/radinpi.hpp | 32 ++++- .../eve/module/math/regular/significants.hpp | 53 ++++++++- test/unit/module/math/atan2.cpp | 66 +++++------ 58 files changed, 872 insertions(+), 1485 deletions(-) delete mode 100644 include/eve/module/math/pedantic/atan2.hpp delete mode 100644 include/eve/module/math/pedantic/impl/arg.hpp delete mode 100644 include/eve/module/math/pedantic/impl/atan2.hpp delete mode 100644 include/eve/module/math/pedantic/impl/atan2d.hpp delete mode 100644 include/eve/module/math/pedantic/impl/atan2pi.hpp delete mode 100644 include/eve/module/math/regular/impl/acosh.hpp delete mode 100644 include/eve/module/math/regular/impl/acot.hpp delete mode 100644 include/eve/module/math/regular/impl/acotd.hpp delete mode 100644 include/eve/module/math/regular/impl/acoth.hpp delete mode 100644 include/eve/module/math/regular/impl/acotpi.hpp delete mode 100644 include/eve/module/math/regular/impl/acsc.hpp delete mode 100644 include/eve/module/math/regular/impl/acscd.hpp delete mode 100644 include/eve/module/math/regular/impl/acsch.hpp delete mode 100644 include/eve/module/math/regular/impl/acscpi.hpp delete mode 100644 include/eve/module/math/regular/impl/agd.hpp delete mode 100644 include/eve/module/math/regular/impl/arg.hpp delete mode 100644 include/eve/module/math/regular/impl/asech.hpp delete mode 100644 include/eve/module/math/regular/impl/asin.hpp delete mode 100644 include/eve/module/math/regular/impl/asind.hpp delete mode 100644 include/eve/module/math/regular/impl/asinh.hpp delete mode 100644 include/eve/module/math/regular/impl/asinpi.hpp delete mode 100644 include/eve/module/math/regular/impl/atan.hpp delete mode 100644 include/eve/module/math/regular/impl/atan2.hpp delete mode 100644 include/eve/module/math/regular/impl/atan2d.hpp delete mode 100644 include/eve/module/math/regular/impl/atan2pi.hpp delete mode 100644 include/eve/module/math/regular/impl/atand.hpp delete mode 100644 include/eve/module/math/regular/impl/atanh.hpp delete mode 100644 include/eve/module/math/regular/impl/atanpi.hpp delete mode 100644 include/eve/module/math/regular/impl/significants.hpp diff --git a/include/eve/module/math/pedantic/atan2.hpp b/include/eve/module/math/pedantic/atan2.hpp deleted file mode 100644 index 4910ae1035..0000000000 --- a/include/eve/module/math/pedantic/atan2.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/math/pedantic/impl/arg.hpp b/include/eve/module/math/pedantic/impl/arg.hpp deleted file mode 100644 index 9a6311da8d..0000000000 --- a/include/eve/module/math/pedantic/impl/arg.hpp +++ /dev/null @@ -1,27 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -arg_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - auto z = if_else(is_negative(a), pi(eve::as(a)), eve::zero); - if constexpr( platform::supports_nans ) { return if_else(is_nan(a), eve::allbits, z); } - else { return z; } - } - else { return apply_over(pedantic(arg), a); } -} -} diff --git a/include/eve/module/math/pedantic/impl/atan2.hpp b/include/eve/module/math/pedantic/impl/atan2.hpp deleted file mode 100644 index 2e5be49512..0000000000 --- a/include/eve/module/math/pedantic/impl/atan2.hpp +++ /dev/null @@ -1,66 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - U const& b) noexcept --> common_value_t -{ - return arithmetic_call(pedantic(atan2), a, b); -} - -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a0, - T const& a1) noexcept requires has_native_abi_v -{ - if constexpr( scalar_value && platform::supports_nans ) - { - if( is_unordered(a0, a1) ) return nan(eve::as(a0)); - } - T a00 = a0, a10 = a1; - auto test1 = eve::is_infinite(a0) && eve::is_infinite(a1); - if constexpr( platform::supports_infinites ) - { - a00 = eve::if_else(test1, eve::copysign(one(eve::as(a0)), a00), a00); - a10 = eve::if_else(test1, eve::copysign(one(eve::as(a0)), a10), a10); - } - - T q = eve::abs(a00 / a10); - T z = atan_kernel(q, rec(q)); - T sgn = signnz(a0); - if constexpr( scalar_value ) - { - z = (is_positive(a10) ? z : pi(eve::as()) - z) * sgn; - return is_eqz(a00) ? if_else(is_negative(a10), pi(eve::as(a00)) * sgn, eve::zero) : z; - } - else - { - z = eve::if_else(eve::is_positive(a10), z, eve::pi(eve::as(a0)) - z) * sgn; - z = eve::if_else(eve::is_eqz(a00), - eve::if_else(eve::is_negative(a10), eve::pi(eve::as(a0)) * sgn, eve::zero), - z); - if constexpr( platform::supports_nans ) - return eve::if_else(is_unordered(a00, a10), eve::allbits, z); - else return z; - } -} -} diff --git a/include/eve/module/math/pedantic/impl/atan2d.hpp b/include/eve/module/math/pedantic/impl/atan2d.hpp deleted file mode 100644 index 6d9cc18154..0000000000 --- a/include/eve/module/math/pedantic/impl/atan2d.hpp +++ /dev/null @@ -1,34 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, U const& b) noexcept -{ - return arithmetic_call(pedantic(atan2d), a, b); -} - -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - T const& b) noexcept requires has_native_abi_v -{ - return radindeg(pedantic(atan2)(a, b)); -} - -} diff --git a/include/eve/module/math/pedantic/impl/atan2pi.hpp b/include/eve/module/math/pedantic/impl/atan2pi.hpp deleted file mode 100644 index 424a69bd76..0000000000 --- a/include/eve/module/math/pedantic/impl/atan2pi.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 - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), pedantic_type const&, T const& a, U const& b) noexcept -{ - return arithmetic_call(pedantic(atan2pi), a, b); -} - -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), - pedantic_type const&, - T const& a, - T const& b) noexcept requires has_native_abi_v -{ - return radinpi(pedantic(atan2)(a, b)); -} -} diff --git a/include/eve/module/math/pedantic/math.hpp b/include/eve/module/math/pedantic/math.hpp index c8a70d1770..05825819f3 100644 --- a/include/eve/module/math/pedantic/math.hpp +++ b/include/eve/module/math/pedantic/math.hpp @@ -7,9 +7,8 @@ //================================================================================================== #pragma once -#include -#include -#include +// #include +// #include #include #include #include diff --git a/include/eve/module/math/regular/acosd.hpp b/include/eve/module/math/regular/acosd.hpp index b8a58f3edf..234f80cc9e 100644 --- a/include/eve/module/math/regular/acosd.hpp +++ b/include/eve/module/math/regular/acosd.hpp @@ -15,14 +15,14 @@ namespace eve { -template -struct acosd_t : elementwise_callable -{ - template - constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + template + struct acosd_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } - EVE_CALLABLE_OBJECT(acosd_t, acosd_); -}; + EVE_CALLABLE_OBJECT(acosd_t, acosd_); + }; //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -66,15 +66,14 @@ struct acosd_t : elementwise_callable //! @godbolt{doc/math/regular/acosd.cpp} //! @} //================================================================================================ -inline constexpr auto acosd = functor; + inline constexpr auto acosd = functor; -namespace detail -{ - template - constexpr EVE_FORCEINLINE T acosd_(EVE_REQUIRES(cpu_), O const& o, T const& a0) + namespace detail { - if constexpr( has_native_abi_v ) return radindeg(acos[o](a0)); - else return apply_over(acosd[o], a0); + template + constexpr EVE_FORCEINLINE T acosd_(EVE_REQUIRES(cpu_), O const& o, T const& a0) + { + return radindeg(acos[o](a0)); + } } } -} diff --git a/include/eve/module/math/regular/acosh.hpp b/include/eve/module/math/regular/acosh.hpp index fd7e2ac0a0..73d6c90530 100644 --- a/include/eve/module/math/regular/acosh.hpp +++ b/include/eve/module/math/regular/acosh.hpp @@ -7,10 +7,26 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct acosh_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acosh_t, acosh_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -50,22 +66,33 @@ namespace eve //! * If the element is \f$1\f$, \f$+0\f$ is returned. //! * If the element is \f$+\infty\f$, \f$+\infty\f$ is returned. //! * If the element is a `Nan`, `NaN` is returned. -//! +//! //! @groupheader{Example} //! //! @godbolt{doc/math/regular/acosh.cpp} //! //! @} //================================================================================================ -namespace tag -{ - struct acosh_; -} + inline constexpr auto acosh = functor; -template<> struct supports_optimized_conversion : std::true_type -{}; + namespace detail + { + template + constexpr EVE_FORCEINLINE T acosh_(EVE_REQUIRES(cpu_), O const&, T const& x) + { + const T t = dec(x); + auto const test = is_greater(t, inv_2eps(eve::as())); -EVE_MAKE_CALLABLE(acosh_, acosh); + if constexpr( simd_value ) + { + const T z = if_else(test, x, t + sqrt(fma(t, t, t + t))); + return add[test](log1p(z), log_2(eve::as())); + } + else if constexpr( scalar_value ) + { + if( test ) { return eve::log(t) + log_2(eve::as()); } + else { return eve::log1p(t + eve::sqrt(fma(t, t, t + t))); } + } + } + } } - -#include diff --git a/include/eve/module/math/regular/acot.hpp b/include/eve/module/math/regular/acot.hpp index bc665bbddc..429abd3e96 100644 --- a/include/eve/module/math/regular/acot.hpp +++ b/include/eve/module/math/regular/acot.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct acot_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acot_t, acot_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -53,8 +66,20 @@ namespace eve //! @godbolt{doc/math/regular/acot.cpp} //! @} //================================================================================================ + inline constexpr auto acot = functor; -EVE_MAKE_CALLABLE(acot_, acot); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acot_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + if constexpr( has_native_abi_v ) + { + auto x = eve::abs(a); + return bit_xor(atan_kernel(rec(x), x), bitofsign(a)); + } + else + return apply_over(acot, a); + } + } } - -#include diff --git a/include/eve/module/math/regular/acotd.hpp b/include/eve/module/math/regular/acotd.hpp index 7098d8b8a1..eb91765365 100644 --- a/include/eve/module/math/regular/acotd.hpp +++ b/include/eve/module/math/regular/acotd.hpp @@ -7,10 +7,21 @@ //================================================================================================== #pragma once -#include +#include +#include +#include namespace eve { + template + struct acotd_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acotd_t, acotd_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -56,8 +67,14 @@ namespace eve //! @godbolt{doc/math/regular/acotd.cpp} //! @} //================================================================================================ + inline constexpr auto acotd = functor; -EVE_MAKE_CALLABLE(acotd_, acotd); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acotd_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return radindeg(acot(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/acoth.hpp b/include/eve/module/math/regular/acoth.hpp index 19dbadafaf..882fb8da4a 100644 --- a/include/eve/module/math/regular/acoth.hpp +++ b/include/eve/module/math/regular/acoth.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include + +#include +#include +#include +#include namespace eve { + template + struct acoth_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acoth_t, acoth_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -29,7 +42,7 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::floating_value T > T acoth(T x) noexcept; +//! template< eve::floating_value T > T acoth(T x) noexcept; //! } //! @endcode //! @@ -53,14 +66,14 @@ namespace eve //! @godbolt{doc/math/regular/acoth.cpp} //! @} //================================================================================================ -namespace tag -{ - struct acoth_; -} + inline constexpr auto acoth = functor; -template<> struct supports_optimized_conversion : std::true_type -{}; -EVE_MAKE_CALLABLE(acoth_, acoth); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acoth_(EVE_REQUIRES(cpu_), O const&, T const& x) + { + return eve::atanh(rec(x)); + } + } } - -#include diff --git a/include/eve/module/math/regular/acotpi.hpp b/include/eve/module/math/regular/acotpi.hpp index 0211b36014..25aec332df 100644 --- a/include/eve/module/math/regular/acotpi.hpp +++ b/include/eve/module/math/regular/acotpi.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct acotpi_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acotpi_t, acotpi_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -54,8 +67,14 @@ namespace eve //! @godbolt{doc/math/regular/acotpi.cpp} //! @} //================================================================================================ + inline constexpr auto acotpi = functor; -EVE_MAKE_CALLABLE(acotpi_, acotpi); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acotpi_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return radinpi(acot(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/acsc.hpp b/include/eve/module/math/regular/acsc.hpp index 9d59f99156..88c209aee8 100644 --- a/include/eve/module/math/regular/acsc.hpp +++ b/include/eve/module/math/regular/acsc.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct acsc_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acsc_t, acsc_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -54,15 +67,14 @@ namespace eve //! @godbolt{doc/math/regular/acsc.cpp} //! @} //================================================================================================ -namespace tag -{ - struct acsc_; -} - -template<> struct supports_optimized_conversion : std::true_type -{}; + inline constexpr auto acsc = functor; -EVE_MAKE_CALLABLE(acsc_, acsc); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acsc_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return eve::asin(rec(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/acscd.hpp b/include/eve/module/math/regular/acscd.hpp index 424aa5d361..2e5e6c477d 100644 --- a/include/eve/module/math/regular/acscd.hpp +++ b/include/eve/module/math/regular/acscd.hpp @@ -7,10 +7,24 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct acscd_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acscd_t, acscd_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -55,8 +69,14 @@ namespace eve //! @godbolt{doc/math/regular/acscd.cpp} //! @} //================================================================================================ + inline constexpr auto acscd = functor; -EVE_MAKE_CALLABLE(acscd_, acscd); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acscd_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return radindeg(acsc(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/acsch.hpp b/include/eve/module/math/regular/acsch.hpp index e4e756e7c4..d1955b5797 100644 --- a/include/eve/module/math/regular/acsch.hpp +++ b/include/eve/module/math/regular/acsch.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct acsch_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acsch_t, acsch_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -54,7 +67,14 @@ namespace eve //! @godbolt{doc/math/regular/acsch.cpp} //! @} //================================================================================================ -EVE_MAKE_CALLABLE(acsch_, acsch); -} + inline constexpr auto acsch = functor; -#include + namespace detail + { + template + constexpr EVE_FORCEINLINE T acsch_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return asinh(rec(a)); + } + } +} diff --git a/include/eve/module/math/regular/acscpi.hpp b/include/eve/module/math/regular/acscpi.hpp index edd73fbcb3..03ee05d272 100644 --- a/include/eve/module/math/regular/acscpi.hpp +++ b/include/eve/module/math/regular/acscpi.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct acscpi_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(acscpi_t, acscpi_); +}; //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -55,8 +68,14 @@ namespace eve //! @godbolt{doc/math/regular/acscpi.cpp} //! @} //================================================================================================ + inline constexpr auto acscpi = functor; -EVE_MAKE_CALLABLE(acscpi_, acscpi); + namespace detail + { + template + constexpr EVE_FORCEINLINE T acscpi_(EVE_REQUIRES(cpu_), O const&, T const& a) + { + return radinpi(acsc(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/agd.hpp b/include/eve/module/math/regular/agd.hpp index 5b5250619f..da37b9fd4f 100644 --- a/include/eve/module/math/regular/agd.hpp +++ b/include/eve/module/math/regular/agd.hpp @@ -6,11 +6,24 @@ */ //================================================================================================== #pragma once - -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct agd_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(agd_t, agd_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -55,7 +68,14 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(agd_, agd); -} + inline constexpr auto agd = functor; -#include + namespace detail + { + template + constexpr EVE_FORCEINLINE T agd_(EVE_REQUIRES(cpu_), O const&, T const& x) + { + return 2*atanh(tan(x*half(as(x)))); + } + } +} diff --git a/include/eve/module/math/regular/asech.hpp b/include/eve/module/math/regular/asech.hpp index 901431ea77..e8eebec8e6 100644 --- a/include/eve/module/math/regular/asech.hpp +++ b/include/eve/module/math/regular/asech.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct asech_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(asech_t, asech_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -56,7 +69,14 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(asech_, asech); -} + inline constexpr auto asech = functor; -#include + namespace detail + { + template + constexpr EVE_FORCEINLINE T asech_(EVE_REQUIRES(cpu_), O const&, T const& x) + { + return acosh(rec(x)); + } + } +} diff --git a/include/eve/module/math/regular/asin.hpp b/include/eve/module/math/regular/asin.hpp index 0a9e0b5a73..8ec0535e7b 100644 --- a/include/eve/module/math/regular/asin.hpp +++ b/include/eve/module/math/regular/asin.hpp @@ -7,10 +7,27 @@ //================================================================================================== #pragma once -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct asin_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(asin_t, asin_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -58,15 +75,73 @@ namespace eve //! //! @} //================================================================================================ -namespace tag -{ - struct asin_; -} - -template<> struct supports_optimized_conversion : std::true_type -{}; + inline constexpr auto asin = functor; -EVE_MAKE_CALLABLE(asin_, asin); + namespace detail + { + template + constexpr EVE_FORCEINLINE T + asin_(EVE_REQUIRES(cpu_), O const&, T const& a0) noexcept + { + using elt_t = element_type_t; + auto x = eve::abs(a0); + auto sgn = eve::bitofsign(a0); + if constexpr( std::is_same_v ) + { + const auto x_larger_05 = x > half(eve::as()); + T z = if_else(x_larger_05, half(eve::as()) * oneminus(x), eve::sqr(x)); + x = if_else(x_larger_05, sqrt(z), x); + T z1 = + eve::reverse_horner(z, T(0x1.5555c8p-3f), T(0x1.3301ecp-4f), T(0x1.747d8ep-5f) + , T(0x1.8c2fc6p-6f), T(0x1.5966a4p-5f)); + ; + z1 = fma(z1, z * x, x); + z = if_else(x_larger_05, pio_2(eve::as()) - (z1 + z1), z1); + return eve::bit_xor(z, sgn); + } + else if constexpr( std::is_same_v ) + { + auto small = x < sqrteps(eve::as()); + if constexpr( scalar_value ) // early scalar return + { + if( small ) return a0; + if( (x > one(eve::as())) ) return nan(eve::as()); + } + else if constexpr( simd_value ) // simd preparation + { + x = if_else(x > one(eve::as()), eve::allbits, x); + } + auto case_1 = [](const T& x) { // x < 0.625 + auto zz1 = eve::oneminus(x); + auto num = zz1*eve::reverse_horner(zz1, T(0x1.c896240f3081dp+4), T(-0x1.991aaac01ab68p+4), T(0x1.bdff5baf33e6ap+2) + , T(-0x1.2079259f9290fp-1), T(0x1.84fc3988e9f08p-9)); + auto den = eve::reverse_horner(zz1, T(0x1.56709b0b644bep+8), T(-0x1.7fe08959063eep+8), T(0x1.26219af6a7f42p+7) + , T(-0x1.5f2a2b6bf5d8cp+4), T(0x1.0p0)); + auto vp = num / den; + zz1 = sqrt(zz1 + zz1); + auto z = pio_4(eve::as()) - zz1; + zz1 = fms(zz1, vp, T(0x1.1a62633145c07p-54)); // pio_2lo + z = z - zz1; + zz1 = z + pio_4(eve::as()); + return zz1; + }; + auto case_2 = [](const T& x) { // x >= 0.625 + T zz2 = sqr(x); + auto num = zz2 * eve::reverse_horner(zz2, T(-0x1.0656c06ceafd5p+3), T(0x1.39007da779259p+4), T(-0x1.04331de27907bp+4) + , T(0x1.5c74b178a2dd9p+2), T(-0x1.34341333e5c16p-1), T(0x1.16b9b0bd48ad3p-8)); + auto den = + eve::reverse_horner(zz2, T(-0x1.898220a3607acp+5), T(0x1.1705684ffbf9dp+7), T(-0x1.265bb6d3576d7p+7) + , T(0x1.19fc025fe9054p+6), T(-0x1.d7b590b5e0eabp+3), T(0x1.0p0)); + auto z = num / den; + zz2 = fma(x, z, x); + return zz2; + }; + auto ct1 = T(0x1.4000000000000p-1); // 0.625; + auto xgtct1 = x > ct1; + auto res = branch>(xgtct1, case_1, case_2)(x); + if constexpr( simd_value ) { res = if_else(small, x, res); } + return bit_xor(res, sgn); + } + } + } } - -#include diff --git a/include/eve/module/math/regular/asind.hpp b/include/eve/module/math/regular/asind.hpp index 1db921b983..b065559c61 100644 --- a/include/eve/module/math/regular/asind.hpp +++ b/include/eve/module/math/regular/asind.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct asind_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(asind_t, asind_); + }; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -54,8 +67,14 @@ namespace eve //! @godbolt{doc/math/regular/asind.cpp} //! @} //================================================================================================ + inline constexpr auto asind = functor; -EVE_MAKE_CALLABLE(asind_, asind); + namespace detail + { + template + constexpr EVE_FORCEINLINE T asind_(EVE_REQUIRES(cpu_), O const&, T const& a0) + { + return radindeg(asin(a0)); + } + } } - -#include diff --git a/include/eve/module/math/regular/asinh.hpp b/include/eve/module/math/regular/asinh.hpp index 1429ca4377..a84e72efb0 100644 --- a/include/eve/module/math/regular/asinh.hpp +++ b/include/eve/module/math/regular/asinh.hpp @@ -7,10 +7,27 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct asinh_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(asinh_t, asinh_); +}; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -69,7 +86,55 @@ namespace eve //! //! @} //================================================================================================ -EVE_MAKE_CALLABLE(asinh_, asinh); -} + inline constexpr auto asinh = functor; -#include + namespace detail + { + template + constexpr EVE_FORCEINLINE T asinh_(EVE_REQUIRES(cpu_), O const&, T const& a0) + { + using vt_t = element_type_t; + T x = eve::abs(a0); + if constexpr( scalar_value ) + if( x < sqrteps(eve::as()) ) return a0; // scalar early return + auto x_gt_oneosqrteps = x > oneosqrteps(eve::as()); + auto bts = bitofsign(a0); + if constexpr( std::is_same_v ) + { + if constexpr( scalar_value ) // faster for great or small values + { + if( x_gt_oneosqrteps ) return bit_xor(log(x) + log_2(eve::as()), bts); + else if( x >= eve::half(eve::as()) ) + return bit_xor(log(x + hypot(one(eve::as()), x)), bts); + } + // remaining scalar case and all simd cases to avoid multiple computations as + // this one is always ok + T z = if_else(x_gt_oneosqrteps, dec(x), x + sqr(x) / eve::inc(hypot(one(eve::as()), x))); + if constexpr( eve::platform::supports_infinites ) z = if_else((x == inf(eve::as())), x, z); + z = add[x_gt_oneosqrteps](eve::log1p(z), log_2(eve::as())); + return bit_xor(z, bts); + } + else if constexpr( std::is_same_v ) + { + auto x_lt_half = x < half(eve::as()); + T x2 = sqr(x); + T z = zero(eve::as()); + std::size_t nb = eve::count_true(x_lt_half); + if( nb > 0 ) + { + z = eve::reverse_horner(x2, T(0x1.000000p+0f), T(-0x1.55535ap-3f), T(0x1.329362p-4f) + , T(-0x1.5dcb02p-5f), T(0x1.49adccp-6f))* x; + if( nb >= cardinal_v ) return bit_xor(z, bts); + } + auto case_1 = [](T const& x) { return x; }; // great x + auto case_2 = [](T const& x) { return average(x, hypot(one(eve::as()), x)); }; // lesser x + auto tmp = branch>(x_gt_oneosqrteps, case_1, case_2)(x); + auto z1 = bit_xor(if_else(x_lt_half, z, log(tmp) + log_2(eve::as())), bts); + if constexpr( eve::platform::supports_invalids ) + return if_else(is_nan(a0), eve::allbits, z1); + else + return z1; + } + } + } +} diff --git a/include/eve/module/math/regular/asinpi.hpp b/include/eve/module/math/regular/asinpi.hpp index 261d018582..87035f97d4 100644 --- a/include/eve/module/math/regular/asinpi.hpp +++ b/include/eve/module/math/regular/asinpi.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct asinpi_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(asinpi_t, asinpi_); + }; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -52,8 +65,14 @@ namespace eve //! @godbolt{doc/math/regular/asinpi.cpp} //! @} //================================================================================================ + inline constexpr auto asinpi = functor; -EVE_MAKE_CALLABLE(asinpi_, asinpi); + namespace detail + { + template + constexpr EVE_FORCEINLINE T asinpi_(EVE_REQUIRES(cpu_), O const& , T const& a0) + { + return radinpi(asin(a0)); + } + } } - -#include diff --git a/include/eve/module/math/regular/atan.hpp b/include/eve/module/math/regular/atan.hpp index 4cab7a1d6c..1446b807b2 100644 --- a/include/eve/module/math/regular/atan.hpp +++ b/include/eve/module/math/regular/atan.hpp @@ -7,10 +7,24 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct atan_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(atan_t, atan_); + }; + + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -57,9 +71,15 @@ namespace eve //! //! @} //================================================================================================ + inline constexpr auto atan = functor; - -EVE_MAKE_CALLABLE(atan_, atan); + namespace detail + { + template + constexpr EVE_FORCEINLINE T atan_(EVE_REQUIRES(cpu_), O const& , T const& a) + { + T x = eve::abs(a); + return bit_xor(atan_kernel(x, rec(x)), bitofsign(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/atan2.hpp b/include/eve/module/math/regular/atan2.hpp index 00a182a7ac..a4ccefa849 100644 --- a/include/eve/module/math/regular/atan2.hpp +++ b/include/eve/module/math/regular/atan2.hpp @@ -7,10 +7,25 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct atan2_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T v, U w) const noexcept + { return EVE_DISPATCH_CALL(v, w); } + + EVE_CALLABLE_OBJECT(atan2_t, atan2_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -81,8 +96,56 @@ namespace eve //! * If `x` is \f$\pm0\f$ and `y` is \f$\pm+0\f$, \f$+\frac\pi2\f$ is returned //! @} //================================================================================================ + inline constexpr auto atan2 = functor; -EVE_MAKE_CALLABLE(atan2_, atan2); -} + namespace detail + { + template + constexpr EVE_FORCEINLINE common_value_t + atan2_(EVE_REQUIRES(cpu_), O const&, T const& a0, const U a1) noexcept + { + using r_t = common_value_t; + r_t a00(a0); + r_t a10(a1); + if constexpr(O::contains(pedantic2)) + { + if constexpr(scalar_value && platform::supports_nans) + { + if (is_unordered(a00, a10)) return nan(eve::as(a00)); + } + auto test1 = eve::is_infinite(a00) && eve::is_infinite(a10); + if constexpr(platform::supports_infinites) + { + a00 = eve::if_else(test1, eve::copysign(one(eve::as(a00)), a00), a00); + a10 = eve::if_else(test1, eve::copysign(one(eve::as(a00)), a10), a10); + } -#include + r_t q = eve::abs(a00/a10); + r_t z = atan_kernel(q, rec(q)); + r_t sgn = signnz(a00); + if constexpr(scalar_value) + { + z = (is_positive(a10)? z: pi(eve::as())-z)*sgn; + return is_eqz(a00) ? if_else(is_negative(a10), pi(eve::as(a00))*sgn, eve::zero) : z; + } + else + { + z = eve::if_else(eve::is_positive(a10), z, eve::pi(eve::as(a0))-z)*sgn; + z = eve::if_else( eve::is_eqz(a00), + eve::if_else( eve::is_negative(a10), eve::pi(eve::as(a00))*sgn, eve::zero), + z); + if constexpr(platform::supports_nans) + return eve::if_else( is_unordered(a00, a10), eve::allbits, z); + else + return z; + } + } + else + { + auto q = eve::abs(a00/a10); + auto z = detail::atan_kernel(q, eve::rec(q)); + return if_else(is_positive(a10), z, (pi(eve::as(a00)) - z))*signnz(a00); + } + } + } +} diff --git a/include/eve/module/math/regular/atan2d.hpp b/include/eve/module/math/regular/atan2d.hpp index 4db9b14871..5baa16efc2 100644 --- a/include/eve/module/math/regular/atan2d.hpp +++ b/include/eve/module/math/regular/atan2d.hpp @@ -7,10 +7,25 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct atan2d_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T v, U w) const noexcept + { return EVE_DISPATCH_CALL(v, w); } + + EVE_CALLABLE_OBJECT(atan2d_t, atan2d_); + }; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -81,9 +96,15 @@ namespace eve //! * If `x` is \f$\pm0\f$ and `y` is \f$\pm+0\f$, \f$+90\f$ is returned //! @} //================================================================================================ + inline constexpr auto atan2d = functor; - -EVE_MAKE_CALLABLE(atan2d_, atan2d); + namespace detail + { + template + constexpr EVE_FORCEINLINE common_value_t + atan2d_(EVE_REQUIRES(cpu_), O const& o, T const& a0, const U a1) noexcept + { + return radindeg(atan2[o](a0, a1)); + } + } } - -#include diff --git a/include/eve/module/math/regular/atan2pi.hpp b/include/eve/module/math/regular/atan2pi.hpp index 19707a219c..4cd287548a 100644 --- a/include/eve/module/math/regular/atan2pi.hpp +++ b/include/eve/module/math/regular/atan2pi.hpp @@ -7,10 +7,25 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct atan2pi_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE common_value_t operator()(T v, U w) const noexcept + { return EVE_DISPATCH_CALL(v, w); } + + EVE_CALLABLE_OBJECT(atan2pi_t, atan2pi_); + }; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -81,8 +96,15 @@ namespace eve //! * If `x` is \f$\pm0\f$ and `y` is \f$\pm+0\f$, \f$+\frac12\f$ is returned //! @} //================================================================================================ + inline constexpr auto atan2pi = functor; -EVE_MAKE_CALLABLE(atan2pi_, atan2pi); + namespace detail + { + template + constexpr EVE_FORCEINLINE common_value_t + atan2pi_(EVE_REQUIRES(cpu_), O const& o, T const& a0, const U a1) noexcept + { + return radinpi(atan2[o](a0, a1)); + } + } } - -#include diff --git a/include/eve/module/math/regular/atand.hpp b/include/eve/module/math/regular/atand.hpp index 46cc9563a1..a38a14bfde 100644 --- a/include/eve/module/math/regular/atand.hpp +++ b/include/eve/module/math/regular/atand.hpp @@ -7,10 +7,24 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { +template +struct atand_t : elementwise_callable +{ + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(atand_t, atand_); +}; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -54,8 +68,14 @@ namespace eve //! @godbolt{doc/math/regular/atand.cpp} //! @} //================================================================================================ + inline constexpr auto atand = functor; -EVE_MAKE_CALLABLE(atand_, atand); + namespace detail + { + template + constexpr EVE_FORCEINLINE T atand_(EVE_REQUIRES(cpu_), O const& , T const& a) + { + return radindeg(atan(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/atanh.hpp b/include/eve/module/math/regular/atanh.hpp index 75ff10cc65..ed199c4624 100644 --- a/include/eve/module/math/regular/atanh.hpp +++ b/include/eve/module/math/regular/atanh.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include namespace eve { + template + struct atanh_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(atanh_t, atanh_); + }; + //================================================================================================ //! @addtogroup math_invhyper //! @{ @@ -69,15 +82,21 @@ namespace eve //! //! @} //================================================================================================ -namespace tag -{ - struct atanh_; -} - -template<> struct supports_optimized_conversion : std::true_type -{}; + inline constexpr auto atanh = functor; - EVE_MAKE_CALLABLE(atanh_, atanh); + namespace detail + { + template + constexpr EVE_FORCEINLINE T atanh_(EVE_REQUIRES(cpu_), O const& , T const& x) + { + auto absx = eve::abs(x); + auto t = absx + absx; + auto z1 = oneminus(absx); + auto test = absx < half(eve::as()); + auto tmp = if_else(test, absx, t) / z1; + if constexpr( scalar_value ) tmp = test ? fma(t, tmp, t) : tmp; + else tmp = if_else(test, fma(t, tmp, t), tmp); + return signnz(x)*half(eve::as())*log1p(tmp); + } + } } - -#include diff --git a/include/eve/module/math/regular/atanpi.hpp b/include/eve/module/math/regular/atanpi.hpp index e0117f70d7..20e0ae34a0 100644 --- a/include/eve/module/math/regular/atanpi.hpp +++ b/include/eve/module/math/regular/atanpi.hpp @@ -7,10 +7,24 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include +#include +#include namespace eve { + template + struct atanpi_t : elementwise_callable + { + template + constexpr EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(atanpi_t, atanpi_); + }; + //================================================================================================ //! @addtogroup math_invtrig //! @{ @@ -55,9 +69,14 @@ namespace eve //! @godbolt{doc/math/regular/atanpi.cpp} //! @} //================================================================================================ + inline constexpr auto atanpi = functor; - -EVE_MAKE_CALLABLE(atanpi_, atanpi); + namespace detail + { + template + constexpr EVE_FORCEINLINE T atanpi_(EVE_REQUIRES(cpu_), O const& , T const& a) + { + return radinpi(atan(a)); + } + } } - -#include diff --git a/include/eve/module/math/regular/deginrad.hpp b/include/eve/module/math/regular/deginrad.hpp index 8efa61a6ce..96d6be51e6 100644 --- a/include/eve/module/math/regular/deginrad.hpp +++ b/include/eve/module/math/regular/deginrad.hpp @@ -7,8 +7,10 @@ //================================================================================================== #pragma once +#include +#include +#include #include -#include namespace eve { @@ -58,21 +60,21 @@ namespace eve //! @godbolt{doc/math/regular/deginrad.cpp} //! @} //================================================================================================ -inline constexpr auto deginrad = functor; -} + inline constexpr auto deginrad = functor; -namespace eve::detail -{ - template - EVE_FORCEINLINE constexpr T - deginrad_(EVE_REQUIRES(cpu_), O const &, T const& a) noexcept + namespace detail { - if constexpr( has_native_abi_v ) + template + EVE_FORCEINLINE constexpr T + deginrad_(EVE_REQUIRES(cpu_), O const &, T const& a) noexcept { - auto ridh = ieee_constant<0x1.1de0000p-6f, 0x1.1df46a0000000p-6>(eve::as{}); - auto ridl = ieee_constant<0x1.46a2520p-18f, 0x1.294e9c8ae0ec6p-33>(eve::as{}); - return fma(a, ridl, a * ridh); + if constexpr( has_native_abi_v ) + { + auto ridh = ieee_constant<0x1.1de0000p-6f, 0x1.1df46a0000000p-6>(eve::as{}); + auto ridl = ieee_constant<0x1.46a2520p-18f, 0x1.294e9c8ae0ec6p-33>(eve::as{}); + return fma(a, ridl, a * ridh); + } + else return apply_over(deginrad, a); } - else return apply_over(deginrad, a); } } diff --git a/include/eve/module/math/regular/impl/acosh.hpp b/include/eve/module/math/regular/impl/acosh.hpp deleted file mode 100644 index c381594455..0000000000 --- a/include/eve/module/math/regular/impl/acosh.hpp +++ /dev/null @@ -1,56 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -acosh_(EVE_SUPPORTS(cpu_), T x) noexcept -{ - if constexpr( has_native_abi_v ) - { - const T t = dec(x); - auto const test = is_greater(t, inv_2eps(eve::as())); - - if constexpr( simd_value ) - { - const T z = if_else(test, x, t + sqrt(fma(t, t, t + t))); - return add[test](log1p(z), log_2(eve::as())); - } - else if constexpr( scalar_value ) - { - if( test ) { return eve::log(t) + log_2(eve::as()); } - else { return eve::log1p(t + eve::sqrt(fma(t, t, t + t))); } - } - } - else { return apply_over(acosh, x); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acosh_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acosh, t); -} - -template -EVE_FORCEINLINE auto -acosh_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acosh), t); -} -} diff --git a/include/eve/module/math/regular/impl/acot.hpp b/include/eve/module/math/regular/impl/acot.hpp deleted file mode 100644 index 4109636df8..0000000000 --- a/include/eve/module/math/regular/impl/acot.hpp +++ /dev/null @@ -1,42 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -acot_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - auto x = eve::abs(a); - return bit_xor(atan_kernel(rec(x), x), bitofsign(a)); - } - else { return apply_over(acot, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acot_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acot, t); -} - -template -EVE_FORCEINLINE auto -acot_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acot), t); -} -} diff --git a/include/eve/module/math/regular/impl/acotd.hpp b/include/eve/module/math/regular/impl/acotd.hpp deleted file mode 100644 index 8f00722dd9..0000000000 --- a/include/eve/module/math/regular/impl/acotd.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -acotd_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) { return radindeg(acot(a)); } - else { return apply_over(acotd, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acotd_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acotd, t); -} - -template -EVE_FORCEINLINE auto -acotd_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acotd), t); -} -} diff --git a/include/eve/module/math/regular/impl/acoth.hpp b/include/eve/module/math/regular/impl/acoth.hpp deleted file mode 100644 index 5b95bbfb7e..0000000000 --- a/include/eve/module/math/regular/impl/acoth.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -acoth_(EVE_SUPPORTS(cpu_), T x) noexcept -{ - if constexpr( has_native_abi_v ) { return eve::atanh(rec(x)); } - else { return apply_over(acoth, x); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acoth_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acoth, t); -} - -template -EVE_FORCEINLINE auto -acoth_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acoth), t); -} -} diff --git a/include/eve/module/math/regular/impl/acotpi.hpp b/include/eve/module/math/regular/impl/acotpi.hpp deleted file mode 100644 index 4f2c729278..0000000000 --- a/include/eve/module/math/regular/impl/acotpi.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -acotpi_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) { return radinpi(acot(a)); } - else { return apply_over(acotpi, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acotpi_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acotpi, t); -} - -template -EVE_FORCEINLINE auto -acotpi_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acotpi), t); -} -} diff --git a/include/eve/module/math/regular/impl/acsc.hpp b/include/eve/module/math/regular/impl/acsc.hpp deleted file mode 100644 index 2d7eee3347..0000000000 --- a/include/eve/module/math/regular/impl/acsc.hpp +++ /dev/null @@ -1,38 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -acsc_(EVE_SUPPORTS(cpu_), T const& a0) noexcept -{ - if constexpr( has_native_abi_v ) { return eve::asin(rec(a0)); } - else { return apply_over(acsc, a0); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acsc_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acsc, t); -} - -template -EVE_FORCEINLINE auto -acsc_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acsc), t); -} -} diff --git a/include/eve/module/math/regular/impl/acscd.hpp b/include/eve/module/math/regular/impl/acscd.hpp deleted file mode 100644 index bad61ef8b3..0000000000 --- a/include/eve/module/math/regular/impl/acscd.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -acscd_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) { return radindeg(acsc(a)); } - else { return apply_over(acscd, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acscd_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acscd, t); -} - -template -EVE_FORCEINLINE auto -acscd_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acscd), t); -} -} diff --git a/include/eve/module/math/regular/impl/acsch.hpp b/include/eve/module/math/regular/impl/acsch.hpp deleted file mode 100644 index a617533bac..0000000000 --- a/include/eve/module/math/regular/impl/acsch.hpp +++ /dev/null @@ -1,38 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -acsch_(EVE_SUPPORTS(cpu_), T const& x) noexcept -{ - if constexpr( has_native_abi_v ) { return asinh(rec(x)); } - else { return apply_over(acsch, x); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acsch_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acsch, t); -} - -template -EVE_FORCEINLINE auto -acsch_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acsch), t); -} -} diff --git a/include/eve/module/math/regular/impl/acscpi.hpp b/include/eve/module/math/regular/impl/acscpi.hpp deleted file mode 100644 index 4d8d4bc63d..0000000000 --- a/include/eve/module/math/regular/impl/acscpi.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -acscpi_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) { return radinpi(acsc(a)); } - else { return apply_over(acscpi, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -acscpi_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::acscpi, t); -} - -template -EVE_FORCEINLINE auto -acscpi_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::acscpi), t); -} -} diff --git a/include/eve/module/math/regular/impl/agd.hpp b/include/eve/module/math/regular/impl/agd.hpp deleted file mode 100644 index 67ec3026ef..0000000000 --- a/include/eve/module/math/regular/impl/agd.hpp +++ /dev/null @@ -1,43 +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 constexpr auto -agd_(EVE_SUPPORTS(cpu_), T x) noexcept -{ - if constexpr( has_native_abi_v ) - { - return 2*atanh(tan(x*half(as(x)))); - } - else return apply_over(agd, x); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -agd_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::agd, t); -} - -template -EVE_FORCEINLINE auto -agd_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::agd), t); -} -} diff --git a/include/eve/module/math/regular/impl/arg.hpp b/include/eve/module/math/regular/impl/arg.hpp deleted file mode 100644 index 1add93b3f0..0000000000 --- a/include/eve/module/math/regular/impl/arg.hpp +++ /dev/null @@ -1,31 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -arg_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) { return if_else(is_negative(a), pi(eve::as(a)), eve::zero); } - else { return apply_over(arg, a); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked case -template -EVE_FORCEINLINE auto -arg_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::arg, t); -} -} diff --git a/include/eve/module/math/regular/impl/asech.hpp b/include/eve/module/math/regular/impl/asech.hpp deleted file mode 100644 index 319a96388f..0000000000 --- a/include/eve/module/math/regular/impl/asech.hpp +++ /dev/null @@ -1,38 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE constexpr auto -asech_(EVE_SUPPORTS(cpu_), T x) noexcept -{ - if constexpr( has_native_abi_v ) { return acosh(rec(x)); } - else { return apply_over(eve::asech, x); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -asech_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::asech, t); -} - -template -EVE_FORCEINLINE auto -asech_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::asech), t); -} -} diff --git a/include/eve/module/math/regular/impl/asin.hpp b/include/eve/module/math/regular/impl/asin.hpp deleted file mode 100644 index b7512272a0..0000000000 --- a/include/eve/module/math/regular/impl/asin.hpp +++ /dev/null @@ -1,112 +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 auto - asin_(EVE_SUPPORTS(cpu_), T const& a0) noexcept - { - if constexpr( has_native_abi_v ) - { - using elt_t = element_type_t; - auto x = eve::abs(a0); - auto sgn = eve::bitofsign(a0); - if constexpr( std::is_same_v ) - { - const auto x_larger_05 = x > half(eve::as()); - T z = if_else(x_larger_05, half(eve::as()) * oneminus(x), eve::sqr(x)); - x = if_else(x_larger_05, sqrt(z), x); - T z1 = - eve::reverse_horner(z, T(0x1.5555c8p-3f), T(0x1.3301ecp-4f), T(0x1.747d8ep-5f) - , T(0x1.8c2fc6p-6f), T(0x1.5966a4p-5f)); - ; - z1 = fma(z1, z * x, x); - z = if_else(x_larger_05, pio_2(eve::as()) - (z1 + z1), z1); - return eve::bit_xor(z, sgn); - } - else if constexpr( std::is_same_v ) - { - auto small = x < sqrteps(eve::as()); - if constexpr( scalar_value ) // early scalar return - { - if( small ) return a0; - if( (x > one(eve::as())) ) return nan(eve::as()); - } - else if constexpr( simd_value ) // simd preparation - { - x = if_else(x > one(eve::as()), eve::allbits, x); - } - auto case_1 = [](const T& x) { // x < 0.625 - auto zz1 = eve::oneminus(x); - auto num = zz1 - * - eve::reverse_horner(zz1, T(0x1.c896240f3081dp+4), T(-0x1.991aaac01ab68p+4), T(0x1.bdff5baf33e6ap+2), T(-0x1.2079259f9290fp-1), T(0x1.84fc3988e9f08p-9)); - ; - auto den = - eve::reverse_horner(zz1, T(0x1.56709b0b644bep+8), T(-0x1.7fe08959063eep+8), T(0x1.26219af6a7f42p+7), T(-0x1.5f2a2b6bf5d8cp+4), T(0x1.0p0)); - ; - auto vp = num / den; - zz1 = sqrt(zz1 + zz1); - auto z = pio_4(eve::as()) - zz1; - zz1 = fms(zz1, vp, T(0x1.1a62633145c07p-54)); // pio_2lo - z = z - zz1; - zz1 = z + pio_4(eve::as()); - return zz1; - }; - auto case_2 = [](const T& x) { // x >= 0.625 - T zz2 = sqr(x); - auto num = zz2 * eve::reverse_horner(zz2, T(-0x1.0656c06ceafd5p+3), T(0x1.39007da779259p+4), T(-0x1.04331de27907bp+4) - , T(0x1.5c74b178a2dd9p+2), T(-0x1.34341333e5c16p-1), T(0x1.16b9b0bd48ad3p-8)); - ; - auto den = - eve::reverse_horner(zz2, T(-0x1.898220a3607acp+5), T(0x1.1705684ffbf9dp+7), T(-0x1.265bb6d3576d7p+7) - , T(0x1.19fc025fe9054p+6), T(-0x1.d7b590b5e0eabp+3), T(0x1.0p0)); - ; - auto z = num / den; - zz2 = fma(x, z, x); - return zz2; - }; - auto ct1 = T(0x1.4000000000000p-1); // 0.625; - auto xgtct1 = x > ct1; - auto res = branch>(xgtct1, case_1, case_2)(x); - if constexpr( simd_value ) { res = if_else(small, x, res); } - return bit_xor(res, sgn); - } - } - else return apply_over(eve::asin, a0); - } - -// ----------------------------------------------------------------------------------------------- -// Masked cases - template - EVE_FORCEINLINE auto - asin_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept - { - return mask_op(cond, eve::asin, t); - } - - template - EVE_FORCEINLINE auto - asin_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept - { - return mask_op(cond, d(eve::asin), t); - } -} diff --git a/include/eve/module/math/regular/impl/asind.hpp b/include/eve/module/math/regular/impl/asind.hpp deleted file mode 100644 index 6ee5b867d2..0000000000 --- a/include/eve/module/math/regular/impl/asind.hpp +++ /dev/null @@ -1,40 +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 constexpr auto -asind_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) return radindeg(eve::asin(a)); - else return apply_over(eve::asind, a); -} - - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -asind_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::asind, t); -} - -template -EVE_FORCEINLINE auto -asind_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::asind), t); -} -} diff --git a/include/eve/module/math/regular/impl/asinh.hpp b/include/eve/module/math/regular/impl/asinh.hpp deleted file mode 100644 index 898d462913..0000000000 --- a/include/eve/module/math/regular/impl/asinh.hpp +++ /dev/null @@ -1,85 +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 auto -asinh_(EVE_SUPPORTS(cpu_), const T& a0) noexcept -{ - if constexpr( has_native_abi_v ) - { - using vt_t = element_type_t; - T x = eve::abs(a0); - if constexpr( scalar_value ) - if( x < sqrteps(eve::as()) ) return a0; // scalar early return - auto x_gt_oneosqrteps = x > oneosqrteps(eve::as()); - auto bts = bitofsign(a0); - if constexpr( std::is_same_v ) - { - if constexpr( scalar_value ) // faster for great or small values - { - if( x_gt_oneosqrteps ) return bit_xor(log(x) + log_2(eve::as()), bts); - else if( x >= eve::half(eve::as()) ) - return bit_xor(log(x + hypot(one(eve::as()), x)), bts); - } - // remaining scalar case and all simd cases to avoid multiple computations as - // this one is always ok - T z = if_else(x_gt_oneosqrteps, dec(x), x + sqr(x) / eve::inc(hypot(one(eve::as()), x))); - if constexpr( eve::platform::supports_infinites ) z = if_else((x == inf(eve::as())), x, z); - z = add[x_gt_oneosqrteps](eve::log1p(z), log_2(eve::as())); - return bit_xor(z, bts); - } - else if constexpr( std::is_same_v ) - { - auto x_lt_half = x < half(eve::as()); - T x2 = sqr(x); - T z = zero(eve::as()); - std::size_t nb = eve::count_true(x_lt_half); - if( nb > 0 ) - { - z = eve::reverse_horner(x2, T(0x1.000000p+0f), T(-0x1.55535ap-3f), T(0x1.329362p-4f), T(-0x1.5dcb02p-5f), T(0x1.49adccp-6f))* x; - if( nb >= cardinal_v ) return bit_xor(z, bts); - } - auto case_1 = [](T const& x) { return x; }; // great x - auto case_2 = [](T const& x) { return average(x, hypot(one(eve::as()), x)); }; // lesser x - auto tmp = branch>(x_gt_oneosqrteps, case_1, case_2)(x); - auto z1 = bit_xor(if_else(x_lt_half, z, log(tmp) + log_2(eve::as())), bts); - if constexpr( eve::platform::supports_invalids ) return if_else(is_nan(a0), eve::allbits, z1); - else return z1; - } - } - else { return apply_over(eve::asinh, a0); } -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -asinh_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::asinh, t); -} - -template -EVE_FORCEINLINE auto -asinh_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::asinh), t); -} -} diff --git a/include/eve/module/math/regular/impl/asinpi.hpp b/include/eve/module/math/regular/impl/asinpi.hpp deleted file mode 100644 index 7e397a6af5..0000000000 --- a/include/eve/module/math/regular/impl/asinpi.hpp +++ /dev/null @@ -1,40 +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 constexpr auto -asinpi_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) return radinpi(eve::asin(a)); - else return apply_over(eve::asinpi, a); -} - - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -asinpi_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::asinpi, t); -} - -template -EVE_FORCEINLINE auto -asinpi_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::asinpi), t); -} -} diff --git a/include/eve/module/math/regular/impl/atan.hpp b/include/eve/module/math/regular/impl/atan.hpp deleted file mode 100644 index 661a4fcc5d..0000000000 --- a/include/eve/module/math/regular/impl/atan.hpp +++ /dev/null @@ -1,42 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) - { - T x = eve::abs(a); - return bit_xor(atan_kernel(x, rec(x)), bitofsign(a)); - } - else return apply_over(atan, a); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atan_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::atan, t); -} - -template -EVE_FORCEINLINE auto -atan_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::atan), t); -} -} diff --git a/include/eve/module/math/regular/impl/atan2.hpp b/include/eve/module/math/regular/impl/atan2.hpp deleted file mode 100644 index 20ef1ff564..0000000000 --- a/include/eve/module/math/regular/impl/atan2.hpp +++ /dev/null @@ -1,54 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include - -namespace eve::detail -{ -// ----------------------------------------------------------------------------------------------- -// regular case -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), T const& a, U const& b) noexcept --> common_value_t -{ - return arithmetic_call(atan2, a, b); -} - -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), T const& a0, T const& a1) noexcept -requires has_native_abi_v -{ - auto q = eve::abs(a0 / a1); - auto z = detail::atan_kernel(q, eve::rec(q)); - return if_else(is_positive(a1), z, (pi(eve::as(a0)) - z)) * signnz(a0); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), C const& cond, T const& t, U const& u) noexcept --> decltype( if_else(cond, atan2(t, u), t) ) -{ - return mask_op(cond, eve::atan2, t,u); -} - -template -EVE_FORCEINLINE auto -atan2_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, T const& t, U const& u) noexcept --> decltype( if_else(cond, atan2(t, u), t) ) -{ - return mask_op(cond, d(eve::atan2), t, u); -} -} diff --git a/include/eve/module/math/regular/impl/atan2d.hpp b/include/eve/module/math/regular/impl/atan2d.hpp deleted file mode 100644 index 5fb18727b0..0000000000 --- a/include/eve/module/math/regular/impl/atan2d.hpp +++ /dev/null @@ -1,47 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), T const& a, U const& b) noexcept --> decltype(atan2(a, b)) -{ - return arithmetic_call(atan2d, a, b); -} - -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v -{ - return radindeg(atan2(a, b)); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), C const& cond, T const& t, U const& u) noexcept -{ - return mask_op(cond, eve::atan2d, t,u); -} - -template -EVE_FORCEINLINE auto -atan2d_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, T const& t, U const& u) noexcept -{ - return mask_op(cond, d(eve::atan2d), t, u); -} -} diff --git a/include/eve/module/math/regular/impl/atan2pi.hpp b/include/eve/module/math/regular/impl/atan2pi.hpp deleted file mode 100644 index 85610db923..0000000000 --- a/include/eve/module/math/regular/impl/atan2pi.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 - -namespace eve::detail -{ -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), T const& a, U const& b) noexcept -{ - return arithmetic_call(atan2pi, a, b); -} - -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), T const& a, T const& b) noexcept requires has_native_abi_v -{ - return radinpi(atan2(a, b)); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), C const& cond, T const& t, U const& u) noexcept -{ - return mask_op(cond, eve::atan2pi, t,u); -} - -template -EVE_FORCEINLINE auto -atan2pi_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, T const& t, U const& u) noexcept -{ - return mask_op(cond, d(eve::atan2pi), t, u); -} -} diff --git a/include/eve/module/math/regular/impl/atand.hpp b/include/eve/module/math/regular/impl/atand.hpp deleted file mode 100644 index 90d2908b4d..0000000000 --- a/include/eve/module/math/regular/impl/atand.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -atand_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) return radindeg(atan(a)); - else return apply_over(atand, a); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atand_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::atand, t); -} - -template -EVE_FORCEINLINE auto -atand_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::atand), t); -} -} diff --git a/include/eve/module/math/regular/impl/atanh.hpp b/include/eve/module/math/regular/impl/atanh.hpp deleted file mode 100644 index e7e56a9c67..0000000000 --- a/include/eve/module/math/regular/impl/atanh.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 -atanh_(EVE_SUPPORTS(cpu_), const T& x) noexcept -{ - if constexpr( has_native_abi_v ) - { - auto absx = eve::abs(x); - auto t = absx + absx; - auto z1 = oneminus(absx); - auto test = absx < half(eve::as()); - auto tmp = if_else(test, absx, t) / z1; - if constexpr( scalar_value ) tmp = test ? fma(t, tmp, t) : tmp; - else tmp = if_else(test, fma(t, tmp, t), tmp); - return signnz(x)*half(eve::as()) * log1p(tmp); - } - else return apply_over(atanh, x); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atanh_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::atanh, t); -} - -template -EVE_FORCEINLINE auto -atanh_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::atanh), t); -} -} diff --git a/include/eve/module/math/regular/impl/atanpi.hpp b/include/eve/module/math/regular/impl/atanpi.hpp deleted file mode 100644 index fba680efd0..0000000000 --- a/include/eve/module/math/regular/impl/atanpi.hpp +++ /dev/null @@ -1,39 +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 constexpr auto -atanpi_(EVE_SUPPORTS(cpu_), T const& a) noexcept -{ - if constexpr( has_native_abi_v ) return radinpi(atan(a)); - else return apply_over(atanpi, a); -} - -// ----------------------------------------------------------------------------------------------- -// Masked cases -template -EVE_FORCEINLINE auto -atanpi_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept -{ - return mask_op(cond, eve::atanpi, t); -} - -template -EVE_FORCEINLINE auto -atanpi_(EVE_SUPPORTS(cpu_), C const& cond, D const & d, U const& t) noexcept -{ - return mask_op(cond, d(eve::atanpi), t); -} -} diff --git a/include/eve/module/math/regular/impl/significants.hpp b/include/eve/module/math/regular/impl/significants.hpp deleted file mode 100644 index 980c69d982..0000000000 --- a/include/eve/module/math/regular/impl/significants.hpp +++ /dev/null @@ -1,35 +0,0 @@ -//================================================================================================== -/* - EVE - Expressive Vector Engine - Copyright : EVE Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace eve::detail -{ -template -EVE_FORCEINLINE T -significants_(EVE_SUPPORTS(cpu_), T const& a, U const& n) noexcept -{ - if constexpr( has_native_abi_v && has_native_abi_v ) - { - using elt_t = element_type_t; - auto nn = convert(n, as()); - auto e = floor(inc(log10(eve::abs(a)) - nn)); - auto factor = exp10(abs(e)); - auto tmp = if_else(is_gez(e), nearest(a / factor) * factor, nearest(a * factor) / factor); - tmp = if_else(is_eqz(a), a, tmp); - return if_else(is_nez(nn), tmp, allbits); - } - else return apply_over(significants, a, n); -} -} diff --git a/include/eve/module/math/regular/radindeg.hpp b/include/eve/module/math/regular/radindeg.hpp index c96780405e..c93514d014 100644 --- a/include/eve/module/math/regular/radindeg.hpp +++ b/include/eve/module/math/regular/radindeg.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include namespace eve { + + template + struct radindeg_t : elementwise_callable + { + template + EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(radindeg_t, radindeg_); + }; + //================================================================================================ //! @addtogroup math_trig //! @{ @@ -47,7 +60,21 @@ namespace eve //! @godbolt{doc/math/regular/radindeg.cpp} //! @} //================================================================================================ -EVE_MAKE_CALLABLE(radindeg_, radindeg); -} + inline constexpr auto radindeg = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr T + radindeg_(EVE_REQUIRES(cpu_), O const &, T const& a) noexcept + { + if constexpr( has_native_abi_v ) + { + auto radradindeg = ieee_constant<0x1.ca5dc20p+5f, 0x1.ca5dc1a63c1f8p+5>(eve::as{}); + auto radradindegr = ieee_constant<0x1.670f800p-21f, 0x1.1e7ab456405f8p-49>(eve::as{}); + return fma(a, radradindegr, a * radradindeg); + } + else return apply_over(radindeg, a); + } + } +} diff --git a/include/eve/module/math/regular/radinpi.hpp b/include/eve/module/math/regular/radinpi.hpp index 99e0fe0cfc..c8931cb57a 100644 --- a/include/eve/module/math/regular/radinpi.hpp +++ b/include/eve/module/math/regular/radinpi.hpp @@ -7,10 +7,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include namespace eve { + + template + struct radinpi_t : elementwise_callable + { + template + EVE_FORCEINLINE T operator()(T v) const { return EVE_DISPATCH_CALL(v); } + + EVE_CALLABLE_OBJECT(radinpi_t, radinpi_); + }; + //================================================================================================ //! @addtogroup math_trig //! @{ @@ -48,7 +61,18 @@ namespace eve //! @godbolt{doc/math/regular/radinpi.cpp} //! @} //================================================================================================ - EVE_MAKE_CALLABLE(radinpi_, radinpi); -} + inline constexpr auto radinpi = functor; -#include + namespace detail + { + template + EVE_FORCEINLINE constexpr T + radinpi_(EVE_REQUIRES(cpu_), O const &, T const& a) noexcept + { + if constexpr( has_native_abi_v ) + return inv_pi(eve::as(a)) * a; + else + return apply_over(radinpi, a); + } + } +} diff --git a/include/eve/module/math/regular/significants.hpp b/include/eve/module/math/regular/significants.hpp index db6e196636..a3fc7706e4 100644 --- a/include/eve/module/math/regular/significants.hpp +++ b/include/eve/module/math/regular/significants.hpp @@ -6,10 +6,23 @@ //================================================================================================== #pragma once -#include +#include +#include +#include +#include namespace eve { + template + struct significants_t : elementwise_callable + { + template + EVE_FORCEINLINE constexpr as_wide_as_t operator()(T0 t0, T1 t1) const noexcept + { return EVE_DISPATCH_CALL(t0, t1); } + + EVE_CALLABLE_OBJECT(significants_t, significants_); + }; + //================================================================================================ //! @addtogroup math_exp //! @{ @@ -27,7 +40,7 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::integral_value N > +//! template< eve::value T, eve::value N > //! eve::common_value_t significants(T x, N n) noexcept; //! } //! @endcode @@ -36,7 +49,7 @@ namespace eve //! //! * `x`: [floating argument](@ref eve::floating_value). //! -//! * `n` : [integral value argument](@ref eve::integral_value). +//! * `n` : [value argument](@ref eve::integral_value). Must be positive and integral or flint. //! //! **Return value** //! @@ -52,7 +65,35 @@ namespace eve //! //! @godbolt{doc/core/regular/significants.cpp} //! @} -EVE_MAKE_CALLABLE(significants_, significants); -} + inline constexpr auto significants = functor; -#include + namespace detail + { + + template + EVE_FORCEINLINE constexpr auto + significants_(EVE_REQUIRES(cpu_), O const &, T const& a, U const& n) noexcept + { + using r_t = as_wide_as_t; + if constexpr(integral_value) + { + using elt_t = element_type_t; + return significants(r_t(a), convert(n, as())); + } + else + { + EVE_ASSERT(eve::all(is_flint(n)), "n is not flint"); + EVE_ASSERT(eve::all(is_gez(n)), "some n are not positive"); + if constexpr( has_native_abi_v && has_native_abi_v ) + { + auto e = floor(inc(log10(eve::abs(a)) - n)); + auto factor = exp10(abs(e)); + auto tmp = if_else(is_gez(e), nearest(a / factor) * factor, nearest(a * factor) / factor); + tmp = if_else(is_eqz(a), a, tmp); + return if_else(is_nez(n), tmp, allbits); + } + else return apply_over(significants, a, n); + } + } + } +} diff --git a/test/unit/module/math/atan2.cpp b/test/unit/module/math/atan2.cpp index d77e6ddb08..2cd56a3dae 100644 --- a/test/unit/module/math/atan2.cpp +++ b/test/unit/module/math/atan2.cpp @@ -60,66 +60,66 @@ TTS_CASE_TPL("Check behavior of pedantic(atan2)", eve::test::simd::ieee_reals) if constexpr( eve::platform::supports_infinites ) { TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::inf(eve::as()), T(1.)), eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::inf(eve::as()), T(1.)), eve::pio_2(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::inf(eve::as()), T(-1.)), eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::inf(eve::as()), T(-1.)), eve::pio_2(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::minf(eve::as()), T(1.)), -eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::minf(eve::as()), T(1.)), -eve::pio_2(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::minf(eve::as()), T(-1.)), -eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::minf(eve::as()), T(-1.)), -eve::pio_2(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)((T(1.)), eve::minf(eve::as())), eve::pi(eve::as()), 0.5); + eve::atan2[pedantic]((T(1.)), eve::minf(eve::as())), eve::pi(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)((T(-1.)), eve::minf(eve::as())), -eve::pi(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)((T(1.)), eve::inf(eve::as())), T(0.), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)((T(-1.)), eve::inf(eve::as())), T(-0.), 0.5); + eve::atan2[pedantic]((T(-1.)), eve::minf(eve::as())), -eve::pi(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic]((T(1.)), eve::inf(eve::as())), T(0.), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic]((T(-1.)), eve::inf(eve::as())), T(-0.), 0.5); - TTS_EXPECT(eve::all(is_negative(pedantic(eve::atan2)((T(-1.)), eve::inf(eve::as()))))); - TTS_EXPECT(eve::all(is_positive(pedantic(eve::atan2)((T(1.)), eve::inf(eve::as()))))); + TTS_EXPECT(eve::all(is_negative(eve::atan2[pedantic]((T(-1.)), eve::inf(eve::as()))))); + TTS_EXPECT(eve::all(is_positive(eve::atan2[pedantic]((T(1.)), eve::inf(eve::as()))))); - TTS_ULP_EQUAL(pedantic(eve::atan2)(eve::minf(eve::as()), eve::minf(eve::as())), + TTS_ULP_EQUAL(eve::atan2[pedantic](eve::minf(eve::as()), eve::minf(eve::as())), -3 * eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(eve::inf(eve::as()), eve::minf(eve::as())), + TTS_ULP_EQUAL(eve::atan2[pedantic](eve::inf(eve::as()), eve::minf(eve::as())), 3 * eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(eve::minf(eve::as()), eve::inf(eve::as())), + TTS_ULP_EQUAL(eve::atan2[pedantic](eve::minf(eve::as()), eve::inf(eve::as())), -eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(eve::inf(eve::as()), eve::inf(eve::as())), + TTS_ULP_EQUAL(eve::atan2[pedantic](eve::inf(eve::as()), eve::inf(eve::as())), eve::pio_4(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::inf(eve::as()), T(1.)), eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::inf(eve::as()), T(1.)), eve::pio_2(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::minf(eve::as()), T(1.)), -eve::pio_2(eve::as()), 0.5); + eve::atan2[pedantic](eve::minf(eve::as()), T(1.)), -eve::pio_2(eve::as()), 0.5); } if constexpr( eve::platform::supports_nans ) { - TTS_ULP_EQUAL(pedantic(eve::atan2)(eve::nan(eve::as()), eve::nan(eve::as())), + TTS_ULP_EQUAL(eve::atan2[pedantic](eve::nan(eve::as()), eve::nan(eve::as())), eve::nan(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)(eve::nan(eve::as()), (T(0.))), eve::nan(eve::as()), 0.5); + eve::atan2[pedantic](eve::nan(eve::as()), (T(0.))), eve::nan(eve::as()), 0.5); TTS_ULP_EQUAL( - pedantic(eve::atan2)((T(0.)), eve::nan(eve::as())), eve::nan(eve::as()), 0.5); + eve::atan2[pedantic]((T(0.)), eve::nan(eve::as())), eve::nan(eve::as()), 0.5); } - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(0.5), T(0.5)), eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-0.5), T(-0.5)), -3 * eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-1.), T(-1.)), -3 * eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(1.), T(1.)), eve::pio_4(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(0.), T(0.)), (T(0.)), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-0.), T(0.)), T(-0.), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-0.), T(-0.)), -eve::pi(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-0.), T(-1.)), -eve::pi(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(0.), T(-0.)), eve::pi(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(0.), T(-1.)), eve::pi(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-1.), T(-0.)), -eve::pio_2(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(-1.), T(0.)), -eve::pio_2(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(1.), T(-0.)), eve::pio_2(eve::as()), 0.5); - TTS_ULP_EQUAL(pedantic(eve::atan2)(T(1.), T(0.)), eve::pio_2(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(0.5), T(0.5)), eve::pio_4(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-0.5), T(-0.5)), -3 * eve::pio_4(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-1.), T(-1.)), -3 * eve::pio_4(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(1.), T(1.)), eve::pio_4(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(0.), T(0.)), (T(0.)), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-0.), T(0.)), T(-0.), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-0.), T(-0.)), -eve::pi(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-0.), T(-1.)), -eve::pi(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(0.), T(-0.)), eve::pi(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(0.), T(-1.)), eve::pi(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-1.), T(-0.)), -eve::pio_2(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(-1.), T(0.)), -eve::pio_2(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(1.), T(-0.)), eve::pio_2(eve::as()), 0.5); + TTS_ULP_EQUAL(eve::atan2[pedantic](T(1.), T(0.)), eve::pio_2(eve::as()), 0.5); };