diff --git a/include/kyosu/complex/acos.hpp b/include/kyosu/complex/acos.hpp index cc4cfbd8..e579de9d 100644 --- a/include/kyosu/complex/acos.hpp +++ b/include/kyosu/complex/acos.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acos{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns elementwise the complex principal value //! of the arc cosine of the input. //! Branch cuts exist outside the interval \f$[-1, +1]\f$ along the real axis. //! diff --git a/include/kyosu/complex/acosh.hpp b/include/kyosu/complex/acosh.hpp index 67b4896b..5e10f7a4 100644 --- a/include/kyosu/complex/acosh.hpp +++ b/include/kyosu/complex/acosh.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acosh{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns the complex arc hyperbolic sine of z, in the range of a half-strip mathematically //! unbounded along the real axis and in the interval \f$i\times[-\pi/2, \pi/2]\f$ along diff --git a/include/kyosu/complex/acospi.hpp b/include/kyosu/complex/acospi.hpp index c3bed466..6f90b2de 100644 --- a/include/kyosu/complex/acospi.hpp +++ b/include/kyosu/complex/acospi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acospi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*acos(z)` //! diff --git a/include/kyosu/complex/acot.hpp b/include/kyosu/complex/acot.hpp index 3c6bf955..aa4c8472 100644 --- a/include/kyosu/complex/acot.hpp +++ b/include/kyosu/complex/acot.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acot{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns elementwise the complex principal value //! of the arc cotangent of the input as the arc tangent of the inverse of the input. //! //! @groupheader{Example} diff --git a/include/kyosu/complex/acoth.hpp b/include/kyosu/complex/acoth.hpp index bae3455f..83336805 100644 --- a/include/kyosu/complex/acoth.hpp +++ b/include/kyosu/complex/acoth.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acoth{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns the complex arc hyperbolic cotangent of z, computed as \f$\mathop{\mathrm{atanh}}(1/z)\f$. //! diff --git a/include/kyosu/complex/acotpi.hpp b/include/kyosu/complex/acotpi.hpp index 28c0f444..1b228045 100644 --- a/include/kyosu/complex/acotpi.hpp +++ b/include/kyosu/complex/acotpi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acotpi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*acot(z)` //! diff --git a/include/kyosu/complex/acsc.hpp b/include/kyosu/complex/acsc.hpp index 198d889d..6df94c2b 100644 --- a/include/kyosu/complex/acsc.hpp +++ b/include/kyosu/complex/acsc.hpp @@ -63,9 +63,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) \f$\mathop{\mathrm{asin}}(1/z)\f$. +//! 2. Returns elementwise \f$\mathop{\mathrm{asin}}(1/z)\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/acsch.hpp b/include/kyosu/complex/acsch.hpp index 81009f31..9f890931 100644 --- a/include/kyosu/complex/acsch.hpp +++ b/include/kyosu/complex/acsch.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acsch{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) \f$\mathop{\mathrm{asinh}}(1/z)\f$. +//! 2. Returns elementwise \f$\mathop{\mathrm{asinh}}(1/z)\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/acscpi.hpp b/include/kyosu/complex/acscpi.hpp index f260d088..5cbd3592 100644 --- a/include/kyosu/complex/acscpi.hpp +++ b/include/kyosu/complex/acscpi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acscpi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*acsc(z)` //! diff --git a/include/kyosu/complex/acsh.hpp b/include/kyosu/complex/acsh.hpp index 37af3d51..fadd08d4 100644 --- a/include/kyosu/complex/acsh.hpp +++ b/include/kyosu/complex/acsh.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atanh{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns the complex arc hyperbolic sine of z, in the range of a half-strip mathematically //! unbounded along the real axis and in the interval \f$i\times[-\pi/2, \pi/2]\f$ along diff --git a/include/kyosu/complex/asec.hpp b/include/kyosu/complex/asec.hpp index 6eb3a835..2590c021 100644 --- a/include/kyosu/complex/asec.hpp +++ b/include/kyosu/complex/asec.hpp @@ -63,9 +63,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) \f$\mathop{\mathrm{acos}}(1/z)\f$. +//! 2. Returns elementwise \f$\mathop{\mathrm{acos}}(1/z)\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/asech.hpp b/include/kyosu/complex/asech.hpp index 9802b6b7..2c3c0b43 100644 --- a/include/kyosu/complex/asech.hpp +++ b/include/kyosu/complex/asech.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asech{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) \f$\mathop{\mathrm{acosh}}(1/z)\f$. +//! 2. Returns elementwise \f$\mathop{\mathrm{acosh}}(1/z)\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/asecpi.hpp b/include/kyosu/complex/asecpi.hpp index 9e368c70..69c85337 100644 --- a/include/kyosu/complex/asecpi.hpp +++ b/include/kyosu/complex/asecpi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asecpi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*asec(z)` //! diff --git a/include/kyosu/complex/asin.hpp b/include/kyosu/complex/asin.hpp index 262c4a3f..47f73bcc 100644 --- a/include/kyosu/complex/asin.hpp +++ b/include/kyosu/complex/asin.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asin{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns the [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns the elementwise the complex principal value //! of the arc sine of the input in the range of a strip unbounded along the imaginary axis //! and in the interval \f$[-\pi/2, \pi/2]\f$ along the real axis. //! diff --git a/include/kyosu/complex/asinh.hpp b/include/kyosu/complex/asinh.hpp index cfff986b..d507ff66 100644 --- a/include/kyosu/complex/asinh.hpp +++ b/include/kyosu/complex/asinh.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asinh{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns the complex arc hyperbolic sine of z, with branch cuts outside the interval //! \f$i\times[-\pi/2, \pi/2]\f$ along the imaginary axis. diff --git a/include/kyosu/complex/asinpi.hpp b/include/kyosu/complex/asinpi.hpp index 62156b09..2a250fce 100644 --- a/include/kyosu/complex/asinpi.hpp +++ b/include/kyosu/complex/asinpi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asinpi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*asin(z)` //! diff --git a/include/kyosu/complex/atan.hpp b/include/kyosu/complex/atan.hpp index 1b183d5b..1b0188d4 100644 --- a/include/kyosu/complex/atan.hpp +++ b/include/kyosu/complex/atan.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atan{}; - return fn(v); + return fn(complex(v)); } template @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns the [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns the elementwise the complex principal value //! of the arc tangent of the input in the range of a strip unbounded along the imaginary axis //! and in the interval \f$[-\pi/2, \pi/2]\f$ along the real axis. //! diff --git a/include/kyosu/complex/atanh.hpp b/include/kyosu/complex/atanh.hpp index 37af3d51..fadd08d4 100644 --- a/include/kyosu/complex/atanh.hpp +++ b/include/kyosu/complex/atanh.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atanh{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns the complex arc hyperbolic sine of z, in the range of a half-strip mathematically //! unbounded along the real axis and in the interval \f$i\times[-\pi/2, \pi/2]\f$ along diff --git a/include/kyosu/complex/atanpi.hpp b/include/kyosu/complex/atanpi.hpp index 2fe9bcdd..076872ec 100644 --- a/include/kyosu/complex/atanpi.hpp +++ b/include/kyosu/complex/atanpi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atanpi{}; - return fn(v); + return fn(complex(v)); } template @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! //! 2. Returns `pi(as(z))*atan(z)` //! diff --git a/include/kyosu/complex/beta.hpp b/include/kyosu/complex/beta.hpp new file mode 100644 index 00000000..523163ee --- /dev/null +++ b/include/kyosu/complex/beta.hpp @@ -0,0 +1,85 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_beta : eve::elementwise + { + using callable_tag_type = callable_beta; + + KYOSU_DEFERS_CALLABLE(beta_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T1 const& v, T2 const& w) noexcept { + auto fn = callable_beta{}; + return fn(complex(v), w); } + + template + KYOSU_FORCEINLINE auto operator()(T1 const& target1, T2 const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2)) + { + return eve::tag_invoke(*this, target1, target2); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var beta +//! @brief Computes the beta function: \f$\displaystyle \mathbf{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template< eve::floating_ordered_value T, eve::floating_ordered_value U > +//! auto beta(T x,U y) noexcept; //1 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto beta(eve::complex_t x, U y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto beta(T x, eve::complex_t y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto beta(eve::complex_t x, eve::complex_t y) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `x`,`y` : Values to process. +//! +//! **Return value** +//! +//! 1. \f$\displaystyle \mathbf{B}(x,y) = \int_0^1 t^{x-1}(1-t)^{y-1}\mbox{d}t\f$ +//! 2. The complex \f$\displaystyle \mathbb{B}(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$ is returned. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/beta.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_beta beta = {}; +} diff --git a/include/kyosu/complex/deta.hpp b/include/kyosu/complex/deta.hpp new file mode 100644 index 00000000..35d1576e --- /dev/null +++ b/include/kyosu/complex/deta.hpp @@ -0,0 +1,79 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_deta : eve::elementwise + { + using callable_tag_type = callable_deta; + + KYOSU_DEFERS_CALLABLE(deta_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, K const & k, T const& v) noexcept + { + auto fn = callable_deta{}; + return fn(k, complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(K const & target1, T const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2)) + { + return eve::tag_invoke(*this, target1, target2); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var deta +//! @brief Computes the Dirichlet sums \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(kn+1)^z}\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto deta(K, k, T z) noexcept; //1 +//! template constexpr auto deta(K, k, T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `k` : scalar unsigned value, parameter of the sum. +//! * `z` : Vcomplex or real value to process. +//! +//! **Return value** +//! +//! Returns the Dirichlet sum \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(kn+1)^z}\f$ +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/deta.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_deta deta = {}; +} diff --git a/include/kyosu/complex/digamma.hpp b/include/kyosu/complex/digamma.hpp new file mode 100644 index 00000000..2ba2798e --- /dev/null +++ b/include/kyosu/complex/digamma.hpp @@ -0,0 +1,74 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_digamma : eve::elementwise + { + using callable_tag_type = callable_digamma; + + KYOSU_DEFERS_CALLABLE(digamma_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::digamma(v); } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var digamma +//! @brief Computes the Digamma function i.e. the logarithmic derivative of the \f$\Gamma\f$ +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr T digamma(T z) noexcept; +//! template constexpr T digamma(T z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! The value of the Digamma function: \f$\frac{\Gamma'(z)}{\Gamma(z)}\f$ is returned. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/digamma.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_digamma digamma = {}; +} diff --git a/include/kyosu/complex/erf.hpp b/include/kyosu/complex/erf.hpp new file mode 100644 index 00000000..cd1e58d0 --- /dev/null +++ b/include/kyosu/complex/erf.hpp @@ -0,0 +1,81 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_erf : eve::elementwise + { + using callable_tag_type = callable_erf; + + KYOSU_DEFERS_CALLABLE(erf_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + return eve::erf(v); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var erf +//! @brief Computes the error function: \f$ \displaystyle +//! \mbox{erf}(x)=\frac{2}{\sqrt\pi}\int_0^{x} e^{-t^2}\mbox{d}t\f$ or +//! its analytic continuation in the complex plane +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto erf(T z) noexcept; //1 +//! template constexpr auto erf(T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! 1. a real input z is treated as if complex(z) was entered. +//! +//! 2. The value of the error function in the complex plane is returned +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/erf.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_erf erf = {}; +} diff --git a/include/kyosu/complex/erfcx.hpp b/include/kyosu/complex/erfcx.hpp new file mode 100644 index 00000000..db5a0e4a --- /dev/null +++ b/include/kyosu/complex/erfcx.hpp @@ -0,0 +1,80 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_erfcx : eve::elementwise + { + using callable_tag_type = callable_erfcx; + + KYOSU_DEFERS_CALLABLE(erfcx_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + return eve::erfcx(v); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var erfcx +//! @brief Computes the normalized complementary error function +//! \f$ \displaystyle \mbox{erfcx}(x) = e^{x^2} \mbox{erfc}(x)\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto erfcx(T z) noexcept; //1 +//! template constexpr auto erfcx(T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! 1. a real input z is treated as if complex(z) was entered. +//! +//! 2. The value of the normalized complementary error function is returned. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/erfcx.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_erfcx erfcx = {}; +} diff --git a/include/kyosu/complex/erfi.hpp b/include/kyosu/complex/erfi.hpp new file mode 100644 index 00000000..7b69a037 --- /dev/null +++ b/include/kyosu/complex/erfi.hpp @@ -0,0 +1,80 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_erfi : eve::elementwise + { + using callable_tag_type = callable_erfi; + + KYOSU_DEFERS_CALLABLE(erfi_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto over = eve::sqr(v) > 720; + auto r = eve::inf(eve::as(v))*eve::sign(v); + r = eve::if_else(over, r, -kyosu::imag(kyosu::erf(complex(eve::zero(eve::as(v)), -v)))); + return complex(r); + } + + template + KYOSU_FORCEINLINE auto operator()(T const & target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var erfi +//! @brief Callable object computing The imaginary error function \f$ \displaystyle \mathrm{erfi}(z) = -i\mathrm{erf}(iz)\f$ +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto erfi(T z) noexcept; //1 +//! template constexpr auto erfi(T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Vcomplex or real value to process. +//! +//! **Return value** +//! +//! Returns the imaginary error function \f$ \displaystyle \mathrm{erfi}(z) = -i\mathrm{erf}(iz)\f$ +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/erfi.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_erfi erfi = {}; +} diff --git a/include/kyosu/complex/eta.hpp b/include/kyosu/complex/eta.hpp new file mode 100644 index 00000000..0f64ba4d --- /dev/null +++ b/include/kyosu/complex/eta.hpp @@ -0,0 +1,79 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_eta : eve::elementwise + { + using callable_tag_type = callable_eta; + + KYOSU_DEFERS_CALLABLE(eta_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto fn = callable_eta{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const & target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var eta +//! @brief Computes the Dirichlet sum \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(n+1)^z}\f$. +//! Sometimes this function is for obvious reasons called the alternative \f$\zeta\f$ function . +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto eta(K, k, T z) noexcept; //1 +//! template constexpr auto eta(K, k, T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Vcomplex or real value to process. +//! +//! **Return value** +//! +//! Returns the Dirichlet alternating zeta function: sum \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(n+1)^z}\f$ +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/eta.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_eta eta = {}; +} diff --git a/include/kyosu/complex/faddeeva.hpp b/include/kyosu/complex/faddeeva.hpp new file mode 100644 index 00000000..d26f81d5 --- /dev/null +++ b/include/kyosu/complex/faddeeva.hpp @@ -0,0 +1,78 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_faddeeva : eve::elementwise + { + using callable_tag_type = callable_faddeeva; + + KYOSU_DEFERS_CALLABLE(faddeeva_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto fn = callable_faddeeva{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var faddeeva +//! @brief Callable object computing \f$e^{-z^2}\mathrm{erfc}(-iz)\f$ the scaled complex error func +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto faddeeva(T z) noexcept; //1 +//! template constexpr auto faddeeva(T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! Returns \f$e^{-z^2}\mathrm{erfc}(-iz)\f$ the scaled complex error function +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/faddeeva.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_faddeeva faddeeva = {}; +} diff --git a/include/kyosu/complex/impl/special.hpp b/include/kyosu/complex/impl/special.hpp new file mode 100644 index 00000000..d5ae357d --- /dev/null +++ b/include/kyosu/complex/impl/special.hpp @@ -0,0 +1,251 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once +#include + +namespace kyosu::_ +{ + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const&, C const& c) noexcept + { + return eve::pedantic(eve::atan2(kyosu::imag(c), kyosu::real(c))); + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : tgamma + //===------------------------------------------------------------------------------------------- + template + auto dispatch(eve::tag_of, Z const& a0) noexcept + { + // 15 sig. digits for 0<=real(z)<=171 + // coeffs should sum to about g*g/2+23/24 + // + using r_t = eve::element_type_t>; + auto g=r_t(607)/r_t(128); + // best results when 4<=g<=5 + constexpr int N = 15; + std::array c = + { 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + .33994649984811888699e-4, + .46523628927048575665e-4, + -.98374475304879564677e-4, + .15808870322491248884e-3, + -.21026444172410488319e-3, + .21743961811521264320e-3, + -.16431810653676389022e-3, + .84418223983852743293e-4, + -.26190838401581408670e-4, + .36899182659531622704e-5 + }; + + //Num Recipes used g=5 with 7 terms + //for a less effective approximation + + auto negra0 = eve::is_negative(real(a0)); + auto z = if_else(negra0, -a0, a0); + z = dec(z); + auto zh = z+half(as()); + auto zgh=zh+g; + //trick for avoiding FP overflow above z=141 + auto zp=pow(zgh,(zh*eve::half(as()))); + auto ss = Z{0, 0}; + for(int pp = N-1; pp >= 1; --pp){ + ss+= c[pp]/(z+pp); + } + auto sq2pi = r_t(2.5066282746310005024157652848110); + auto f=(sq2pi*(c[0]+ss))*((zp*exp(-zgh))*zp); + auto o = one(as()); + f = if_else(is_eqz(z) || z == o, o, f); + //adjust for negative real parts + auto reala0 = is_real(a0); + if(eve::any(negra0)) + { + f = if_else(negra0, rec(-eve::inv_pi(as(real(a0)))*a0*f*sinpi(a0)), eve::zero); + f = if_else (negra0 && reala0 && is_flint(real(a0)), Z{nan(as(sq2pi)), eve::inf(as(sq2pi))}, f); + } + f = if_else(eve::is_gtz(real(a0)) && eve::is_flint(real(a0)) && reala0, complex(nearest(real(f))), f); + f = if_else (is_eqz(a0), complex(inf(as(g))*pedantic(signnz)(real(a0))), f); + return f; + } + + // //===------------------------------------------------------------------------------------------- +// // Unary functions : log_gamma +// //===------------------------------------------------------------------------------------------- +// template +// EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& a0) noexcept +// { +// return log_abs(tgamma(a0)); +// } + +// template +// auto dispatch(eve::tag_of, Z const& a0) noexcept +// { +// // 15 sig. digits for 0<=real(z)<=171 +// // coeffs should sum to about g*g/2+23/24 +// // +// using r_t = eve::element_type_t>; +// auto g=r_t(607)/r_t(128); +// // best results when 4<=g<=5 +// constexpr int N = 15; +// std::array c = +// { 0.99999999999999709182, +// 57.156235665862923517, +// -59.597960355475491248, +// 14.136097974741747174, +// -0.49191381609762019978, +// .33994649984811888699e-4, +// .46523628927048575665e-4, +// -.98374475304879564677e-4, +// .15808870322491248884e-3, +// -.21026444172410488319e-3, +// .21743961811521264320e-3, +// -.16431810653676389022e-3, +// .84418223983852743293e-4, +// -.26190838401581408670e-4, +// .36899182659531622704e-5 +// }; + +// //Num Recipes used g=5 with 7 terms +// //for a less effective approximation + +// auto negra0 = is_negative(real(a0)); +// auto z = if_else(negra0, -a0, a0); +// auto ss = Z{0, 0}; +// for(int pp = N-1; pp >= 1; --pp){ +// ss += c[pp]*rec(z+dec(pp)); +// } +// auto zg = z+g-half(as(g)); +// auto lsq2pi = r_t(0.9189385332046727417803297); +// auto f=(lsq2pi + log(c[0]+ss)) - zg + (z-half(as()))*log(zg); +// auto zer = Z{0, 0}; +// auto o = Z{1, 0}; +// auto t = Z{2, 0}; +// f = if_else(z == t|| z == o, zer, f); +// //adjust for negative real parts +// if(any(negra0)) +// { +// auto lpi = Z{1.14472988584940017414342735, pi(as(g))}; +// auto reala0 = is_real(a0); +// f = if_else(negra0, lpi-log(a0)-f-log(sinpi(a0)), f); +// f = if_else (negra0 && reala0 && is_flint(real(a0)), Z{nan(as(g)), inf(as(g))}, f); +// } +// return f; +// } + +// //===------------------------------------------------------------------------------------------- +// // Unary functions : digamma +// //===------------------------------------------------------------------------------------------- +// template +// auto dispatch(eve::tag_of, Z const& a0) noexcept +// { +// // 15 sig. digits for 0<=real(z)<=171 +// // coeffs should sum to about g*g/2+23/24 +// // +// using r_t = eve::element_type_t>; +// auto g=r_t(607)/r_t(128); +// // best results when 4<=g<=5 +// constexpr int N = 15; +// std::array c = +// { 0.99999999999999709182, +// 57.156235665862923517, +// -59.597960355475491248, +// 14.136097974741747174, +// -0.49191381609762019978, +// .33994649984811888699e-4, +// .46523628927048575665e-4, +// -.98374475304879564677e-4, +// .15808870322491248884e-3, +// -.21026444172410488319e-3, +// .21743961811521264320e-3, +// -.16431810653676389022e-3, +// .84418223983852743293e-4, +// -.26190838401581408670e-4, +// .36899182659531622704e-5 +// }; + +// //Num Recipes used g=5 with 7 terms +// //for a less effective approximation + +// auto reflection = real(a0) < half(as(real(a0))); +// auto z = if_else(reflection, oneminus(a0), a0); + +// auto d = Z{0, 0}; +// auto n = d; +// for(int pp = N-1; pp >= 1; --pp){ +// auto dz = rec(z+dec(pp)); +// auto dd = c[pp]*dz; +// d += dd; +// n -= dd*dz; +// } +// d+= c[0]; +// auto zg = z+g-half(as(g)); +// auto f = log(zg) + (n/d - g/zg); + +// if(any(reflection)) +// { +// f = if_else(reflection, f-pi(as(g))*cotpi(a0), f); +// f = if_else (reflection && is_real(a0) && is_flint(real(a0)), Z{nan(as(g)), inf(as(g))}, f); +// } +// return f; +// } + +// //===------------------------------------------------------------------------------------------- +// // Unary functions : zeta +// //===------------------------------------------------------------------------------------------- +// template +// EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept +// { +// auto zz=exp2(z); +// auto k = zz/(zz-2); +// return if_else(z == one(as(z)), Z(inf(as(real(z))), 0), k*eta(z)); +// } + +// //===------------------------------------------------------------------------------------------- +// // Binary functions : rising_factorial, lrising_factorial, lbeta, beta +// //===------------------------------------------------------------------------------------------- +// template +// EVE_FORCEINLINE auto complex_binary_dispatch( eve::tag::rising_factorial> +// , Z1 const& a0, Z2 const& a1) noexcept +// { +// return if_else(is_eqz(a1), one, pedantic(div)(tgamma(a0+a1),tgamma(a0))); +// } + +// template +// EVE_FORCEINLINE auto complex_binary_dispatch( eve::tag::lrising_factorial_ +// , Z1 const& a0, Z2 const& a1) noexcept +// { +// return if_else(is_eqz(a1), zero, log( pedantic(div)(tgamma(a0+a1),tgamma(a0)))); +// } + +// template +// EVE_FORCEINLINE auto complex_binary_dispatch( eve::tag::lbeta_ +// , Z1 const& a0, Z2 const& a1) noexcept +// { +// return log(beta(a0, a1)); +// } + +// template +// EVE_FORCEINLINE auto complex_binary_dispatch( eve::tag::beta_ +// , Z1 const& a0, Z2 const& a1) noexcept +// { +// auto y = a0 + a1; +// return tgamma(a0)*tgamma(a1)/tgamma(y); +// } + + +// } + +// #include +// #include + +} diff --git a/include/kyosu/complex/lambda.hpp b/include/kyosu/complex/lambda.hpp new file mode 100644 index 00000000..b0aa70c4 --- /dev/null +++ b/include/kyosu/complex/lambda.hpp @@ -0,0 +1,82 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_lambda : eve::elementwise + { + using callable_tag_type = callable_lambda; + + KYOSU_DEFERS_CALLABLE(lambda_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto fn = callable_lambda{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const & target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var lambda +//! @brief Callable object computing The Dirichlet \f$ \displaystyle \lambda(z) = \sum_0^\infty \frac{1}{(2n+1)^z}\f$ +//! +//! This function can be extended to the whole complex plane as \f$\lambda(z) = \zeta(z)(1-2^{-x})\f$ +//! (where \f$\zeta\f$ is the Riemann zeta function). It coincides with the serie where the serie converges. +//! However for `z = 1` the result is \f$\infty\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto lambda(K, k, T z) noexcept; //1 +//! template constexpr auto lambda(K, k, T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Vcomplex or real value to process. +//! +//! **Return value** +//! +//! Returns the Dirichlet sum \f$ \displaystyle \sum_0^\infty \frac{1}{(2n+1)^z}\f$ +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lambda.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_lambda lambda = {}; +} diff --git a/include/kyosu/complex/lbeta.hpp b/include/kyosu/complex/lbeta.hpp new file mode 100644 index 00000000..f343bd3a --- /dev/null +++ b/include/kyosu/complex/lbeta.hpp @@ -0,0 +1,84 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_lbeta : eve::elementwise + { + using callable_tag_type = callable_lbeta; + + KYOSU_DEFERS_CALLABLE(lbeta_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v, U const& w) noexcept { + auto fn = callable_lbeta{}; + return fn(complex(v), w); } + + template + KYOSU_FORCEINLINE auto operator()(T const& target1, U const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2)) + { + return eve::tag_invoke(*this, target1, target2); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var lbeta +//! @brief Computes the natural logarithm of the lbeta function. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template< eve::floating_ordered_value T, eve::floating_ordered_value U > +//! auto lbeta(T x,U y) noexcept; //1 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lbeta(eve::complex_t x, U y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lbeta(T x, eve::complex_t y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lbeta(eve::complex_t x, eve::complex_t y) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `x`,`y` : Values to process. +//! +//! **Return value** +//! +//! `log(beta(x, y)`. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lbeta.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_lbeta lbeta = {}; +} diff --git a/include/kyosu/complex/log_abs_gamma.hpp b/include/kyosu/complex/log_abs_gamma.hpp new file mode 100644 index 00000000..ae38ffad --- /dev/null +++ b/include/kyosu/complex/log_abs_gamma.hpp @@ -0,0 +1,77 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_log_abs_gamma : eve::elementwise + { + using callable_tag_type = callable_log_abs_gamma; + + KYOSU_DEFERS_CALLABLE(log_abs_gamma_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto fn = callable_log_abs_gamma{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var log_abs_gamma +//! @brief Computes the log of the modulus of the \f$\Gamma\f$ function of the parameter. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr T log_abs_gamma(T z) noexcept; +//! template constexpr T log_abs_gamma(T z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! Returns \f$\log(|\Gamma(z)|)\f$. If z is floating the result is as if complex(z) was used in the call. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/log_abs_gamma.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_log_abs_gamma log_abs_gamma = {}; +} diff --git a/include/kyosu/complex/log_gamma.hpp b/include/kyosu/complex/log_gamma.hpp new file mode 100644 index 00000000..757fc8c0 --- /dev/null +++ b/include/kyosu/complex/log_gamma.hpp @@ -0,0 +1,75 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_log_gamma : eve::elementwise + { + using callable_tag_type = callable_log_gamma; + + KYOSU_DEFERS_CALLABLE(log_gamma_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { + auto fn = callable_log_gamma{}; + return fn(complex(v)); } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var log_gamma +//! @brief Computes the log of the \f$\Gamma\f$ function of the parameter. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr T log_gamma(T z) noexcept; +//! template constexpr T log_gamma(T z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! Returns \f$\log(\Gamma(z))\f$. If z is floating the result is as if complex(z) was used in the call. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/log_gamma.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_log_gamma log_gamma = {}; +} diff --git a/include/kyosu/complex/lrising_factorial.hpp b/include/kyosu/complex/lrising_factorial.hpp new file mode 100644 index 00000000..de1c9661 --- /dev/null +++ b/include/kyosu/complex/lrising_factorial.hpp @@ -0,0 +1,84 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_lrising_factorial : eve::elementwise + { + using callable_tag_type = callable_lrising_factorial; + + KYOSU_DEFERS_CALLABLE(lrising_factorial_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T1 const& v, T2 const& w) noexcept { + auto fn = callable_lrising_factorial{}; + return fn(v, w); } + + template + KYOSU_FORCEINLINE auto operator()(T1 const& target1, T2 const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2)) + { + return eve::tag_invoke(*this, target1, target2); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var lrising_factorial +//! @brief Computes the lrising_factorial function: \f$\log\frac{\Gamma(x+y)}{\Gamma(x)}\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template< eve::floating_ordered_value T, eve::floating_ordered_value U > +//! auto lrising_factorial(T x,U y) noexcept; //1 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lrising_factorial(eve::complex_t x, U y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lrising_factorial(T x, eve::complex_t y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto lrising_factorial(eve::complex_t x, eve::complex_t y) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `x`,`y` : Values to process. +//! +//! **Return value** +//! +//! @brief Computes the Rising Factorial function i.e. \f$\log\frac{\Gamma(x+y)}{\Gamma(x)}\f$. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lrising_factorial.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_lrising_factorial lrising_factorial = {}; +} diff --git a/include/kyosu/complex/polar.hpp b/include/kyosu/complex/polar.hpp index 09252844..bac79926 100644 --- a/include/kyosu/complex/polar.hpp +++ b/include/kyosu/complex/polar.hpp @@ -21,7 +21,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T0 const& rho, T1 const & theta) noexcept { auto [s, c] = eve::sincos(theta); - return kyosu::to_complex(rho*c, eve::if_else(eve::is_eqz(s), eve::zero, rho*s)); + return kyosu::complex(rho*c, eve::if_else(eve::is_eqz(s), eve::zero, rho*s)); } template diff --git a/include/kyosu/complex/rising_factorial.hpp b/include/kyosu/complex/rising_factorial.hpp new file mode 100644 index 00000000..add8c8ec --- /dev/null +++ b/include/kyosu/complex/rising_factorial.hpp @@ -0,0 +1,84 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_rising_factorial : eve::elementwise + { + using callable_tag_type = callable_rising_factorial; + + KYOSU_DEFERS_CALLABLE(rising_factorial_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T1 const& v, T2 const& w) noexcept { + auto fn = callable_rising_factorial{}; + return fn(v, w); } + + template + KYOSU_FORCEINLINE auto operator()(T1 const& target1, T2 const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2)) + { + return eve::tag_invoke(*this, target1, target2); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var rising_factorial +//! @brief Computes the rising_factorial function: \f$\frac{\Gamma(x+y)}{\Gamma(x)}\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template< eve::floating_ordered_value T, eve::floating_ordered_value U > +//! auto rising_factorial(T x,U y) noexcept; //1 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto rising_factorial(eve::complex_t x, U y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto rising_factorial(T x, eve::complex_t y) noexcept; //2 +//! +//! template< eve::floating_value T, eve::floating_value U > +//! auto rising_factorial(eve::complex_t x, eve::complex_t y) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `x`,`y` : Values to process. +//! +//! **Return value** +//! +//! @brief Computes the Rising Factorial function i.e. \f$\frac{\Gamma(x+y)}{\Gamma(x)}\f$. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/rising_factorial.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_rising_factorial rising_factorial = {}; +} diff --git a/include/kyosu/complex/tgamma.hpp b/include/kyosu/complex/tgamma.hpp new file mode 100644 index 00000000..86219211 --- /dev/null +++ b/include/kyosu/complex/tgamma.hpp @@ -0,0 +1,76 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_tgamma : eve::elementwise + { + using callable_tag_type = callable_tgamma; + + KYOSU_DEFERS_CALLABLE(tgamma_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { + auto fn = callable_tgamma{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var tgamma +//! @brief Computes the tgammaolute value of the parameter. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr T tgamma(T z) noexcept; +//! template constexpr T tgamma(T z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to process. +//! +//! **Return value** +//! +//! Returns \f$\Gamma(z)\f$. If z is floating the result is as if complex(z) was used in the call. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/tgamma.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_tgamma tgamma = {}; +} diff --git a/include/kyosu/complex/zeta.hpp b/include/kyosu/complex/zeta.hpp new file mode 100644 index 00000000..ea909afc --- /dev/null +++ b/include/kyosu/complex/zeta.hpp @@ -0,0 +1,79 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_zeta : eve::elementwise + { + using callable_tag_type = callable_zeta; + + KYOSU_DEFERS_CALLABLE(zeta_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept + { + auto fn = callable_zeta{}; + return fn(complex(v)); + } + + template + KYOSU_FORCEINLINE auto operator()(T const & target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var zeta +//! @brief Computes the Riemann \f$\zeta\f$ \f$ \displaystyle \sum_0^\infty \frac{1}{(n+1)^z}\f$. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto zeta(K, k, T z) noexcept; //1 +//! template constexpr auto zeta(K, k, T z) noexcept; //2 +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `k` : scalar unsigned value, parameter of the sum. +//! * `z` : Vcomplex or real value to process. +//! +//! **Return value** +//! +//! Returns the Dirichlet alternating zzeta function: sum \f$ \displaystyle \sum_0^\infty \frac{1}{(n+1)^z}\f$ +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/zeta.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_zeta zeta = {}; +} diff --git a/include/kyosu/functions.hpp b/include/kyosu/functions.hpp index 2197a603..9fc6b0e3 100644 --- a/include/kyosu/functions.hpp +++ b/include/kyosu/functions.hpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -122,10 +124,26 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include -#include +#include +#include #include +#include //====================================================================================================================== //! @brief Functions performing computations over quaternion complex or real elements only. diff --git a/include/kyosu/functions/acos.hpp b/include/kyosu/functions/acos.hpp index 02a13ffe..6772558b 100644 --- a/include/kyosu/functions/acos.hpp +++ b/include/kyosu/functions/acos.hpp @@ -63,9 +63,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns elementwise the complex principal value //! of the arc cosine of the input. //! Branch cuts exist outside the interval \f$[-1, +1]\f$ along the real axis. //! diff --git a/include/kyosu/functions/asin.hpp b/include/kyosu/functions/asin.hpp index 4381824d..d4b3cad1 100644 --- a/include/kyosu/functions/asin.hpp +++ b/include/kyosu/functions/asin.hpp @@ -63,9 +63,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if to_complex(z) was entered. +//! 1. a real input z is treated as if complex(z) was entered. //! -//! 2. Returns the [elementwise](@ref glossary_elementwise) the complex principal value +//! 2. Returns elementwise the complex principal value //! of the arc sine of the input in the range of a strip unbounded along the imaginary axis //! and in the interval \f$[-\pi/2, \pi/2]\f$ along the real axis. //! diff --git a/include/kyosu/functions/exp_i.hpp b/include/kyosu/functions/exp_i.hpp index 71ccbd20..73668dee 100644 --- a/include/kyosu/functions/exp_i.hpp +++ b/include/kyosu/functions/exp_i.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { - const auto ii = kyosu::to_complex(T(0), T(1)); + const auto ii = kyosu::complex(T(0), T(1)); return kyosu::exp(ii*v); } diff --git a/include/kyosu/functions/exp_ipi.hpp b/include/kyosu/functions/exp_ipi.hpp index 1d92ec20..257590bf 100644 --- a/include/kyosu/functions/exp_ipi.hpp +++ b/include/kyosu/functions/exp_ipi.hpp @@ -22,7 +22,7 @@ namespace kyosu::tags template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { - const auto ii = kyosu::to_complex(T(0), T(1))*eve::pi(eve::as()); + const auto ii = kyosu::complex(T(0), T(1))*eve::pi(eve::as()); return kyosu::exp(ii*v); } diff --git a/include/kyosu/functions/from_angle_axis.hpp b/include/kyosu/functions/from_angle_axis.hpp index b015676c..4d9c2c71 100644 --- a/include/kyosu/functions/from_angle_axis.hpp +++ b/include/kyosu/functions/from_angle_axis.hpp @@ -24,7 +24,7 @@ namespace kyosu::tags , V const & angle , std::span axis) noexcept { - auto q = to_quaternion(U(0), axis[0], axis[1], axis[2]); + auto q = quaternion(U(0), axis[0], axis[1], axis[2]); auto [s, c] = eve::sincos(angle*eve::half(eve::as(angle))); return c+s*q; } diff --git a/include/kyosu/functions/from_cylindrical.hpp b/include/kyosu/functions/from_cylindrical.hpp index 46b90abc..9958e5d1 100644 --- a/include/kyosu/functions/from_cylindrical.hpp +++ b/include/kyosu/functions/from_cylindrical.hpp @@ -27,7 +27,7 @@ namespace kyosu::tags { using e_t = decltype(r+angle+h1+h2); auto [sa, ca] = eve::sincos(angle); - return kyosu::to_quaternion(r*ca, r*sa, h1, h2); + return kyosu::quaternion(r*ca, r*sa, h1, h2); } template diff --git a/include/kyosu/functions/from_cylindricospherical.hpp b/include/kyosu/functions/from_cylindricospherical.hpp index 9c319a96..6c2cfd29 100644 --- a/include/kyosu/functions/from_cylindricospherical.hpp +++ b/include/kyosu/functions/from_cylindricospherical.hpp @@ -28,7 +28,7 @@ namespace kyosu::tags auto [slat, clat] = eve::sincos(latitude); auto [slon, clon] = eve::sincos(longitude); auto f = r*clat; - return kyosu::to_quaternion(t, f*clon, f*slon, r*slat); + return kyosu::quaternion(t, f*clon, f*slon, r*slat); } template diff --git a/include/kyosu/functions/from_euler.hpp b/include/kyosu/functions/from_euler.hpp index 897d77a4..5504acb7 100644 --- a/include/kyosu/functions/from_euler.hpp +++ b/include/kyosu/functions/from_euler.hpp @@ -34,7 +34,7 @@ namespace kyosu::tags requires(I != J && J != K) { using e_t = decltype(v1+v2+v3); - using q_t = decltype(to_quaternion(e_t{})); + using q_t = decltype(quaternion(e_t{})); auto h = eve::half(eve::as()); std::array qs; auto [sa, ca] = eve::sincos(v3*h); diff --git a/include/kyosu/functions/from_multipolar.hpp b/include/kyosu/functions/from_multipolar.hpp index d68bd425..55f1a6cb 100644 --- a/include/kyosu/functions/from_multipolar.hpp +++ b/include/kyosu/functions/from_multipolar.hpp @@ -28,7 +28,7 @@ namespace kyosu::tags { auto [a0, a1] = kyosu::from_polar(rho1, theta1); auto [a2, a3] = kyosu::from_polar(rho2, theta2); - return kyosu::to_quaternion(a0, a1, a2, a3); + return kyosu::quaternion(a0, a1, a2, a3); } template @@ -74,7 +74,8 @@ namespace kyosu //! namespace eve //! { //! auto from_multipolar( auto rho1, auto theta1 auto rho2, auto theta2) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/from_polar.hpp b/include/kyosu/functions/from_polar.hpp index 6e96d996..1d4ea786 100644 --- a/include/kyosu/functions/from_polar.hpp +++ b/include/kyosu/functions/from_polar.hpp @@ -26,7 +26,7 @@ namespace kyosu::tags auto r = eve::abs(v); auto a = eve::if_else(eve::is_positive(v), u, eve::pi(eve::as(u))+u); auto [s, c] = eve::sincos(a); - return to_complex(r*c, r*s); + return complex(r*c, r*s); } template @@ -66,7 +66,8 @@ namespace kyosu //! namespace eve //! { //! auto from_polar( auto rho, auto theta) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/from_rotation_matrix.hpp b/include/kyosu/functions/from_rotation_matrix.hpp index b653dd2a..a3390298 100644 --- a/include/kyosu/functions/from_rotation_matrix.hpp +++ b/include/kyosu/functions/from_rotation_matrix.hpp @@ -42,7 +42,7 @@ namespace kyosu::tags auto q2 = eve::sqrt(eve::if_else(is_gtz(qq2m1), eve::inc(qq2m1), (eve::sqr(r02mr20)+sqr(r01pr10)+eve::sqr(r12pr21))/(3-qq2m1)))*h; auto q3 = eve::sqrt(eve::if_else(is_gtz(qq3m1), eve::inc(qq3m1), (eve::sqr(r10mr01)+sqr(r20pr02)+eve::sqr(r12pr21))/(3-qq3m1)))*h; using e_t = decltype(r11pr22); - return to_quaternion(q0, q1, q2, q3); + return quaternion(q0, q1, q2, q3); } template diff --git a/include/kyosu/functions/from_semipolar.hpp b/include/kyosu/functions/from_semipolar.hpp index eddc4f95..d9bc39c8 100644 --- a/include/kyosu/functions/from_semipolar.hpp +++ b/include/kyosu/functions/from_semipolar.hpp @@ -28,7 +28,7 @@ namespace kyosu::tags auto [st1, ct1] = eve::sincos(theta1); auto [st2, ct2] = eve::sincos(theta2); auto [sa, ca] = eve::sincos(alpha); - return rho*kyosu::to_quaternion(ca*ct1, ca*st1, sa*ct2, sa*st2); + return rho*kyosu::quaternion(ca*ct1, ca*st1, sa*ct2, sa*st2); } template diff --git a/include/kyosu/functions/from_spherical.hpp b/include/kyosu/functions/from_spherical.hpp index 0711e531..787990e1 100644 --- a/include/kyosu/functions/from_spherical.hpp +++ b/include/kyosu/functions/from_spherical.hpp @@ -29,7 +29,7 @@ namespace kyosu::tags auto [sp1, cp1] = eve::sincos(phi1); auto [sp2, cp2] = eve::sincos(phi2); auto f = cp1*cp2; - return rho*to_quaternion(ct*f, st*f, sp1*cp2, sp2); + return rho*quaternion(ct*f, st*f, sp1*cp2, sp2); } template diff --git a/include/kyosu/functions/ldiv.hpp b/include/kyosu/functions/ldiv.hpp new file mode 100644 index 00000000..f5c3890e --- /dev/null +++ b/include/kyosu/functions/ldiv.hpp @@ -0,0 +1,79 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include +namespace kyosu::tags +{ + struct callable_ldiv : eve::elementwise + { + using callable_tag_type = callable_ldiv; + + KYOSU_DEFERS_CALLABLE(ldiv_); + + static KYOSU_FORCEINLINE auto deferred_call(auto + , eve::ordered_value auto const& v0 + , eve::ordered_value auto const& v1) noexcept + { + return v1/v0; + } + + KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1) const noexcept + -> decltype(eve::tag_invoke(*this, target0, target1)) + { + return eve::tag_invoke(*this, target0, target1); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var ldiv +//! @brief Computes the left division of the two parameters. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto ldiv(T0 z0, T1, z1) noexcept; +//! template > constexpr auto ldiv(T0 z0, T1, z1) noexcept; +//! template constexpr auto ldiv(T0 z0, T1, z1) noexcept; +//! template > constexpr auto ldiv(T0 z0, T1, z1) noexcept; +///! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z0, z1` : Values to process. +//! +//! **Return value** +//! +//! Returns the left division of the two arguments. This function not equivalent to z1/z0 as soon as multiplication +//! is not commutative. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/ldiv.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_ldiv ldiv = {}; +} diff --git a/include/kyosu/functions/log.hpp b/include/kyosu/functions/log.hpp index 56149962..e86727af 100644 --- a/include/kyosu/functions/log.hpp +++ b/include/kyosu/functions/log.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log{}; - return fn( kyosu::to_complex(v, T(0))); + return fn( kyosu::complex(v, T(0))); } template diff --git a/include/kyosu/functions/log10.hpp b/include/kyosu/functions/log10.hpp index c1bb477d..f124d6b1 100644 --- a/include/kyosu/functions/log10.hpp +++ b/include/kyosu/functions/log10.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log10{}; - return fn( kyosu::to_complex(v, T(0))); + return fn( kyosu::complex(v, T(0))); } template @@ -58,7 +58,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T log10(T z) noexcept; -//! template constexpr as_complex_t log10(T z) noexcept; +//! template constexpr complex_t log10(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/log1p.hpp b/include/kyosu/functions/log1p.hpp index e7dbf404..b821a6db 100644 --- a/include/kyosu/functions/log1p.hpp +++ b/include/kyosu/functions/log1p.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log1p{}; - return fn( kyosu::to_complex(v, T(0))); + return fn( kyosu::complex(v, T(0))); } template @@ -58,7 +58,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T log1p(T z) noexcept; -//! template constexpr as_complex_t log1p(T z) noexcept; +//! template constexpr complex_t log1p(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/log2.hpp b/include/kyosu/functions/log2.hpp index e8b3a5de..09902307 100644 --- a/include/kyosu/functions/log2.hpp +++ b/include/kyosu/functions/log2.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log2{}; - return fn( kyosu::to_complex(v, T(0))); + return fn( kyosu::complex(v, T(0))); } template @@ -58,7 +58,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T log2(T z) noexcept; -//! template constexpr as_complex_t log2(T z) noexcept; +//! template constexpr complex_t log2(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/log_abs.hpp b/include/kyosu/functions/log_abs.hpp index dcae6ed0..6246cd8e 100644 --- a/include/kyosu/functions/log_abs.hpp +++ b/include/kyosu/functions/log_abs.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log_abs{}; - return fn( kyosu::to_complex(v, T(0))); + return fn( kyosu::complex(v, T(0))); } template diff --git a/include/kyosu/functions/multipolar.hpp b/include/kyosu/functions/multipolar.hpp index e1be237d..3a2495e4 100644 --- a/include/kyosu/functions/multipolar.hpp +++ b/include/kyosu/functions/multipolar.hpp @@ -28,7 +28,7 @@ namespace kyosu::tags auto [slat, clat] = eve::sincos(latitude); auto [slon, clon] = eve::sincos(longitude); auto f = r*clat; - return kyosu::to_quaternion(t, f*clon, f*slon, r*slat); + return kyosu::quaternion(t, f*clon, f*slon, r*slat); } template @@ -72,9 +72,10 @@ namespace kyosu //! //! @code //! namespace eve - //! { + //! { //! auto from_multipolar( auto rho1, auto theta1 auto rho2, auto theta2) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/proj.hpp b/include/kyosu/functions/proj.hpp new file mode 100644 index 00000000..6f9afc83 --- /dev/null +++ b/include/kyosu/functions/proj.hpp @@ -0,0 +1,79 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once + +#include + +namespace kyosu::tags +{ + struct callable_proj : eve::elementwise + { + using callable_tag_type = callable_proj; + + KYOSU_DEFERS_CALLABLE(proj_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { + return complex(v,eve::sign(v)*eve::zero(eve::as(v))); + } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ +//====================================================================================================================== +//! @addtogroup functions +//! @{ +//! @var proj +//! @brief Callable object computing proj(x), the projection of the cayley_dickson number z onto the (hyper) Riemann sphere +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr T proj(T z) noexcept; +//! template constexpr T proj(T z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Value to projugate. +//! +//! **Return value** +//! +//! For most z, std::proj(z)==z, but all infinities, even the numbers where one component +//! is infinite and the other is NaN, become positive real infinity, (inf, 0.0...) or (inf, -0.0...). +//! The sign of the pure (zero) components is the signs of the components of pure(z). +//! +//! For floating inputs the call returns a complex number. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/proj.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_proj proj = {}; +} diff --git a/include/kyosu/functions/rot_angle.hpp b/include/kyosu/functions/rot_angle.hpp index b03a8b21..23ccef2b 100644 --- a/include/kyosu/functions/rot_angle.hpp +++ b/include/kyosu/functions/rot_angle.hpp @@ -61,7 +61,8 @@ namespace kyosu //! namespace eve //! { //! auto rot_angle( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/rot_axis.hpp b/include/kyosu/functions/rot_axis.hpp index f6e897e8..e6913e34 100644 --- a/include/kyosu/functions/rot_axis.hpp +++ b/include/kyosu/functions/rot_axis.hpp @@ -61,7 +61,8 @@ namespace kyosu //! namespace eve //! { //! auto rot_axis( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/rotate_vec b/include/kyosu/functions/rotate_vec deleted file mode 100644 index 2e6ab4e8..00000000 --- a/include/kyosu/functions/rotate_vec +++ /dev/null @@ -1,104 +0,0 @@ -//================================================================================================== -/* - KYOSU - Expressive Vector Engine - Copyright : KYOSU Project Contributors - SPDX-License-Identifier: BSL-1.0 -*/ -//================================================================================================== -#pragma once - -#include -#include - -namespace kyosu::tags -{ - struct callable_rot_vec : eve::elementwise - { - using callable_tag_type = callable_rot_vec; - - KYOSU_DEFERS_CALLABLE(rot_vec_); - - template - static KYOSU_FORCEINLINE auto deferred_call(auto - , V const & v - , nor) noexcept - { - return v; - } - - template - static KYOSU_FORCEINLINE auto deferred_call(auto - , V const & - , std::span const & v - ) noexcept - { - return v; - } - - template - KYOSU_FORCEINLINE auto operator()( T0 const& target0 - , T1 const& target1 - , nor) const noexcept - -> decltype(eve::tag_invoke(*this, target0, nor())) - { - return eve::tag_invoke(*this, target0, nor()); - } - - template - KYOSU_FORCEINLINE auto operator()(T0 const& target0, - T1 const& target1) const noexcept - -> decltype(eve::tag_invoke(*this, target0, target1)) - { - return eve::tag_invoke(*this, target0, target1, Normalize); - } - - template - eve::unsupported_call operator()(T&&... x) const - requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; - }; -} - -namespace kyosu -{ - //================================================================================================ - //! @addtogroup quaternion - //! @{ - //! @var rot_vec - //! - //! @brief Callable object rotatating an \f$\mathbb{R}\f$ using a quaternion. - //! - //! **Defined in header** - //! - //! @code - //! #include eve/module/quaternion.hpp>` - //! @endcode - //! - //! @groupheader{Callable Signatures} - //! - //! @code - //! namespace eve - //! { - //! auto rot_vec( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - //! - //! **Parameters** - //! - //! `q`: [quaternion](@ref eve::value) defining the rotation. - //! `x`: span of 3 elements to rotate - //! - //! **Return value** - //! - //! the span rotated by q - //! - //! --- - //! - //! #### Example - //! - //! @godbolt{doc/quaternion/regular/rot_vec.cpp} - //! - //! @} - //================================================================================================ - inline constexpr tags::callable_rot_vec rot_vec = {}; -} diff --git a/include/kyosu/functions/rotate_vec.hpp b/include/kyosu/functions/rotate_vec.hpp index 1399e2c5..6febedc6 100644 --- a/include/kyosu/functions/rotate_vec.hpp +++ b/include/kyosu/functions/rotate_vec.hpp @@ -82,7 +82,8 @@ namespace kyosu //! namespace eve //! { //! auto rotate_vec( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/semipolar.hpp b/include/kyosu/functions/semipolar.hpp index b3fe9ee9..91efee1d 100644 --- a/include/kyosu/functions/semipolar.hpp +++ b/include/kyosu/functions/semipolar.hpp @@ -25,11 +25,11 @@ namespace kyosu::tags , W const & theta1 , T const & theta2) noexcept { - using z_t = eve::as_quaternion_t; + using z_t = eve::quaternion_t; auto [st1, ct1] = eve::sincos(theta1); auto [st2, ct2] = eve::sincos(theta2); auto [sa, ca] = eve::sincos(alpha); - return rho*to_quaternion(ca*ct1, ca*st1, sa*ct2, sa*st2); + return rho*quaternion(ca*ct1, ca*st1, sa*ct2, sa*st2); } template diff --git a/include/kyosu/functions/sqrt.hpp b/include/kyosu/functions/sqrt.hpp index 10b49e96..dec55303 100644 --- a/include/kyosu/functions/sqrt.hpp +++ b/include/kyosu/functions/sqrt.hpp @@ -23,7 +23,7 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto asq = eve::sqrt(eve::abs(v)); - return if_else(eve::is_gez(v), to_complex(asq, T(0)), to_complex(T(0), asq)); + return if_else(eve::is_gez(v), complex(asq, T(0)), complex(T(0), asq)); } template diff --git a/include/kyosu/functions/to_angle_axis.hpp b/include/kyosu/functions/to_angle_axis.hpp index e6eaaa6d..b18cbf13 100644 --- a/include/kyosu/functions/to_angle_axis.hpp +++ b/include/kyosu/functions/to_angle_axis.hpp @@ -60,9 +60,10 @@ namespace kyosu //! //! @code //! namespace eve - //! { + //! { //! auto to_angle_axis( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/to_complex.hpp b/include/kyosu/functions/to_complex.hpp index 71e0e6b0..9347c111 100644 --- a/include/kyosu/functions/to_complex.hpp +++ b/include/kyosu/functions/to_complex.hpp @@ -11,11 +11,11 @@ namespace kyosu::tags { - struct callable_to_complex + struct callable_complex { - using callable_tag_type = callable_to_complex; + using callable_tag_type = callable_complex; - KYOSU_DEFERS_CALLABLE(to_complex_); + KYOSU_DEFERS_CALLABLE(complex_); template KYOSU_FORCEINLINE auto operator()(T... target) const noexcept -> decltype(eve::tag_invoke(*this, target...)) @@ -24,7 +24,7 @@ namespace kyosu::tags } template - eve::unsupported_call operator()(T&&... x) const + eve::unsupported_call operator()(T&&... x) const requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; }; } @@ -34,7 +34,7 @@ namespace kyosu //====================================================================================================================== //! @addtogroup functions //! @{ -//! @var to_complex +//! @var complex //! @brief Constructs a kyosu::complex //! //! **Defined in Header** @@ -48,10 +48,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto to_complex(T r) noexcept; -//! template constexpr auto to_complex(T r, T i) noexcept; - -//! template constexpr T to_complex(T z) noexcept; +//! template constexpr auto complex(T r, T i = 0) noexcept; +//! template constexpr T complex(T z) noexcept; //! } //! @endcode //! @@ -69,6 +67,5 @@ namespace kyosu //! @godbolt{doc/to_complex.cpp} //! @} //====================================================================================================================== -inline constexpr tags::callable_to_complex to_complex = {}; +inline constexpr tags::callable_complex complex = {}; } - diff --git a/include/kyosu/functions/to_cylindrical.hpp b/include/kyosu/functions/to_cylindrical.hpp index 5883bfcf..bb2421ba 100644 --- a/include/kyosu/functions/to_cylindrical.hpp +++ b/include/kyosu/functions/to_cylindrical.hpp @@ -61,9 +61,10 @@ namespace kyosu //! //! @code //! namespace eve - //! { + //! { //! auto to_cylindrical( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/to_multipolar.hpp b/include/kyosu/functions/to_multipolar.hpp index 325d70c4..a4465aca 100644 --- a/include/kyosu/functions/to_multipolar.hpp +++ b/include/kyosu/functions/to_multipolar.hpp @@ -61,9 +61,10 @@ namespace kyosu //! //! @code //! namespace eve - //! { + //! { //! auto to_multipolar( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/to_polar.hpp b/include/kyosu/functions/to_polar.hpp index a28a9fcd..519e348c 100644 --- a/include/kyosu/functions/to_polar.hpp +++ b/include/kyosu/functions/to_polar.hpp @@ -63,7 +63,8 @@ namespace kyosu //! namespace eve //! { //! auto to_polar( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/to_quaternion.hpp b/include/kyosu/functions/to_quaternion.hpp index f1c2661a..e75bad75 100644 --- a/include/kyosu/functions/to_quaternion.hpp +++ b/include/kyosu/functions/to_quaternion.hpp @@ -11,11 +11,11 @@ namespace kyosu::tags { - struct callable_to_quaternion + struct callable_quaternion { - using callable_tag_type = callable_to_quaternion; + using callable_tag_type = callable_quaternion; - KYOSU_DEFERS_CALLABLE(to_quaternion_); + KYOSU_DEFERS_CALLABLE(quaternion_); template KYOSU_FORCEINLINE auto operator()(T... target) const noexcept -> decltype(eve::tag_invoke(*this, target...)) @@ -24,7 +24,7 @@ namespace kyosu::tags } template - eve::unsupported_call operator()(T&&... x) const + eve::unsupported_call operator()(T&&... x) const requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; }; } @@ -34,7 +34,7 @@ namespace kyosu //====================================================================================================================== //! @addtogroup functions //! @{ -//! @var to_quaternion +//! @var quaternion //! @brief Constructs a kyosu::quaternion //! //! **Defined in Header** @@ -48,17 +48,17 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto to_quaternion(T r) noexcept; -//! template constexpr auto to_quaternion(T r, T i) noexcept; - -//! template constexpr T to_quaternion(T z) noexcept; +//! template constexpr auto quaternion(T r, T i = 0, T j = 0, T k = 0) noexcept; +//! template constexpr auto quaternion(complex_t c0, complex_t c1 = 0) noexcept; +//! template constexpr T quaternion(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Quaternion value. -//! * `r`, `i` : Real and imaginary part sued to construct a @ref kyosu::quaternion.. +//! * `z` : Quaternion value. +//! * `c0 `,`c1` : Complex values generates the quaternion c0+j*conj(c1) i.e. real(c0+i*imag(c1)+j*real(1)+k*imag(c1) +//! * `r`, `i`, `j`, `k` : Real and unreal parts sued to construct a @ref kyosu::quaternion from its components //! //! **Return value** //! @@ -69,5 +69,5 @@ namespace kyosu //! @godbolt{doc/to_quaternion.cpp} //! @} //====================================================================================================================== -inline constexpr tags::callable_to_quaternion to_quaternion = {}; +inline constexpr tags::callable_quaternion quaternion = {}; } diff --git a/include/kyosu/functions/to_semipolar.hpp b/include/kyosu/functions/to_semipolar.hpp index 68894924..d26bdb92 100644 --- a/include/kyosu/functions/to_semipolar.hpp +++ b/include/kyosu/functions/to_semipolar.hpp @@ -63,7 +63,8 @@ namespace kyosu //! namespace eve //! { //! auto to_semipolar( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/functions/to_spherical.hpp b/include/kyosu/functions/to_spherical.hpp index 29bb478e..52442dc8 100644 --- a/include/kyosu/functions/to_spherical.hpp +++ b/include/kyosu/functions/to_spherical.hpp @@ -63,7 +63,8 @@ namespace kyosu //! namespace eve //! { //! auto to_spherical( auto q) const noexcept; - //! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //! } + //! @endcode //! //! **Parameters** //! diff --git a/include/kyosu/types/cayley_dickson.hpp b/include/kyosu/types/cayley_dickson.hpp index b6645260..d527872d 100644 --- a/include/kyosu/types/cayley_dickson.hpp +++ b/include/kyosu/types/cayley_dickson.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/include/kyosu/types/complex.hpp b/include/kyosu/types/complex.hpp index bea5c643..c7c660a6 100644 --- a/include/kyosu/types/complex.hpp +++ b/include/kyosu/types/complex.hpp @@ -15,16 +15,14 @@ namespace kyosu //==================================================================================================================== //! @addtogroup types //! @{ - //! @typedef complex + //! @typedef complex_t //! @brief Type alias for complex numbers //! //! Complex numbers are implemented as Caley-dickson numbers of dimension 2. //! //! @} //==================================================================================================================== - template - using complex = cayley_dickson; template - using as_complex_t = as_cayley_dickson_n_t<2,T>; + using complex_t = as_cayley_dickson_n_t<2,T>; } diff --git a/include/kyosu/types/impl/arithmetic.hpp b/include/kyosu/types/impl/arithmetic.hpp index cc11562b..7501fe8e 100644 --- a/include/kyosu/types/impl/arithmetic.hpp +++ b/include/kyosu/types/impl/arithmetic.hpp @@ -248,5 +248,39 @@ namespace kyosu::_ return c*eve::inv_pi(eve::as()); ; } + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const&, C c) noexcept + { + using real_t = eve::as>; + constexpr auto P = kyosu::dimension_v; + if constexpr (P == 2) +// std::cout << c << " -> " << is_infinite(c) << std::endl; + return if_else(is_infinite(c) + , complex(eve::inf(real_t{}), eve::copysign(eve::zero(real_t{}), imag(c))) + , c); + else + { + auto isinf = is_infinite(c); + auto tmp = eve::if_else(isinf, eve::inf(real_t{}), real(c)); + auto setpure = [isinf](auto & x){ + x = eve::if_else(isinf, eve::copysign(eve::zero(real_t{}), x), x); + }; + kumi::for_each(setpure, c); + real(c) = tmp; + return c; + } + } + + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const&, C0 const & c0, C1 const & c1) noexcept + { + using r_t = kyosu::as_cayley_dickson_t; + if constexpr(dimension_v <= 2 || eve::ordered_value|| eve::ordered_value ) + return c1/c0; + else + return rec(c0)*c1; + } } diff --git a/include/kyosu/types/impl/complex/erf.hpp b/include/kyosu/types/impl/complex/erf.hpp new file mode 100644 index 00000000..f1b8bb10 --- /dev/null +++ b/include/kyosu/types/impl/complex/erf.hpp @@ -0,0 +1,290 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once +#include +#include +#include +#include +#include + + +namespace kyosu::_ +{ + template + auto dispatch(eve::tag_of, Z z) noexcept + { + auto numeric_sqr = [](auto z){ // UNTIL DECORATORS ARE AT HAND + auto [zr, zi] = z; + return complex((zr-zi)*(zi+zr), 2 * zr * zi); + }; + auto x = real(z); + auto y = imag(z); + using real_t = decltype(x); + using r_t = eve::element_type_t; + auto mz2 = -numeric_sqr(z);// -z^2, being careful of overflow + using A9 = kumi::result::generate_t<9, r_t>; + static constexpr std::array< A9, 97> coefs = + { + A9{0.28351593328822191546e-2,0.28494783221378400759e-2,0.14427470563276734183e-4,0.10939723080231588129e-6,0.92474307943275042045e-9,0.89128907666450075245e-11,0.92974121935111111110e-13,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.85927161243940350562e-2,0.29085312941641339862e-2,0.15106783707725582090e-4,0.11716709978531327367e-6,0.10197387816021040024e-8,0.10122678863073360769e-10,0.10917479678400000000e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.14471159831187703054e-1,0.29703978970263836210e-2,0.15835096760173030976e-4,0.12574803383199211596e-6,0.11278672159518415848e-8,0.11547462300333495797e-10,0.12894535335111111111e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.20476320420324610618e-1,0.30352843012898665856e-2,0.16617609387003727409e-4,0.13525429711163116103e-6,0.12515095552507169013e-8,0.13235687543603382345e-10,0.15326595042666666667e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.26614461952489004566e-1,0.31034189276234947088e-2,0.17460268109986214274e-4,0.14582130824485709573e-6,0.13935959083809746345e-8,0.15249438072998932900e-10,0.18344741882133333333e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.32892330248093586215e-1,0.31750557067975068584e-2,0.18369907582308672632e-4,0.15761063702089457882e-6,0.15577638230480894382e-8,0.17663868462699097951e-10,0.22126732680711111111e-12,0.30273474177737853668e-14,0.00000000000000000000e+00}, + A9{0.39317207681134336024e-1,0.32504779701937539333e-2,0.19354426046513400534e-4,0.17081646971321290539e-6,0.17485733959327106250e-8,0.20593687304921961410e-10,0.26917401949155555556e-12,0.38562123837725712270e-14,0.00000000000000000000e+00}, + A9{0.45896976511367738235e-1,0.33300031273110976165e-2,0.20423005398039037313e-4,0.18567412470376467303e-6,0.19718038363586588213e-8,0.24175006536781219807e-10,0.33059982791466666666e-12,0.49756574284439426165e-14,0.00000000000000000000e+00}, + A9{0.52640192524848962855e-1,0.34139883358846720806e-2,0.21586390240603337337e-4,0.20247136501568904646e-6,0.22348696948197102935e-8,0.28597516301950162548e-10,0.41045502119111111110e-12,0.65151614515238361946e-14,0.00000000000000000000e+00}, + A9{0.59556171228656770456e-1,0.35028374386648914444e-2,0.22857246150998562824e-4,0.22156372146525190679e-6,0.25474171590893813583e-8,0.34122390890697400584e-10,0.51593189879111111110e-12,0.86775076853908006938e-14,0.00000000000000000000e+00}, + A9{0.66655089485108212551e-1,0.35970095381271285568e-2,0.24250626164318672928e-4,0.24339561521785040536e-6,0.29221990406518411415e-8,0.41117013527967776467e-10,0.65786450716444444445e-12,0.11791885745450623331e-13,0.00000000000000000000e+00}, + A9{0.73948106345519174661e-1,0.36970297216569341748e-2,0.25784588137312868792e-4,0.26853012002366752770e-6,0.33763958861206729592e-8,0.50111549981376976397e-10,0.85313857496888888890e-12,0.16417079927706899860e-13,0.00000000000000000000e+00}, + A9{0.81447508065002963203e-1,0.38035026606492705117e-2,0.27481027572231851896e-4,0.29769200731832331364e-6,0.39336816287457655076e-8,0.61895471132038157624e-10,0.11292303213511111111e-11,0.23558532213703884304e-13,0.00000000000000000000e+00}, + A9{0.89166884027582716628e-1,0.39171301322438946014e-2,0.29366827260422311668e-4,0.33183204390350724895e-6,0.46276006281647330524e-8,0.77692631378169813324e-10,0.15335153258844444444e-11,0.35183103415916026911e-13,0.00000000000000000000e+00}, + A9{0.97121342888032322019e-1,0.40387340353207909514e-2,0.31475490395950776930e-4,0.37222714227125135042e-6,0.55074373178613809996e-8,0.99509175283990337944e-10,0.21552645758222222222e-11,0.55728651431872687605e-13,0.00000000000000000000e+00}, + A9{0.10532778218603311137e00,0.41692873614065380607e-2,0.33849549774889456984e-4,0.42064596193692630143e-6,0.66494579697622432987e-8,0.13094103581931802337e-09,0.31896187409777777778e-11,0.97271974184476560742e-13,0.00000000000000000000e+00}, + A9{0.11380523107427108222e00,0.43099572287871821013e-2,0.36544324341565929930e-4,0.47965044028581857764e-6,0.81819034238463698796e-8,0.17934133239549647357e-09,0.50956666166186293627e-11,0.18850487318190638010e-12,0.79697813173519853340e-14}, + A9{0.12257529703447467345e00,0.44621675710026986366e-2,0.39634304721292440285e-4,0.55321553769873381819e-6,0.10343619428848520870e-7,0.26033830170470368088e-09,0.87743837749108025357e-11,0.34427092430230063401e-12,0.10205506615709843189e-13}, + A9{0.13166276955656699478e00,0.46276970481783001803e-2,0.43225026380496399310e-4,0.64799164020016902656e-6,0.13580082794704641782e-7,0.39839800853954313927e-09,0.14431142411840000000e-10,0.42193457308830027541e-12,0.00000000000000000000e+00}, + A9{0.14109647869803356475e00,0.48088424418545347758e-2,0.47474504753352150205e-4,0.77509866468724360352e-6,0.18536851570794291724e-7,0.60146623257887570439e-09,0.18533978397305276318e-10,0.41033845938901048380e-13,-0.46160680279304825485e-13}, + A9{0.15091057940548936603e00,0.50086864672004685703e-2,0.52622482832192230762e-4,0.95034664722040355212e-6,0.25614261331144718769e-7,0.80183196716888606252e-09,0.12282524750534352272e-10,-0.10531774117332273617e-11,-0.86157181395039646412e-13}, + A9{0.16114648116017010770e00,0.52314661581655369795e-2,0.59005534545908331315e-4,0.11885518333915387760e-5,0.33975801443239949256e-7,0.82111547144080388610e-09,-0.12357674017312854138e-10,-0.24355112256914479176e-11,-0.75155506863572930844e-13}, + A9{0.17185551279680451144e00,0.54829002967599420860e-2,0.67013226658738082118e-4,0.14897400671425088807e-5,0.40690283917126153701e-7,0.44060872913473778318e-09,-0.52641873433280000000e-10,-0.30940587864543343124e-11,0.00000000000000000000e+00}, + A9{0.18310194559815257381e00,0.57701559375966953174e-2,0.76948789401735193483e-4,0.18227569842290822512e-5,0.41092208344387212276e-7,-0.44009499965694442143e-09,-0.92195414685628803451e-10,-0.22657389705721753299e-11,0.10004784908106839254e-12}, + A9{0.19496527191546630345e00,0.61010853144364724856e-2,0.88812881056342004864e-4,0.21180686746360261031e-5,0.30652145555130049203e-7,-0.16841328574105890409e-08,-0.11008129460612823934e-09,-0.12180794204544515779e-12,0.15703325634590334097e-12}, + A9{0.20754006813966575720e00,0.64825787724922073908e-2,0.10209599627522311893e-3,0.22785233392557600468e-5,0.73495224449907568402e-8,-0.29442705974150112783e-08,-0.94082603434315016546e-10,0.23609990400179321267e-11,0.14141908654269023788e-12}, + A9{0.22093185554845172146e00,0.69182878150187964499e-2,0.11568723331156335712e-3,0.22060577946323627739e-5,-0.26929730679360840096e-7,-0.38176506152362058013e-08,-0.47399503861054459243e-10,0.40953700187172127264e-11,0.69157730376118511127e-13}, + A9{0.23524827304057813918e00,0.74063350762008734520e-2,0.12796333874615790348e-3,0.18327267316171054273e-5,-0.66742910737957100098e-7,-0.40204740975496797870e-08,0.14515984139495745330e-10,0.44921608954536047975e-11,-0.18583341338983776219e-13}, + A9{0.25058626331812744775e00,0.79377285151602061328e-2,0.13704268650417478346e-3,0.11427511739544695861e-5,-0.10485442447768377485e-6,-0.34850364756499369763e-08,0.72656453829502179208e-10,0.36195460197779299406e-11,-0.84882136022200714710e-13}, + A9{0.26701724900280689785e00,0.84959936119625864274e-2,0.14112359443938883232e-3,0.17800427288596909634e-6,-0.13443492107643109071e-6,-0.23512456315677680293e-08,0.11245846264695936769e-09,0.19850501334649565404e-11,-0.11284666134635050832e-12}, + A9{0.28457293586253654144e00,0.90581563892650431899e-2,0.13880520331140646738e-3,-0.97262302362522896157e-6,-0.15077100040254187366e-6,-0.88574317464577116689e-09,0.12760311125637474581e-09,0.20155151018282695055e-12,-0.10514169375181734921e-12}, + A9{0.30323425595617385705e00,0.95968346790597422934e-2,0.12931067776725883939e-3,-0.21938741702795543986e-5,-0.15202888584907373963e-6,0.61788350541116331411e-09,0.11957835742791248256e-09,-0.12598179834007710908e-11,-0.75151817129574614194e-13}, + A9{0.32292521181517384379e00,0.10082957727001199408e-1,0.11257589426154962226e-3,-0.33670890319327881129e-5,-0.13910529040004008158e-6,0.19170714373047512945e-08,0.94840222377720494290e-10,-0.21650018351795353201e-11,-0.37875211678024922689e-13}, + A9{0.34351233557911753862e00,0.10488575435572745309e-1,0.89209444197248726614e-4,-0.43893459576483345364e-5,-0.11488595830450424419e-6,0.28599494117122464806e-08,0.61537542799857777779e-10,-0.24935749227658002212e-11,0.00000000000000000000e+00}, + A9{0.36480946642143669093e00,0.10789304203431861366e-1,0.60357993745283076834e-4,-0.51855862174130669389e-5,-0.83291664087289801313e-7,0.33898011178582671546e-08,0.27082948188277716482e-10,-0.23603379397408694974e-11,0.19328087692252869842e-13}, + A9{0.38658679935694939199e00,0.10966119158288804999e-1,0.27521612041849561426e-4,-0.57132774537670953638e-5,-0.48404772799207914899e-7,0.35268354132474570493e-08,-0.32383477652514618094e-11,-0.19334202915190442501e-11,0.32333189861286460270e-13}, + A9{0.40858275583808707870e00,0.11006378016848466550e-1,-0.76396376685213286033e-5,-0.59609835484245791439e-5,-0.13834610033859313213e-7,0.33406952974861448790e-08,-0.26474915974296612559e-10,-0.13750229270354351983e-11,0.36169366979417390637e-13}, + A9{0.43051714914006682977e00,0.10904106549500816155e-1,-0.43477527256787216909e-4,-0.59429739547798343948e-5,0.17639200194091885949e-7,0.29235991689639918688e-08,-0.41718791216277812879e-10,-0.81023337739508049606e-12,0.33618915934461994428e-13}, + A9{0.45210428135559607406e00,0.10659670756384400554e-1,-0.78488639913256978087e-4,-0.56919860886214735936e-5,0.44181850467477733407e-7,0.23694306174312688151e-08,-0.49492621596685443247e-10,-0.31827275712126287222e-12,0.27494438742721623654e-13}, + A9{0.47306491195005224077e00,0.10279006119745977570e-1,-0.11140268171830478306e-3,-0.52518035247451432069e-5,0.64846898158889479518e-7,0.17603624837787337662e-08,-0.51129481592926104316e-10,0.62674584974141049511e-13,0.20055478560829935356e-13}, + A9{0.49313638965719857647e00,0.97725799114772017662e-2,-0.14122854267291533334e-3,-0.46707252568834951907e-5,0.79421347979319449524e-7,0.11603027184324708643e-08,-0.48269605844397175946e-10,0.32477251431748571219e-12,0.12831052634143527985e-13}, + A9{0.51208057433416004042e00,0.91542422354009224951e-2,-0.16726530230228647275e-3,-0.39964621752527649409e-5,0.88232252903213171454e-7,0.61343113364949928501e-09,-0.42516755603130443051e-10,0.47910437172240209262e-12,0.66784341874437478953e-14}, + A9{0.52968945458607484524e00,0.84400880445116786088e-2,-0.18908729783854258774e-3,-0.32725905467782951931e-5,0.91956190588652090659e-7,0.14593989152420122909e-09,-0.35239490687644444445e-10,0.54613829888448694898e-12,0.00000000000000000000e+00}, + A9{0.54578857454330070965e00,0.76474155195880295311e-2,-0.20651230590808213884e-3,-0.25364339140543131706e-5,0.91455367999510681979e-7,-0.23061359005297528898e-09,-0.27512928625244444444e-10,0.54895806008493285579e-12,0.00000000000000000000e+00}, + A9{0.56023851910298493910e00,0.67938321739997196804e-2,-0.21956066613331411760e-3,-0.18181127670443266395e-5,0.87650335075416845987e-7,-0.51548062050366615977e-09,-0.20068462174044444444e-10,0.50912654909758187264e-12,0.00000000000000000000e+00}, + A9{0.57293478057455721150e00,0.58965321010394044087e-2,-0.22841145229276575597e-3,-0.11404605562013443659e-5,0.81430290992322326296e-7,-0.71512447242755357629e-09,-0.13372664928000000000e-10,0.44461498336689298148e-12,0.00000000000000000000e+00}, + A9{0.58380635448407827360e00,0.49717469530842831182e-2,-0.23336001540009645365e-3,-0.51952064448608850822e-6,0.73596577815411080511e-7,-0.84020916763091566035e-09,-0.76700972702222222221e-11,0.36914462807972467044e-12,0.00000000000000000000e+00}, + A9{0.59281340237769489597e00,0.40343592069379730568e-2,-0.23477963738658326185e-3,0.34615944987790224234e-7,0.64832803248395814574e-7,-0.90329163587627007971e-09,-0.30421940400000000000e-11,0.29237386653743536669e-12,0.00000000000000000000e+00}, + A9{0.59994428743114271918e00,0.30976579788271744329e-2,-0.23308875765700082835e-3,0.51681681023846925160e-6,0.55694594264948268169e-7,-0.91719117313243464652e-09,0.53982743680000000000e-12,0.22050829296187771142e-12,0.00000000000000000000e+00}, + A9{0.60521224471819875444e00,0.21732138012345456060e-2,-0.22872428969625997456e-3,0.92588959922653404233e-6,0.46612665806531930684e-7,-0.89393722514414153351e-09,0.31718550353777777778e-11,0.15705458816080549117e-12,0.00000000000000000000e+00}, + A9{0.60865189969791123620e00,0.12708480848877451719e-2,-0.22212090111534847166e-3,0.12636236031532793467e-5,0.37904037100232937574e-7,-0.84417089968101223519e-09,0.49843180828444444445e-11,0.10355439441049048273e-12,0.00000000000000000000e+00}, + A9{0.61031580103499200191e00,0.39867436055861038223e-3,-0.21369573439579869291e-3,0.15339402129026183670e-5,0.29787479206646594442e-7,-0.77687792914228632974e-09,0.61192452741333333334e-11,0.60216691829459295780e-13,0.00000000000000000000e+00}, + A9{0.61027109047879835868e00,-0.43680904508059878254e-3,-0.20383783788303894442e-3,0.17421743090883439959e-5,0.22400425572175715576e-7,-0.69934719320045128997e-09,0.67152759655111111110e-11,0.26419960042578359995e-13,0.00000000000000000000e+00}, + A9{0.60859639489217430521e00,-0.12305921390962936873e-2,-0.19290150253894682629e-3,0.18944904654478310128e-5,0.15815530398618149110e-7,-0.61726850580964876070e-09,0.68987888999111111110e-11,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.60537899426486075181e00,-0.19790062241395705751e-2,-0.18120271393047062253e-3,0.19974264162313241405e-5,0.10055795094298172492e-7,-0.53491997919318263593e-09,0.67794550295111111110e-11,-0.17059208095741511603e-13,0.00000000000000000000e+00}, + A9{0.60071229457904110537e00,-0.26795676776166354354e-2,-0.16901799553627508781e-3,0.20575498324332621581e-5,0.51077165074461745053e-8,-0.45536079828057221858e-09,0.64488005516444444445e-11,-0.29311677573152766338e-13,0.00000000000000000000e+00}, + A9{0.59469361520112714738e00,-0.33308208190600993470e-2,-0.15658501295912405679e-3,0.20812116912895417272e-5,0.93227468760614182021e-9,-0.38066673740116080415e-09,0.59806790359111111110e-11,-0.36887077278950440597e-13,0.00000000000000000000e+00}, + A9{0.58742228631775388268e00,-0.39321858196059227251e-2,-0.14410441141450122535e-3,0.20743790018404020716e-5,-0.25261903811221913762e-8,-0.31212416519526924318e-09,0.54328422462222222221e-11,-0.40864152484979815972e-13,0.00000000000000000000e+00}, + A9{0.57899804200033018447e00,-0.44838157005618913447e-2,-0.13174245966501437965e-3,0.20425306888294362674e-5,-0.53330296023875447782e-8,-0.25041289435539821014e-09,0.48490437205333333334e-11,-0.42162206939169045177e-13,0.00000000000000000000e+00}, + A9{0.56951968796931245974e00,-0.49864649488074868952e-2,-0.11963416583477567125e-3,0.19906021780991036425e-5,-0.75580140299436494248e-8,-0.19576060961919820491e-09,0.42613011928888888890e-11,-0.41539443304115604377e-13,0.00000000000000000000e+00}, + A9{0.55908401930063918964e00,-0.54413711036826877753e-2,-0.10788661102511914628e-3,0.19229663322982839331e-5,-0.92714731195118129616e-8,-0.14807038677197394186e-09,0.36920870298666666666e-11,-0.39603726688419162617e-13,0.00000000000000000000e+00}, + A9{0.54778496152925675315e00,-0.58501497933213396670e-2,-0.96582314317855227421e-4,0.18434405235069270228e-5,-0.10541580254317078711e-7,-0.10702303407788943498e-09,0.31563175582222222222e-11,-0.36829748079110481422e-13,0.00000000000000000000e+00}, + A9{0.53571290831682823999e00,-0.62147030670760791791e-2,-0.85782497917111760790e-4,0.17553116363443470478e-5,-0.11432547349815541084e-7,-0.72157091369041330520e-10,0.26630811607111111111e-11,-0.33578660425893164084e-13,0.00000000000000000000e+00}, + A9{0.52295422962048434978e00,-0.65371404367776320720e-2,-0.75530164941473343780e-4,0.16613725797181276790e-5,-0.12003521296598910761e-7,-0.42929753689181106171e-10,0.22170894940444444444e-11,-0.30117697501065110505e-13,0.00000000000000000000e+00}, + A9{0.50959092577577886140e00,-0.68197117603118591766e-2,-0.65852936198953623307e-4,0.15639654113906716939e-5,-0.12308007991056524902e-7,-0.18761997536910939570e-10,0.18198628922666666667e-11,-0.26638355362285200932e-13,0.00000000000000000000e+00}, + A9{0.49570040481823167970e00,-0.70647509397614398066e-2,-0.56765617728962588218e-4,0.14650274449141448497e-5,-0.12393681471984051132e-7,0.92904351801168955424e-12,0.14706755960177777778e-11,-0.23272455351266325318e-13,0.00000000000000000000e+00}, + A9{0.48135536250935238066e00,-0.72746293327402359783e-2,-0.48272489495730030780e-4,0.13661377309113939689e-5,-0.12302464447599382189e-7,0.16707760028737074907e-10,0.11672928324444444444e-11,-0.20105801424709924499e-13,0.00000000000000000000e+00}, + A9{0.46662374675511439448e00,-0.74517177649528487002e-2,-0.40369318744279128718e-4,0.12685621118898535407e-5,-0.12070791463315156250e-7,0.29105507892605823871e-10,0.90653314645333333334e-12,-0.17189503312102982646e-13,0.00000000000000000000e+00}, + A9{0.45156879030168268778e00,-0.75983560650033817497e-2,-0.33045110380705139759e-4,0.11732956732035040896e-5,-0.11729986947158201869e-7,0.38611905704166441308e-10,0.68468768305777777779e-12,-0.14549134330396754575e-13,0.00000000000000000000e+00}, + A9{0.43624909769330896904e00,-0.77168291040309554679e-2,-0.26283612321339907756e-4,0.10811018836893550820e-5,-0.11306707563739851552e-7,0.45670446788529607380e-10,0.49782492549333333334e-12,-0.12191983967561779442e-13,0.00000000000000000000e+00}, + A9{0.42071877443548481181e00,-0.78093484015052730097e-2,-0.20064596897224934705e-4,0.99254806680671890766e-6,-0.10823412088884741451e-7,0.50677203326904716247e-10,0.34200547594666666666e-12,-0.10112698698356194618e-13,0.00000000000000000000e+00}, + A9{0.40502758809710844280e00,-0.78780384460872937555e-2,-0.14364940764532853112e-4,0.90803709228265217384e-6,-0.10298832847014466907e-7,0.53981671221969478551e-10,0.21342751381333333333e-12,-0.82975901848387729274e-14,0.00000000000000000000e+00}, + A9{0.38922115269731446690e00,-0.79249269708242064120e-2,-0.91595258799106970453e-5,0.82783535102217576495e-6,-0.97484311059617744437e-8,0.55889029041660225629e-10,0.10851981336888888889e-12,-0.67278553237853459757e-14,0.00000000000000000000e+00}, + A9{0.37334112915460307335e00,-0.79519385109223148791e-2,-0.44219833548840469752e-5,0.75209719038240314732e-6,-0.91848251458553190451e-8,0.56663266668051433844e-10,0.23995894257777777778e-13,-0.53819475285389344313e-14,0.00000000000000000000e+00}, + A9{0.35742543583374223085e00,-0.79608906571527956177e-2,-0.12530071050975781198e-6,0.68088605744900552505e-6,-0.86181844090844164075e-8,0.56530784203816176153e-10,-0.43120012248888888890e-13,-0.42372603392496813810e-14,0.00000000000000000000e+00}, + A9{0.34150846431979618536e00,-0.79534924968773806029e-2,0.37576885610891515813e-5,0.61419263633090524326e-6,-0.80565865409945960125e-8,0.55684175248749269411e-10,-0.95486860764444444445e-13,-0.32712946432984510595e-14,0.00000000000000000000e+00}, + A9{0.32562129649136346824e00,-0.79313448067948884309e-2,0.72539159933545300034e-5,0.55195028297415503083e-6,-0.75063365335570475258e-8,0.54281686749699595941e-10,-0.13545424295111111111e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.30979191977078391864e00,-0.78959416264207333695e-2,0.10389774377677210794e-4,0.49404804463196316464e-6,-0.69722488229411164685e-8,0.52469254655951393842e-10,-0.16507860650666666667e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.29404543811214459904e00,-0.78486728990364155356e-2,0.13190885683106990459e-4,0.44034158861387909694e-6,-0.64578942561562616481e-8,0.50354306498006928984e-10,-0.18614473550222222222e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.27840427686253660515e00,-0.77908279176252742013e-2,0.15681928798708548349e-4,0.39066226205099807573e-6,-0.59658144820660420814e-8,0.48030086420373141763e-10,-0.20018995173333333333e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.26288838011163800908e00,-0.77235993576119469018e-2,0.17886516796198660969e-4,0.34482457073472497720e-6,-0.54977066551955420066e-8,0.45572749379147269213e-10,-0.20852924954666666667e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.24751539954181029717e00,-0.76480877165290370975e-2,0.19827114835033977049e-4,0.30263228619976332110e-6,-0.50545814570120129947e-8,0.43043879374212005966e-10,-0.21228012028444444444e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.23230087411688914593e00,-0.75653060136384041587e-2,0.21524991113020016415e-4,0.26388338542539382413e-6,-0.46368974069671446622e-8,0.40492715758206515307e-10,-0.21238627815111111111e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.21725840021297341931e00,-0.74761846305979730439e-2,0.23000194404129495243e-4,0.22837400135642906796e-6,-0.42446743058417541277e-8,0.37958104071765923728e-10,-0.20963978568888888889e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.20239979200788191491e00,-0.73815761980493466516e-2,0.24271552727631854013e-4,0.19590154043390012843e-6,-0.38775884642456551753e-8,0.35470192372162901168e-10,-0.20470131678222222222e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.18773523211558098962e00,-0.72822604530339834448e-2,0.25356688567841293697e-4,0.16626710297744290016e-6,-0.35350521468015310830e-8,0.33051896213898864306e-10,-0.19811844544000000000e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.17327341258479649442e00,-0.71789490089142761950e-2,0.26272046822383820476e-4,0.13927732375657362345e-6,-0.32162794266956859603e-8,0.30720156036105652035e-10,-0.19034196304000000000e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.15902166648328672043e00,-0.70722899934245504034e-2,0.27032932310132226025e-4,0.11474573347816568279e-6,-0.29203404091754665063e-8,0.28487010262547971859e-10,-0.18174029063111111111e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.14498609036610283865e00,-0.69628725220045029273e-2,0.27653554229160596221e-4,0.92493727167393036470e-7,-0.26462055548683583849e-8,0.26360506250989943739e-10,-0.17261211260444444444e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.13117165798208050667e00,-0.68512309830281084723e-2,0.28147075431133863774e-4,0.72351212437979583441e-7,-0.23927816200314358570e-8,0.24345469651209833155e-10,-0.16319736960000000000e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.11758232561160626306e00,-0.67378491192463392927e-2,0.28525664781722907847e-4,0.54156999310046790024e-7,-0.21589405340123827823e-8,0.22444150951727334619e-10,-0.15368675584000000000e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.10422112945361673560e00,-0.66231638959845581564e-2,0.28800551216363918088e-4,0.37758983397952149613e-7,-0.19435423557038933431e-8,0.20656766125421362458e-10,-0.14422990012444444444e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.91090275493541084785e-1,-0.65075691516115160062e-2,0.28982078385527224867e-4,0.23014165807643012781e-7,-0.17454532910249875958e-8,0.18981946442680092373e-10,-0.13494234691555555556e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.78191222288771379358e-1,-0.63914190297303976434e-2,0.29079759021299682675e-4,0.97885458059415717014e-8,-0.15635596116134296819e-8,0.17417110744051331974e-10,-0.12591151763555555556e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.65524757106147402224e-1,-0.62750311956082444159e-2,0.29102328354323449795e-4,-0.20430838882727954582e-8,-0.13967781903855367270e-8,0.15958771833747057569e-10,-0.11720175765333333333e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.53091065838453612773e-1,-0.61586898417077043662e-2,0.29057796072960100710e-4,-0.12597414620517987536e-7,-0.12440642607426861943e-8,0.14602787128447932137e-10,-0.10885859114666666667e-12,0.00000000000000000000e+00,0.00000000000000000000e+00}, + A9{0.40889797115352738582e-1,-0.60426484889413678200e-2,0.28953496450191694606e-4,-0.21982952021823718400e-7,-0.11044169117553026211e-8,0.13344562332430552171e-10,-0.10091231402844444444e-12,0.00000000000000000000e+00,0.00000000000000000000e+00} + }; + + auto w_im_y100 = [](T y100, T x) //purely scalar + { + if (eve::is_nan(x)) return x; + auto t = eve::dec(2*eve::frac(y100)); + int index = ((int) y100); + if (index < 97) return eve::reverse_horner(t, coefs[index]); + else + { + // use Taylor expansion for small x (|x| <= 0.0309...) + // (2/sqrt(pi)) * (x -2/3 x^3 , 4/15 x^5 -8/105 x^7, 16/945 x^9) + auto mx2(-eve::sqr(x)); + kumi::result::generate_t<5, r_t> a{1.1283791670955125739, 0.75225277806367504925, 0.30090111122547001970 + , 0.085971746064420005629, 0.016931216931216931217}; + return x*eve::reverse_horner(mx2, a); + } + }; + + auto taylor = [mz2, z](){ + using r_t = eve::element_type_t; + kumi::result::generate_t<5, r_t> a{1.1283791670955125739, 0.37612638903183752464, 0.11283791670955125739 + , 0.026866170645131251760, 0.0052239776254421878422}; + return eve::reverse_horner(mz2, a)*z; + }; + + if constexpr(eve::scalar_value) + { + auto w_im = [w_im_y100](real_t xx){ + const r_t ispi = 0.56418958354775628694807945156; // 1 / sqrt(pi) + auto signxx = sign(xx); + xx = eve::abs(xx); + if (xx > 45) { // continued-fraction expansion is faster + if (xx > real_t(5e7)) // 1-term expansion, important to avoid overflow + return ispi / (xx*signxx); + /* 5-term expansion (rely on compiler for CSE), simplified from: + ispi / (xx-0.5/(xx-1/(xx-1.5/(xx-2/xx)))) */ + return ispi*((xx*xx) * (xx*xx-real_t(4.5)) + 2) / (xx * ((xx*xx) * (xx*xx-5) + real_t(3.75)))*signxx; + } + return w_im_y100(100/(1+xx), xx)*signxx; + }; + + if(eve::is_eqz(y)) + { + return complex(eve::erf(x), y); //call to real implementation + } + else if(eve::is_eqz(x)) + { + return complex(x, (eve::sqr(y) > real_t(720) ? eve::inf(eve::as(y))*eve::sign(y) : eve::expx2(y) * w_im(y))); + } + if (real(mz2) < -750) + { + return complex(eve::signnz(x)); // underflow + } + /* Handle positive and negative x via different formulas, + using the mirror symmetries of w, to avoid overflow/underflow + problems from multiplying exponentially large and small quantities. */ + auto signx = eve::sign(x); + auto ax = eve::abs(x); + auto smallx = ax < 8e-2; + auto smally = eve::abs(y) < 1e-2; + if (smallx && smally) return taylor(); + /* don't use complex exp function, since that will produce spurious NaN + values when multiplying w in an overflow situation. */ + auto [mRe_z2, mIm_z2] = mz2; + auto [s, c] = eve::sincos(mIm_z2); + return oneminus(eve::exp(mRe_z2)*(complex(c, s)*faddeeva(complex(-y, x)*signx)))*signx; + } + else //simd + { + auto signx = eve::signnz(x); + auto w_im = [signx, w_im_y100](real_t x){ + const real_t ispi = real_t(0.56418958354775628694807945156); // 1 / sqrt(pi) + auto greater5e7 = [ispi, signx](auto xx){ + return ispi / (xx*signx); + }; + auto greater45 = [ispi, signx](auto xx){ + auto xx2 = xx*xx; + return signx*ispi*((xx2) * (xx2-real_t(4.5)) + 2) / (xx * ((xx2) * (xx2-5) + real_t(3.75))); + }; + auto remain = [w_im_y100, signx](auto xx){ + + if constexpr(eve::scalar_value) + { + return w_im_y100(100/(1+xx), xx)*signx; + } + else + { + return eve::detail::map(w_im_y100, 100/(1+xx), xx)*signx; + } + }; + + auto ax = eve::abs(x); + auto notdone = eve::true_(eve::as(ax)); + auto r = eve::nan(eve::as(x)); + if( eve::any(notdone) ) + { + notdone = next_interval(greater5e7, notdone, ax > real_t(5e7), r, ax); + if( eve::any(notdone) ) + { + notdone = next_interval(greater45, notdone, ax > real_t(45), r, ax); + if( eve::any(notdone) ) + { + if (eve::any(notdone)) r = remain(ax); + notdone = eve::false_(eve::as(r)); + } + } + } + return r; + }; + + auto signy = eve::signnz(y); + auto no_underflow = real(mz2) >= -750; + auto nfin = eve::is_not_finite(y); //|| is_nan(z); + auto r = if_else(no_underflow || is_nan( real(mz2)) + , complex(eve::nan(eve::as(real_t(0))), eve::nan(eve::as(real_t(0)))) + , complex(signx, real_t(0))); // treat underflow and nan + auto notdone = (no_underflow && !nfin) || eve::is_eqz(y); // no underflow + r = if_else(nfin, complex(eve::nan(eve::as(y)), eve::nan(eve::as(y))), r); + r = if_else(eve::is_eqz(x) && nfin, complex(real_t(0), y), r); + auto ax = eve::abs(x); + auto xsmall = ax < 8e-2; + auto ysmall = eve::abs(y) < 1e-2; + auto nully = [](auto x, auto y){ + return complex(eve::erf(x), y); + }; + auto nullx = [signy, w_im](auto x, auto y){ + return complex(x, eve::if_else(eve::sqr(y) > real_t(720), eve::inf(eve::as(y)), eve::expx2(y) * w_im(y)))*signy; + }; + + auto smallxy = [taylor](){ + return taylor(); + }; + + auto remain = [mz2, signx](auto x, auto y){ + auto [mRe_z2, mIm_z2] = mz2; + auto [s, c] = eve::sincos(mIm_z2); + auto zz = oneminus(eve::exp(mRe_z2)*(complex(c, s)*faddeeva(complex(-y, x)*signx)))*signx; + return zz; + }; + + if( eve::any(notdone) ) + { + notdone = next_interval(nully, notdone, eve::is_eqz(y), r, x, y); + if( eve::any(notdone) ) + { + notdone = next_interval(nullx, notdone, eve::is_eqz(x), r, x, y); + if( eve::any(notdone) ) + { + notdone = next_interval(smallxy, notdone, xsmall && ysmall, r); + if( eve::any(notdone) ) + { + notdone = last_interval(remain, notdone, r, x, y); + } + } + } + } + return r; + } + } +} diff --git a/include/kyosu/types/impl/complex/faddeeva.hpp b/include/kyosu/types/impl/complex/faddeeva.hpp new file mode 100644 index 00000000..15a0a6b0 --- /dev/null +++ b/include/kyosu/types/impl/complex/faddeeva.hpp @@ -0,0 +1,115 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once +#include +#include + +namespace kyosu::_ +{ + template + auto dispatch(eve::tag_of, Z z) noexcept + { + using v_t = as_real_t; + using real_t = eve::element_type_t; + auto const sqrtpi = eve::sqrt_pi(eve::as()); + auto const iosqrtpi = complex(real_t(0), eve::rec(sqrtpi)); + + auto fexp = [iosqrtpi, sqrtpi](auto z){//Fourier expansion approximation + + constexpr real_t tauM = 12; + constexpr real_t tauM2= 144; + constexpr size_t maxN = 23; + constexpr std::array aN = { //Fourier coefficients + 2.758402332921771e-01, 2.245739552246158e-01, 1.594149382739117e-01, 9.866576641545419e-02, 5.324414078763941e-02 + , 2.505215000539365e-02, 1.027746567053954e-02, 3.676164332844847e-03, 1.146493641242233e-03, 3.117570150461976e-04 + , 7.391433429603010e-05, 1.527949342800837e-05, 2.753956608221073e-06, 4.327858781901246e-07, 5.930030408745884e-08 + , 7.084490307748205e-09, 7.379520635816785e-10, 6.702171606002010e-11, 5.307265163470805e-12, 3.664324113467642e-13 + , 2.205894944941035e-14, 1.157826862628556e-15, 5.298711429467307e-17}; + auto z1 = exp_i(tauM*z); + auto z2 = tauM2*sqr(z); + auto FE = sqrtpi/tauM*oneminus(z1)/z2; + for (size_t n = 1; n <= maxN; ++n) + FE += (aN[n-1]*dec(eve::sign_alternate(real_t(n))*z1)/(sqr(n*eve::pi(eve::as(tauM))) - z2)); + return iosqrtpi*tauM2*z*FE; + }; + + auto contfr = [iosqrtpi](auto z){ // the Laplace continued fraction approximation + constexpr std::array bN = {5.5000, 5.0000, 4.5000, 4.0000, 3.5000, + 3.0000, 2.5000, 2.0000, 1.5000, 1.0000, 0.5000}; + auto CF = bN[0]/z; + for (int k = 1; k <= 10; ++k) CF = bN[k]*rec(z - CF); + return iosqrtpi*rec(z - CF); + }; + + auto small_z= [sqrtpi](auto z){ + auto zP2=sqr(z); + auto zP4=sqr(zP2); + auto zP6=zP2*zP4; + + return (((6 - 6*zP2 + 3*zP4 - zP6)*(15*sqrtpi + complex(real_t(0), real_t(1))*z*(30 + 10*zP2 + 3*zP4)))/(90*sqrtpi)); + }; + + auto narr_band = [sqrtpi](auto z, auto aN, auto tauM){ // the narrow band + real_t tauM2 = sqr(tauM); + constexpr size_t maxN = 23; + auto z1 = cos(tauM*z); + auto z2 = tauM2*sqr(z); + Z NB{}; + for (size_t n = 1; n <= maxN; ++n) NB += (aN[n-1]*dec(eve::sign_alternate(real_t(n))*z1)/(sqr(n*eve::pi(eve::as(tauM))) - z2)); + return exp(-sqr(z)) - complex(real_t(0), real_t(1))*(dec(z1)/(tauM*z) - tauM2*z/sqrtpi*NB); + }; + + + auto smallim = [narr_band, small_z](auto z){ // approximation at small imag(z) + constexpr size_t maxN = 23; + constexpr std::array aN12 = { //Fourier coefficients + 2.758402332921771e-01, 2.245739552246158e-01, 1.594149382739117e-01, 9.866576641545419e-02, 5.324414078763941e-02 + , 2.505215000539365e-02, 1.027746567053954e-02, 3.676164332844847e-03, 1.146493641242233e-03, 3.117570150461976e-04 + , 7.391433429603010e-05, 1.527949342800837e-05, 2.753956608221073e-06, 4.327858781901246e-07, 5.930030408745884e-08 + , 7.084490307748205e-09, 7.379520635816785e-10, 6.702171606002010e-11, 5.307265163470805e-12, 3.664324113467642e-13 + , 2.205894944941035e-14, 1.157826862628556e-15, 5.298711429467307e-17}; + constexpr std::array aN12_1 = { //Fourier coefficients avoiding poles + 2.738693653257005e-01, 2.237253191645656e-01, 1.597109174949294e-01, 9.963269094255395e-02, 5.431463971403691e-02 + , 2.587496275171680e-02, 1.077185133049561e-02, 3.918760804860615e-03, 1.245818993506881e-03, 3.461058398397597e-04 + , 8.402542038611651e-05, 1.782626047239582e-05, 3.304894416742214e-06, 5.354300211460283e-07, 7.580461285556943e-08 + , 9.378563805151443e-09, 1.013969351293613e-09, 9.579902872635222e-11, 7.909429715194891e-12, 5.706594634502440e-13 + , 3.597962756907448e-14, 1.982367142666383e-15, 9.544634564831883e-17 }; + + auto x = real(z); + auto ind_0 = abs(x)<5e-3; + auto ind_poles = eve::false_(eve::as(x)); + for(int k = 1; k <= 23; ++k) ind_poles = ind_poles || (abs(x - k*eve::pi(eve::as(x))/12)<1e-4); + return if_else(!ind_0, if_else(ind_poles + , narr_band(z, aN12_1, real_t(12.1)) + , narr_band(z, aN12, real_t(12)) + ) + , small_z(z)); + }; + + auto indneg = eve::is_ltz(imag(z)); + z = if_else(indneg, conj(z), z); + auto r = complex(eve::nan(eve::as(real(z))), eve::nan(eve::as(real(z)))); // nan case treated here + r = if_else(eve::is_infinite(real(z)), Z{}, r); + auto notdone = is_finite(z); + if (eve::any(notdone)) + { + auto indin = sqr_abs(z) <= real_t(64); + auto indband = indin && (imag(z) < real_t(5.0e-3)); + notdone = next_interval(smallim, notdone, indband, r, z); + if( eve::any(notdone) ) + { + notdone = next_interval(fexp, notdone, indin, r, z); + if( eve::any(notdone) ) + { + notdone = next_interval(contfr, notdone, notdone, r, z); + } + } + } + return if_else(indneg, conj(r), r); ; + } +} diff --git a/include/kyosu/types/impl/complex/invtrig.hpp b/include/kyosu/types/impl/complex/invtrig.hpp index 10d88a22..5cee77b9 100644 --- a/include/kyosu/types/impl/complex/invtrig.hpp +++ b/include/kyosu/types/impl/complex/invtrig.hpp @@ -154,7 +154,7 @@ namespace kyosu::_ // restore signs r = eve::if_else(ltzra0, -r, r); i = eve::if_else(ltzia0, -i, i); - return to_complex(r, i); + return complex(r, i); } template @@ -297,7 +297,7 @@ namespace kyosu::_ // restore signs r = eve::if_else(ltzra0, eve::pi(eve::as(x))-r, r); i = eve::if_else(gtzia0, -i, i); - return to_complex(r, i); + return complex(r, i); } template @@ -309,12 +309,12 @@ namespace kyosu::_ // we have compatibility with C99. auto [r, i] = kyosu::acos(a0); auto lez = eve::is_negative(i);; - auto res = to_complex(-i, r); + auto res = complex(-i, r); res = eve::if_else(lez, res, -res); auto nani = is_nan(i); if (eve::any(nani)) return eve::if_else(nani && eve::is_finite(r) - , to_complex(eve::nan(eve::as(r)), eve::nan(eve::as(r))) + , complex(eve::nan(eve::as(r)), eve::nan(eve::as(r))) , res); else return res; @@ -325,8 +325,8 @@ namespace kyosu::_ auto dispatch(eve::tag_of const&, C const& a0) noexcept { auto [r, i] = a0; - auto [r1, i1] = kyosu::asin(to_complex(-i, r)); - return to_complex(i1, -r1); // -(eve::i*asin(eve::i*z)); + auto [r1, i1] = kyosu::asin(complex(-i, r)); + return complex(i1, -r1); // -(eve::i*asin(eve::i*z)); } template @@ -361,7 +361,7 @@ namespace kyosu::_ auto special = eve::is_eqz(y) && (x < eve::one(eve::as(a0r))); auto sr = eve::atanh(a0r); if (eve::all(special)) { - return to_complex(sr, eve::zero(eve::as(sr))); + return complex(sr, eve::zero(eve::as(sr))); } rtype r = eve::zero(eve::as(a0r)); @@ -482,7 +482,7 @@ namespace kyosu::_ i = eve::if_else(realinf, -eve::sign(a0r)*eve::pio_2(eve::as(a0r)), i); r = eve::if_else(special, sr, r); i = eve::if_else(special, eve::zero, i); - return to_complex(r, i); + return complex(r, i); } template @@ -492,8 +492,8 @@ namespace kyosu::_ // C99 definition here; atan(z) = -i atanh(iz): auto [r, i] = a0; - auto [r1, i1] = kyosu::atanh(to_complex(-i, r)); - return to_complex(i1, -r1); + auto [r1, i1] = kyosu::atanh(complex(-i, r)); + return complex(i1, -r1); } template diff --git a/include/kyosu/types/impl/complex/special.hpp b/include/kyosu/types/impl/complex/special.hpp new file mode 100644 index 00000000..bc86fc8e --- /dev/null +++ b/include/kyosu/types/impl/complex/special.hpp @@ -0,0 +1,423 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#pragma once +#include +#include + +namespace kyosu::_ +{ + //===------------------------------------------------------------------------------------------- + // Unary functions : tgamma + //===------------------------------------------------------------------------------------------- + template + auto dispatch(eve::tag_of, Z const& a0) noexcept + { + // 15 sig. digits for 0<=real(z)<=171 + // coeffs should sum to about g*g/2+23/24 + // + using r_t = eve::element_type_t>; + auto g=r_t(607)/r_t(128); + // best results when 4<=g<=5 + constexpr int N = 15; + std::array c = + { 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + .33994649984811888699e-4, + .46523628927048575665e-4, + -.98374475304879564677e-4, + .15808870322491248884e-3, + -.21026444172410488319e-3, + .21743961811521264320e-3, + -.16431810653676389022e-3, + .84418223983852743293e-4, + -.26190838401581408670e-4, + .36899182659531622704e-5 + }; + + //Num Recipes used g=5 with 7 terms + //for a less effective approximation + + auto negra0 = eve::is_negative(real(a0)); + auto z = if_else(negra0, -a0, a0); + z = dec(z); + auto zh = z+eve::half(eve::as()); + auto zgh=zh+g; + //trick for avoiding FP overflow above z=141 + auto zp=pow(zgh,(zh*eve::half(eve::as()))); + auto ss = Z{}; + for(int pp = N-1; pp >= 1; --pp){ + ss+= c[pp]/(z+pp); + } + auto sq2pi = r_t(2.5066282746310005024157652848110); + auto f=(sq2pi*(c[0]+ss))*((zp*exp(-zgh))*zp); + auto o = eve::one(eve::as()); + f = if_else(is_eqz(z) || z == o, o, f); + //adjust for negative real parts + auto reala0 = is_real(a0); + if(eve::any(negra0)) + { + f = if_else(negra0, rec(-eve::inv_pi(eve::as(real(a0)))*a0*f*sinpi(a0)), eve::zero); + f = if_else (negra0 && reala0 && eve::is_flint(real(a0)), complex(eve::nan(eve::as(sq2pi)), eve::inf(eve::as(sq2pi))), f); + } + f = if_else (reala0, complex(eve::tgamma(real(a0))), f); + f = if_else (eve::is_nan(real(f)), complex(eve::nan(eve::as(sq2pi)), eve::inf(eve::as(sq2pi))), f); + f = if_else (is_eqz(a0), complex(eve::inf(eve::as(g))*eve::pedantic(eve::signnz)(real(a0))), f); + return f; + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : log_gamma + //===------------------------------------------------------------------------------------------- + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& a0) noexcept + { + return log_abs(tgamma(a0)); + } + + template + auto dispatch(eve::tag_of, Z const& a0) noexcept + { + // 15 sig. digits for 0<=real(z)<=171 + // coeffs should sum to about g*g/2+23/24 + // + using r_t = eve::element_type_t>; + auto g=r_t(607)/r_t(128); + // best results when 4<=g<=5 + constexpr int N = 15; + std::array c = + { 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + .33994649984811888699e-4, + .46523628927048575665e-4, + -.98374475304879564677e-4, + .15808870322491248884e-3, + -.21026444172410488319e-3, + .21743961811521264320e-3, + -.16431810653676389022e-3, + .84418223983852743293e-4, + -.26190838401581408670e-4, + .36899182659531622704e-5 + }; + + //Num Recipes used g=5 with 7 terms + //for a less effective approximation + + auto negra0 = eve::is_negative(real(a0)); + auto z = if_else(negra0, -a0, a0); + Z ss{}; + for(int pp = N-1; pp >= 1; --pp){ + ss += c[pp]*rec(z+dec(pp)); + } + auto zg = z+g-eve::half(eve::as(g)); + auto lsq2pi = r_t(0.9189385332046727417803297); + auto f=(lsq2pi + log(c[0]+ss)) - zg + (z-eve::half(eve::as()))*log(zg); + auto zer = eve::zero(eve::as(g)); + auto o = eve::one(eve::as(g)); + auto t = o+o; + f = if_else(z == t|| z == o, zer, f); + //adjust for negative real parts + if(eve::any(negra0)) + { + auto lpi = r_t(1.14472988584940017414342735); + auto reala0 = is_real(a0); + f = kyosu::if_else(negra0, lpi-log(a0*sinpi(-a0))-f, f); + f = kyosu::if_else (negra0 && reala0 && eve::is_flint(real(a0)) + , complex(eve::nan(eve::as(g)), eve::inf(eve::as(g))) + , f); + } + return f; + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : digamma + //===------------------------------------------------------------------------------------------- + template + auto dispatch(eve::tag_of, Z const& a0) noexcept + { + // 15 sig. digits for 0<=real(z)<=171 + // coeffs should sum to about g*g/2+23/24 + // + using r_t = eve::element_type_t>; + auto g=r_t(607)/r_t(128); + // best results when 4<=g<=5 + constexpr int N = 15; + std::array c = + { 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + .33994649984811888699e-4, + .46523628927048575665e-4, + -.98374475304879564677e-4, + .15808870322491248884e-3, + -.21026444172410488319e-3, + .21743961811521264320e-3, + -.16431810653676389022e-3, + .84418223983852743293e-4, + -.26190838401581408670e-4, + .36899182659531622704e-5 + }; + + //Num Recipes used g=5 with 7 terms + //for a less effective approximation + + auto reflection = real(a0) < eve::half(eve::as(real(a0))); + auto z = if_else(reflection, oneminus(a0), a0); + + Z d{}; + auto n = d; + for(int pp = N-1; pp >= 1; --pp){ + auto dz = rec(z+dec(pp)); + auto dd = c[pp]*dz; + d += dd; + n -= dd*dz; + } + d+= c[0]; + auto zg = z+g-eve::half(eve::as(g)); + auto f = log(zg) + (n/d - g/zg); + + if(eve::any(reflection)) + { + f = if_else(reflection, f-eve::pi(eve::as(g))*cotpi(a0), f); + f = if_else (reflection && is_real(a0) && eve::is_flint(real(a0)) + , complex(eve::nan(eve::as(g)), eve::inf(eve::as(g))), f); + } + return f; + } + + //===------------------------------------------------------------------------------------------- + // Binary functions : rising_factorial, lrising_factorial, lbeta, beta + //===------------------------------------------------------------------------------------------- + // WAITING FOR DECORATORS + template + auto dispatch(eve::tag_of + , Z1 const& a0, Z2 const& a1) noexcept + requires (kyosu::concepts::complex || kyosu::concepts::complex) + { + using r_t = as_cayley_dickson_t; + return kyosu::if_else(is_eqz(a1), r_t(1), tgamma(a0+a1)/tgamma(a0)); //pedantic(div)(tgamma(a0+a1),tgamma(a0))); + } + + template + auto dispatch(eve::tag_of + , Z1 const& a0, Z2 const& a1) noexcept + requires (kyosu::concepts::complex || kyosu::concepts::complex) + { + using r_t = as_cayley_dickson_t; + return kyosu::if_else(is_eqz(a1), r_t{}, log(tgamma(a0+a1)/tgamma(a0))); //pedantic(divide)(tgamma(a0+a1),tgamma(a0)))); + } + + template + auto dispatch(eve::tag_of, Z1 const& a0, Z2 const& a1) noexcept + requires (kyosu::concepts::complex || kyosu::concepts::complex) + { + return log(beta(a0, a1)); + } + + template + auto dispatch(eve::tag_of, Z1 const& a0, Z2 const& a1) noexcept + requires (kyosu::concepts::complex || kyosu::concepts::complex) + { + auto y = a0 + a1; + return tgamma(a0)*tgamma(a1)/tgamma(y); + } + + template + auto dispatch(eve::tag_of + , K const & kk + , Z z) noexcept + { + // 15 sig. digits for 0<=real(z)<=171 + // coeffs should sum to about g*g/2+23/24 + // + using v_t = kyosu::as_real_t; + using real_t = eve::element_type_t; + auto k = real_t(kk); + auto [rz, iz] = z; + auto iszero = is_eqz(z); + auto isreal = eve::is_eqz(iz); + auto isneg = eve::is_ltz(rz); + auto isnegreal = isreal && isneg; + auto isodd = isnegreal && eve::is_odd(rz); + auto iseven = isnegreal && eve::is_even(rz); + + auto r=eve::half(eve::as(rz)); // reflection point + auto reflect = rz < r; + z = if_else(reflect, oneminus(z), z); + + std::array cm = { + .27105054312137610850e-19 + -.17889335846010823161e-17, + .58167446553847312884e-16, + -.12421162189080181548e-14, + .19593322190397666205e-13, + -.24347803504257137241e-12, + .24823251635643084345e-11, + -.21352608103961806529e-10, + .15816215942184366772e-9, + -.10246226511017621219e-8, + .58768014045093054654e-8, + -.30137695171547022183e-7, + .13931171712321674741e-6, + -.58440580661848562719e-6, + .22376124247437700378e-5, + -.78585149263697370338e-5, + .25423835243950883896e-4, + -.76053287924037718971e-4, + .21106516173760261250e-3, + -.54504190222378945440e-3, + .13131884053420191908e-2, + -.29592166263096543401e-2, + .62512730682449246388e-2, + -.12405987285776082154e-1, + .23176737166455607805e-1, + -.40840766970770029873e-1, + .68016197438946063823e-1, + -.10726959700408922397, + .16054206784249779846, + -.22851039270529494523, + .31007238254065152134, + -.40215850009669926857, + .50000000000000000000, + -.59784149990330073143, + .68992761745934847866, + -.77148960729470505477, + .83945793215750220154, + -.89273040299591077603, + .93198380256105393618, + -.95915923302922997013, + .97682326283354439220, + -.98759401271422391785, + .99374872693175507536, + -.99704078337369034566, + .99868681159465798081, + -.99945495809777621055, + .99978893483826239739, + -.99992394671207596228, + .99997457616475604912, + -.99999214148507363026, + .99999776238757525623, + -.99999941559419338151, + .99999986068828287678, + -.99999996986230482845, + .99999999412319859549, + -.99999999897537734890, + .99999999984183784058, + -.99999999997864739190, + .99999999999751767484, + -.99999999999975652196, + .99999999999998040668, + -.99999999999999875788, + .99999999999999994183, + -.99999999999999999821, + .99999999999999999997 + }; + + Z f{}; + auto j = inc(63*k); + for(size_t i=0; i < cm.size(); ++i, j -= k) + { + f += cm[i]*pow(j, -z); + } + if (eve::none(reflect)) return f; + auto reflection = [&](auto f){ + if (k == 1) + { + auto u = dec(exp2(z)); + auto t = -2*u/dec(u)/pow(eve::pi(eve::as(real(z))), z);; + auto g = t*cospi(eve::half(eve::as(real(z)))*z)*tgamma(z)*f; + g = if_else(iszero, complex(eve::half(eve::as(real(f)))), g); + return if_else(iseven, complex(eve::zero(eve::as(real(f)))), g); + } + else if (k == 2){ + auto g= pow(eve::two_o_pi(eve::as(real(f))), z)*sinpi(z)*tgamma(z)*f; + return if_else(isodd, eve::zero(eve::as(real(f))), g); + } + else + { + return complex(eve::allbits(eve::as(real(f)))); + } + }; + return if_else(reflect, reflection(f), f); + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : eta + //===------------------------------------------------------------------------------------------- + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept + { + return deta(1u, z); + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : zeta + //===------------------------------------------------------------------------------------------- + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept + { + auto zz=exp2(z); + auto k = zz/(zz-2); + auto g = if_else(z == Z(1), complex(eve::nan(eve::as(real(z)))), k*eta(z)); + return if_else(real(z) == eve::inf(eve::as(real(z))), complex(eve::one(eve::as(real(z)))), g); + } + + //===------------------------------------------------------------------------------------------- + // Unary functions : lambda + //===------------------------------------------------------------------------------------------- + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept + { + auto zz=exp2(z); + auto k = (z-1)/(z-2); + auto r = if_else(z == complex(eve::one(eve::as(real(z)))), complex(eve::inf(eve::as(real(z)))), k*deta(1u, zz)); + imag(r) = eve::if_else(is_real(z), eve::zero, imag(r)); + return r; + } +} + +#include +#include + +namespace kyosu::_ +{ + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept + { + auto realz = is_real(z); + if (eve::all(realz)) + return complex(eve::erfcx(real(z))); + else if (eve::none(realz)) + return faddeeva(complex(-imag(z), real(z))); + else + return if_else(realz, complex(eve::erfcx(real(z))), faddeeva(complex(-imag(z), real(z)))); + } + + template + EVE_FORCEINLINE auto dispatch(eve::tag_of, Z const& z) noexcept + { + auto realz = is_real(z); + if (eve::all(realz)) + { + return kyosu::erfi(real(z)); + } + else + { + auto [rz, iz] = z; + auto tmp = erf(complex(-iz, rz)); + return complex(imag(tmp), -real(tmp)); + } + } +} diff --git a/include/kyosu/types/impl/math.hpp b/include/kyosu/types/impl/math.hpp index 6673e4e7..5008582d 100644 --- a/include/kyosu/types/impl/math.hpp +++ b/include/kyosu/types/impl/math.hpp @@ -24,8 +24,8 @@ namespace kyosu::_ auto [s, c] = eve::sincos(iz); auto rho = eve::if_else(is_nan(rz), eve::allbits, eve::exp(rz)); auto res = eve::if_else(is_real(z) || rz == eve::minf(eve::as(rz)), - to_complex(rho, eve::zero(eve::as(rho))), - to_complex(rho*c, rho*s)); + complex(rho, eve::zero(eve::as(rho))), + complex(rho*c, rho*s)); return if_else(rz == eve::inf(eve::as(rz)) && eve::is_not_finite(iz), C{rz, eve::nan(eve::as(iz))}, res); } else @@ -57,7 +57,7 @@ namespace kyosu::_ auto r = eve::fma(expm1(rz), ciz, cosm1(iz)); auto i = eve::exp(rz)*siz; r = eve::if_else(rz == eve::inf(eve::as(rz)) && eve::is_not_finite(iz), rz, r); - return to_complex(r, eve::if_else(kyosu::is_real(z), eve::zero, i)); + return complex(r, eve::if_else(kyosu::is_real(z), eve::zero, i)); } else { @@ -116,14 +116,14 @@ namespace kyosu::_ auto [s, c] = eve::sinpicospi(iz); auto rho = eve::exp(rz*eve::pi(eve::as(rz))); return eve::if_else(kyosu::is_real(z) || rz == eve::minf(eve::as(rz)), - kyosu::to_complex(rho, eve::zero(eve::as(rho))), - kyosu::to_complex(rho*c, rho*s) + kyosu::complex(rho, eve::zero(eve::as(rho))), + kyosu::complex(rho*c, rho*s) ); } else { using u_t = eve::underlying_type_t; - const auto ipi = to_complex(u_t(0), eve::pi(eve::as())); + const auto ipi = complex(u_t(0), eve::pi(eve::as())); return kyosu::exp(ipi*z); } } @@ -149,10 +149,10 @@ namespace kyosu::_ auto argz = arg(z); auto absz = eve::if_else(eve::is_nan(rz) && eve::is_infinite(iz), infty, kyosu::abs(z)); auto la = eve::log(absz); - auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), to_complex(la, eve::zero(eve::as(rz))), to_complex(la, argz)); + auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), complex(la, eve::zero(eve::as(rz))), complex(la, argz)); if(eve::any(kyosu::is_not_finite(z))) { - r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), to_complex(infty, iz), r); + r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), complex(infty, iz), r); } return r; } @@ -187,10 +187,10 @@ namespace kyosu::_ auto argz = arg(z)*eve::invlog_10(eve::as(rz)); auto absz = eve::if_else(eve::is_nan(rz) && eve::is_infinite(iz), infty, kyosu::abs(z)); auto la = eve::log10(absz); - auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), to_complex(la, eve::zero(eve::as(rz))), to_complex(la, argz)); + auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), complex(la, eve::zero(eve::as(rz))), complex(la, argz)); if(eve::any(kyosu::is_not_finite(z))) { - r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), to_complex(infty, iz), r); + r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), complex(infty, iz), r); } return r; } @@ -214,10 +214,10 @@ namespace kyosu::_ auto argz = arg(z)*eve::invlog_2(eve::as(rz)); auto absz = eve::if_else(eve::is_nan(rz) && eve::is_infinite(iz), infty, kyosu::abs(z)); auto la = eve::log2(absz); - auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), to_complex(la, eve::zero(eve::as(rz))), to_complex(la, argz)); + auto r = kyosu::if_else(kyosu::is_real(z) && eve::is_positive(rz), complex(la, eve::zero(eve::as(rz))), complex(la, argz)); if(eve::any(kyosu::is_not_finite(z))) { - r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), to_complex(infty, iz), r); + r = kyosu::if_else(eve::is_infinite(rz) && eve::is_nan(iz), complex(infty, iz), r); } return r; } @@ -241,7 +241,7 @@ namespace kyosu::_ auto theta = eve::if_else((kyosu::is_real(m) && eve::is_nltz(kyosu::real(m))), eve::zero, arg(m)) ; auto rz = kyosu::real(z); auto iz2 = eve::sqr(kyosu::imag(z)); - return to_complex(eve::half(eve::as())*eve::log1p(rz*(rz+e_t(2))+iz2), theta); + return complex(eve::half(eve::as())*eve::log1p(rz*(rz+e_t(2))+iz2), theta); } else { @@ -289,24 +289,24 @@ namespace kyosu::_ auto rr1 = eve::if_else(is_real_z, sqrtx, w); auto ii1 = eve::if_else(is_real_z, eve::zero, iaz*eve::half(eve::as(r))/w); res = kyosu::if_else(gezrz - , to_complex(rr1, ii1) - , to_complex(ii1, rr1) + , complex(rr1, ii1) + , complex(ii1, rr1) ); if (eve::any(is_not_finite(z))) [[unlikely]] { res = kyosu::if_else(rz == eve::minf(eve::as(rz)) - , kyosu::if_else( eve::is_nan(iz), to_complex(iz, eve::minf(eve::as(rz))) - , to_complex(eve::zero(eve::as(rz)), eve::inf(eve::as(rz)))) + , kyosu::if_else( eve::is_nan(iz), complex(iz, eve::minf(eve::as(rz))) + , complex(eve::zero(eve::as(rz)), eve::inf(eve::as(rz)))) , res ); res = kyosu::if_else(rz == eve::inf(eve::as(rz)) - , if_else( eve::is_nan(iz), to_complex(eve::inf(eve::as(rz)), iz) - , to_complex( eve::inf(eve::as(rz)), eve::zero(eve::as(rz)) )) + , if_else( eve::is_nan(iz), complex(eve::inf(eve::as(rz)), iz) + , complex( eve::inf(eve::as(rz)), eve::zero(eve::as(rz)) )) , res ); - res = kyosu::if_else(eve::is_nan(rz), to_complex(rz, rz), res); + res = kyosu::if_else(eve::is_nan(rz), complex(rz, rz), res); auto infty = eve::inf(eve::as(iaz)); - res = kyosu::if_else(iaz == infty, to_complex(infty, infty), res); + res = kyosu::if_else(iaz == infty, complex(infty, infty), res); } return if_else(negimag, kyosu::conj(res), res); } @@ -363,13 +363,10 @@ namespace kyosu::_ C1 expo = c1; auto const o = eve::one(eve::as()); r_t result(o); - std::cout << "result " << result << std::endl; while(true) { if (eve::all(eve::is_eqz(expo))) break; - std::cout << "expo " << expo << " base " << base << "result " << result << std::endl; result = kyosu::if_else(eve::is_odd(expo), result*base, o); - std::cout << "expo " << expo << " base " << base << "result " << result << std::endl; expo = (expo >> 1); base = kyosu::sqr(base); } @@ -424,7 +421,7 @@ namespace kyosu::_ auto realc0 = is_real(c0); if(eve::any(realc0)) { - auto rr = to_complex(kyosu::pow(real(c0), c1)); + auto rr = complex(kyosu::pow(real(c0), c1)); r = kyosu::if_else(realc0, rr, r); } } diff --git a/include/kyosu/types/impl/predicates.hpp b/include/kyosu/types/impl/predicates.hpp index f339e682..d2209f97 100644 --- a/include/kyosu/types/impl/predicates.hpp +++ b/include/kyosu/types/impl/predicates.hpp @@ -74,7 +74,7 @@ namespace kyosu::_ KYOSU_FORCEINLINE constexpr auto dispatch(eve::tag_of const&, C const& c) noexcept { - return kumi::any_of(c, [](auto const& e) { return eve::is_finite(e); }); + return kumi::all_of(c, [](auto const& e) { return eve::is_finite(e); }); } template diff --git a/include/kyosu/types/impl/quaternion/specific.hpp b/include/kyosu/types/impl/quaternion/specific.hpp index 01a9ee32..7b1f8a48 100644 --- a/include/kyosu/types/impl/quaternion/specific.hpp +++ b/include/kyosu/types/impl/quaternion/specific.hpp @@ -24,7 +24,7 @@ namespace kyosu::_ requires(II != JJ && JJ != KK) { using e_t = std::remove_reference_t; - auto q = to_quaternion(q0); + auto q = quaternion(q0); std::array aq{get<0>(q), get<1>(q), get<2>(q), get<3>(q)}; EVE_ASSERT(eve::all(is_nez(q)), "some quaternion are null"); constexpr bool is_proper = II == KK; //Proper Euler angles else Tait-Bryan @@ -188,7 +188,7 @@ namespace kyosu::_ auto dispatch(eve::tag_of const& , Z const& q) noexcept { - auto c0 = to_complex(get<0>(q), get<1>(q)); + auto c0 = complex(get<0>(q), get<1>(q)); if constexpr(kyosu::concepts::complex) { auto z = eve::zero(eve::as(abs(c0))); @@ -196,7 +196,7 @@ namespace kyosu::_ } else { - auto c1 = to_complex(get<2>(q), get<3>(q)); + auto c1 = complex(get<2>(q), get<3>(q)); return kumi::tuple{abs(c0), arg(c0), abs(c1), arg(c1)}; } } @@ -206,7 +206,7 @@ namespace kyosu::_ auto dispatch(eve::tag_of const& , Z const& q) noexcept { - auto c0 = to_complex(get<0>(q), get<1>(q)); + auto c0 = complex(get<0>(q), get<1>(q)); if constexpr(kyosu::concepts::complex) { auto z = eve::zero(eve::as(abs(c0))); @@ -223,7 +223,7 @@ namespace kyosu::_ auto dispatch(eve::tag_of const& , Z const& q) noexcept { - auto c0 = to_complex(get<0>(q), get<1>(q)); + auto c0 = complex(get<0>(q), get<1>(q)); if constexpr(kyosu::concepts::complex) { auto z = eve::zero(eve::as(abs(c0))); @@ -232,8 +232,8 @@ namespace kyosu::_ else { auto rho = kyosu::abs(q); - auto c0 = to_complex(get<0>(q), get<1>(q)); - auto c1 = to_complex(get<2>(q), get<3>(q)); + auto c0 = complex(get<0>(q), get<1>(q)); + auto c1 = complex(get<2>(q), get<3>(q)); auto alpha = eve::pedantic(eve::atan2)(abs(c1), abs(c0)); auto theta1 = arg(c0); auto theta2 = arg(c1); @@ -248,7 +248,7 @@ namespace kyosu::_ { if constexpr(kyosu::concepts::complex) { - auto c0 = to_complex(get<0>(q), get<1>(q)); + auto c0 = complex(get<0>(q), get<1>(q)); auto z = eve::zero(eve::as(abs(c0))); return kumi::tuple{abs(c0), arg(c0), z, z}; } diff --git a/include/kyosu/types/impl/reals.hpp b/include/kyosu/types/impl/reals.hpp index bf2db879..a068150c 100644 --- a/include/kyosu/types/impl/reals.hpp +++ b/include/kyosu/types/impl/reals.hpp @@ -10,48 +10,48 @@ namespace kyosu::_ { template - constexpr auto to_complex_(EVE_EXPECTS(eve::cpu_), T r) noexcept { return as_cayley_dickson_n_t<2,T>(r, 0); } + constexpr auto complex_(EVE_EXPECTS(eve::cpu_), T r) noexcept { return as_cayley_dickson_n_t<2,T>(r, 0); } template - constexpr auto to_complex_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i) noexcept -> as_cayley_dickson_n_t<2,decltype(eve::add(r, i))> + constexpr auto complex_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i) noexcept -> as_cayley_dickson_n_t<2,decltype(eve::add(r, i))> { return as_cayley_dickson_n_t<2, decltype(eve::add(r, i))>{r, i}; } template - constexpr auto to_complex_(EVE_EXPECTS(eve::cpu_), T const& v) noexcept { return v; } + constexpr auto complex_(EVE_EXPECTS(eve::cpu_), T const& v) noexcept { return v; } //========================================================================================================================= template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T r) noexcept { return as_cayley_dickson_n_t<4,T>(r, 0, 0, 0); } + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T r) noexcept { return as_cayley_dickson_n_t<4,T>(r, 0, 0, 0); } template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i) noexcept -> as_cayley_dickson_n_t<4, decltype(eve::add(r, i))> + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i) noexcept -> as_cayley_dickson_n_t<4, decltype(eve::add(r, i))> { return as_cayley_dickson_n_t<4, decltype(eve::add(r, i))>{r, i, 0, 0}; } template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i, T2 j, T3 k) noexcept -> as_cayley_dickson_n_t<4, decltype(eve::add(r, i, j, k))> + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T0 r, T1 i, T2 j, T3 k) noexcept -> as_cayley_dickson_n_t<4, decltype(eve::add(r, i, j, k))> { return as_cayley_dickson_n_t<4, decltype(eve::add(r, i, j, k))>{r, i, j, k}; } template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T0 const & c0) noexcept + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T0 const & c0) noexcept { return as_cayley_dickson_n_t<4, decltype(eve::add(get<0>(c0), get<1>(c0)))>(get<0>(c0), get<1>(c0), 0, 0); } template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T0 const & c0, T1 const & c1) noexcept + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T0 const & c0, T1 const & c1) noexcept { return as_cayley_dickson_n_t<4, decltype(eve::add(get<0>(c0), get<1>(c0),get<0>(c1), get<1>(c1)))>(get<0>(c0), get<1>(c0),get<0>(c1), get<1>(c1)); } template - constexpr auto to_quaternion_(EVE_EXPECTS(eve::cpu_), T const& v) noexcept + constexpr auto quaternion_(EVE_EXPECTS(eve::cpu_), T const& v) noexcept { return v; } diff --git a/include/kyosu/types/impl/trigo.hpp b/include/kyosu/types/impl/trigo.hpp index 78b7b30a..7dd3f0f8 100644 --- a/include/kyosu/types/impl/trigo.hpp +++ b/include/kyosu/types/impl/trigo.hpp @@ -24,11 +24,11 @@ namespace kyosu::_ auto r = c*ch; auto i = s*sh; i = eve::if_else(kyosu::is_eqz(kyosu::ipart(z)) || kyosu::is_real(z), eve::zero, i); - auto res = to_complex(r, i); + auto res = complex(r, i); if (eve::any(kyosu::is_not_finite(z))) { - res = eve::if_else(eve::is_infinite(rz) && eve::is_not_finite(iz), to_complex(eve::inf(eve::as(rz)), eve::nan(eve::as(rz))), res); - res = eve::if_else(eve::is_nan(rz) && eve::is_infinite(iz), to_complex(eve::nan(eve::as(rz)), eve::nan(eve::as(rz))), res); + res = eve::if_else(eve::is_infinite(rz) && eve::is_not_finite(iz), complex(eve::inf(eve::as(rz)), eve::nan(eve::as(rz))), res); + res = eve::if_else(eve::is_nan(rz) && eve::is_infinite(iz), complex(eve::nan(eve::as(rz)), eve::nan(eve::as(rz))), res); } return res; } @@ -57,7 +57,7 @@ namespace kyosu::_ auto [sh, ch] = eve::sinhcosh(rz); auto r = c*sh; auto i = s*ch; - if (eve::all(kyosu::is_finite(z))) return to_complex(r, i); + if (eve::all(kyosu::is_finite(z))) return complex(r, i); auto infrz = kyosu::is_infinite(rz); auto nanrz = kyosu::is_nan(rz); if (eve::any(infrz || nanrz)) @@ -69,7 +69,7 @@ namespace kyosu::_ } i = eve::if_else(kyosu::is_real(z), eve::zero, i); r = eve::if_else(kyosu::is_eqz(kyosu::real(z)), eve::zero, r); - return to_complex(r, i); + return complex(r, i); } else { @@ -107,16 +107,16 @@ namespace kyosu::_ } is = eve::if_else(kyosu::is_real(z), eve::zero, is); rs = eve::if_else(kyosu::is_eqz(kyosu::real(z)), eve::zero, rs); - auto ss = to_complex(rs, is); + auto ss = complex(rs, is); auto rc = c*ch; auto ic = s*sh; ic = eve::if_else(kyosu::is_eqz(kyosu::real(z)) || kyosu::is_real(z), eve::zero, ic); - auto cc = to_complex(rc, ic); + auto cc = complex(rc, ic); if (eve::any(kyosu::is_not_finite(z))) { - cc = kyosu::if_else(infrz && is_not_finite(iz), to_complex(eve::inf(eve::as(rz)), eve::nan(eve::as(rz))), cc); - cc = kyosu::if_else(nanrz && is_infinite(iz), to_complex(eve::nan(eve::as(rz)), eve::nan(eve::as(rz))), cc); + cc = kyosu::if_else(infrz && is_not_finite(iz), complex(eve::inf(eve::as(rz)), eve::nan(eve::as(rz))), cc); + cc = kyosu::if_else(nanrz && is_infinite(iz), complex(eve::nan(eve::as(rz)), eve::nan(eve::as(rz))), cc); } return kumi::tuple{ss, cc}; } @@ -141,7 +141,7 @@ namespace kyosu::_ auto tmp = c+ch; auto rr = eve::if_else(eve::is_eqz(kyosu::real(z)), eve::zero, sh/tmp); auto ii = eve::if_else(kyosu::is_real(z), eve::zero, s/tmp); - return kyosu::if_else(eve::is_infinite(rz), kyosu::to_complex(eve::sign(rz)), kyosu::to_complex(rr, ii)); + return kyosu::if_else(eve::is_infinite(rz), kyosu::complex(eve::sign(rz)), kyosu::complex(rr, ii)); } else { @@ -171,7 +171,7 @@ namespace kyosu::_ { if constexpr(concepts::complex ) { - return cosh(to_complex(-kyosu::imag(z), kyosu::real(z))); + return cosh(complex(-kyosu::imag(z), kyosu::real(z))); } else { @@ -196,8 +196,8 @@ namespace kyosu::_ { if constexpr(concepts::complex ) { - auto s = kyosu::sinh(to_complex(-kyosu::imag(z), kyosu::real(z))); - return to_complex(kyosu::imag(s), -kyosu::real(s)); + auto s = kyosu::sinh(complex(-kyosu::imag(z), kyosu::real(z))); + return complex(kyosu::imag(s), -kyosu::real(s)); } else { @@ -222,8 +222,8 @@ namespace kyosu::_ { if constexpr(concepts::complex ) { - auto [sh, ch] = sinhcosh(to_complex(-kyosu::imag(z), kyosu::real(z))); - return kumi::tuple{to_complex(kyosu::imag(sh), -kyosu::real(sh)), ch}; + auto [sh, ch] = sinhcosh(complex(-kyosu::imag(z), kyosu::real(z))); + return kumi::tuple{complex(kyosu::imag(sh), -kyosu::real(sh)), ch}; } else @@ -247,8 +247,8 @@ namespace kyosu::_ { if constexpr(concepts::complex ) { - auto t = kyosu::tanh(kyosu::to_complex(-kyosu::imag(z), kyosu::real(z))); - return kyosu::to_complex(kyosu::imag(t), -kyosu::real(t)); + auto t = kyosu::tanh(kyosu::complex(-kyosu::imag(z), kyosu::real(z))); + return kyosu::complex(kyosu::imag(t), -kyosu::real(t)); } else { @@ -264,7 +264,7 @@ namespace kyosu::_ if constexpr(concepts::complex ) { auto r = kyosu::tan(z); - return kyosu::if_else(kyosu::is_infinite(r), kyosu::to_complex(eve::zero(eve::as(eve::underlying_type_t()))), kyosu::rec(r)); + return kyosu::if_else(kyosu::is_infinite(r), kyosu::complex(eve::zero(eve::as(eve::underlying_type_t()))), kyosu::rec(r)); } else { diff --git a/include/kyosu/types/impl/trigo_pi.hpp b/include/kyosu/types/impl/trigo_pi.hpp index 8a2f82cf..6433b61b 100644 --- a/include/kyosu/types/impl/trigo_pi.hpp +++ b/include/kyosu/types/impl/trigo_pi.hpp @@ -20,19 +20,19 @@ namespace kyosu::_ if constexpr(concepts::complex ) { auto [rz, iz] = z; - iz *= eve::pi(as(iz)); + iz *= eve::pi(eve::as(iz)); auto [s, c] = eve::sinpicospi(rz); auto [sh, ch] = eve::sinhcosh(iz); auto r = c*ch; - auto i = kyosu::if_else(is_imag(z) || kyosu::is_real(z),eve::zero, -s*sh); + auto i = eve::if_else(is_imag(z) || kyosu::is_real(z),eve::zero, -s*sh); if (eve::any(kyosu::is_not_finite(z))) { - r = eve::if_else(eve::is_infinite(iz) && eve::is_not_finite(rz), eve::inf(as(r)), r); - i = eve::if_else(eve::is_infinite(iz) && eve::is_not_finite(rz), eve::nan(as(r)), i); + r = eve::if_else(eve::is_infinite(iz) && eve::is_not_finite(rz), eve::inf(eve::as(r)), r); + i = eve::if_else(eve::is_infinite(iz) && eve::is_not_finite(rz), eve::nan(eve::as(r)), i); r = eve::if_else(eve::is_nan(iz) && eve::is_infinite(rz), eve::allbits, r); i = eve::if_else(eve::is_nan(iz) && eve::is_infinite(rz), eve::allbits, i); } - return kyosu::to_complex(r, i); + return kyosu::complex(r, i); } else { @@ -61,12 +61,12 @@ namespace kyosu::_ { auto rz = -kyosu::imag(z); auto iz = kyosu::real(z); - rz *= eve::pi(as(rz)); + rz *= eve::pi(eve::as(rz)); auto [s, c] = eve::sinpicospi(iz); auto [sh, ch] = eve::sinhcosh(rz); auto r = c*sh; auto i = s*ch; - if (any(kyosu::is_not_finite(z))) + if (eve::any(kyosu::is_not_finite(z))) { r = eve::if_else(eve::is_infinite(rz) && eve::is_not_finite(iz), rz, r); i = eve::if_else(eve::is_infinite(rz) && eve::is_nan(iz), iz, i); @@ -75,7 +75,7 @@ namespace kyosu::_ i = eve::if_else(kyosu::is_imag(z), eve::zero, i); r = eve::if_else(kyosu::is_real(z), eve::zero, r); } - return kyosu::to_complex(i, -r); + return kyosu::complex(i, -r); } else { @@ -115,7 +115,7 @@ namespace kyosu::_ rc = eve::if_else(eve::is_nan(iz) && eve::is_infinite(rz), eve::allbits, rc); ic = eve::if_else(eve::is_nan(iz) && eve::is_infinite(rz), eve::allbits, ic); } - auto cpi = kyosu::to_complex(rc, ic); + auto cpi = kyosu::complex(rc, ic); auto arz = -kyosu::imag(z); auto aiz = kyosu::real(z); arz*= eve::pi(as(arz)); @@ -132,7 +132,7 @@ namespace kyosu::_ is = if_else(eve::is_eqz(aiz), eve::zero, is); rs = if_else(eve::is_eqz(arz), eve::zero, rs); } - auto spi = kyosu::to_complex(is, -rs); + auto spi = kyosu::complex(is, -rs); return kumi::tuple{spi, cpi}; } else @@ -165,10 +165,10 @@ namespace kyosu::_ auto tmp = c+ch; auto rr = eve::if_else(kyosu::is_imag(z), eve::zero, sh/tmp); auto ii = eve::if_else(kyosu::is_real(z),eve:: zero, s/tmp); - return kyosu::if_else(eve::is_infinite(rz), kyosu::to_complex(sign(rz)), kyosu::to_complex(rr, ii)); + return kyosu::if_else(eve::is_infinite(rz), kyosu::complex(sign(rz)), kyosu::complex(rr, ii)); }; - auto r = machin(kyosu::to_complex(-kyosu::imag(z), kyosu::real(z))); - return kyosu::to_complex(kyosu::imag(r), -kyosu::real(r)); + auto r = machin(kyosu::complex(-kyosu::imag(z), kyosu::real(z))); + return kyosu::complex(kyosu::imag(r), -kyosu::real(r)); } else { @@ -186,7 +186,7 @@ namespace kyosu::_ auto r = kyosu::tanpi(z); r = kyosu::if_else(kyosu::is_infinite(r), C(), kyosu::rec(r)); r = kyosu::if_else(kyosu::is_real(z) && eve::is_flint(kyosu::real(z)*2) && eve::is_not_flint(kyosu::real(z)), C{}, r); - return kyosu::if_else(kyosu::is_real(z), kyosu::to_complex(kyosu::real(r)), r); + return kyosu::if_else(kyosu::is_real(z), kyosu::complex(kyosu::real(r)), r); } else { diff --git a/include/kyosu/types/literals.hpp b/include/kyosu/types/literals.hpp index ff84d123..1e9a6dc4 100644 --- a/include/kyosu/types/literals.hpp +++ b/include/kyosu/types/literals.hpp @@ -11,64 +11,64 @@ namespace kyosu { inline namespace literals { - inline constexpr kyosu::complex operator""_i(long double d) noexcept + inline constexpr kyosu::complex_t operator""_i(long double d) noexcept { - return kyosu::complex {0.0, static_cast(d)}; + return kyosu::complex_t {0.0, static_cast(d)}; } - inline constexpr kyosu::complex operator""_i(unsigned long long d) noexcept + inline constexpr kyosu::complex_t operator""_i(unsigned long long d) noexcept { - return kyosu::complex {0.0, static_cast(d)}; + return kyosu::complex_t {0.0, static_cast(d)}; } - inline constexpr kyosu::complex operator""_if(long double d) noexcept + inline constexpr kyosu::complex_t operator""_if(long double d) noexcept { - return kyosu::complex {0.0f, static_cast(d)}; + return kyosu::complex_t {0.0f, static_cast(d)}; } - inline constexpr kyosu::complex operator""_if(unsigned long long d) noexcept + inline constexpr kyosu::complex_t operator""_if(unsigned long long d) noexcept { - return kyosu::complex {0.0f, static_cast(d)}; + return kyosu::complex_t {0.0f, static_cast(d)}; } - inline constexpr kyosu::quaternion operator""_j(long double d) noexcept + inline constexpr kyosu::quaternion_t operator""_j(long double d) noexcept { - return kyosu::quaternion {0.0, 0.0, static_cast(d), 0.0}; + return kyosu::quaternion_t {0.0, 0.0, static_cast(d), 0.0}; } - inline constexpr kyosu::quaternion operator""_j(unsigned long long d) noexcept + inline constexpr kyosu::quaternion_t operator""_j(unsigned long long d) noexcept { - return kyosu::quaternion {0.0, 0.0, static_cast(d), 0.0}; + return kyosu::quaternion_t {0.0, 0.0, static_cast(d), 0.0}; } - inline constexpr kyosu::quaternion operator""_jf(long double d) noexcept + inline constexpr kyosu::quaternion_t operator""_jf(long double d) noexcept { - return kyosu::quaternion {0.0f, 0.0, static_cast(d), 0.0}; + return kyosu::quaternion_t {0.0f, 0.0, static_cast(d), 0.0}; } - inline constexpr kyosu::quaternion operator""_jf(unsigned long long d) noexcept + inline constexpr kyosu::quaternion_t operator""_jf(unsigned long long d) noexcept { - return kyosu::quaternion {0.0f, 0.0, static_cast(d), 0.0}; + return kyosu::quaternion_t {0.0f, 0.0, static_cast(d), 0.0}; } - inline constexpr kyosu::quaternion operator""_k(long double d) noexcept + inline constexpr kyosu::quaternion_t operator""_k(long double d) noexcept { - return kyosu::quaternion {0.0, 0.0, 0.0, static_cast(d)}; + return kyosu::quaternion_t {0.0, 0.0, 0.0, static_cast(d)}; } - inline constexpr kyosu::quaternion operator""_k(unsigned long long d) noexcept + inline constexpr kyosu::quaternion_t operator""_k(unsigned long long d) noexcept { - return kyosu::quaternion {0.0, 0.0, 0.0, static_cast(d)}; + return kyosu::quaternion_t {0.0, 0.0, 0.0, static_cast(d)}; } - inline constexpr kyosu::quaternion operator""_kf(long double d) noexcept + inline constexpr kyosu::quaternion_t operator""_kf(long double d) noexcept { - return kyosu::quaternion {0.0f, 0., 0.00, static_cast(d)}; + return kyosu::quaternion_t {0.0f, 0., 0.00, static_cast(d)}; } - inline constexpr kyosu::quaternion operator""_kf(unsigned long long d) noexcept + inline constexpr kyosu::quaternion_t operator""_kf(unsigned long long d) noexcept { - return kyosu::quaternion {0.0f, 0., 0.00, static_cast(d)}; + return kyosu::quaternion_t {0.0f, 0., 0.00, static_cast(d)}; } } } diff --git a/include/kyosu/types/octonion.hpp b/include/kyosu/types/octonion.hpp index 3d670765..abd290f8 100644 --- a/include/kyosu/types/octonion.hpp +++ b/include/kyosu/types/octonion.hpp @@ -12,9 +12,16 @@ namespace kyosu { - template - using octonion = cayley_dickson; + //! @addtogroup types + //! @{ + //! @typedef octonion_t + //! @brief Type alias for quaternion numbers + //! + //! Quaternion numbers are implemented as Caley-dickson numbers of dimension 4. + //! + //! @} + //==================================================================================================================== template - using as_octonion_t = as_cayley_dickson_n_t<8,T>; + using octonion_t = as_cayley_dickson_n_t<8,T>; } diff --git a/include/kyosu/types/quaternion.hpp b/include/kyosu/types/quaternion.hpp index ad390623..12843512 100644 --- a/include/kyosu/types/quaternion.hpp +++ b/include/kyosu/types/quaternion.hpp @@ -15,18 +15,16 @@ namespace kyosu //==================================================================================================================== //! @addtogroup types //! @{ - //! @typedef quaternion + //! @typedef quaternion_t //! @brief Type alias for quaternion numbers //! //! Quaternion numbers are implemented as Caley-dickson numbers of dimension 4. //! //! @} //==================================================================================================================== - template - using quaternion = cayley_dickson; template - using as_quaternion_t = as_cayley_dickson_n_t<4,T>; + using quaternion_t = as_cayley_dickson_n_t<4,T>; } #include diff --git a/test/doc/abs.cpp b/test/doc/abs.cpp new file mode 100644 index 00000000..f9e09e04 --- /dev/null +++ b/test/doc/abs.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +int main() +{ + using kyosu::abs; + using kyosu::complex_t; + using kyosu::quaternion_t; + + std::cout << "Real: "; + std::cout << 72.9f << " -> " << abs(72.9f) << "\n"; + + std::cout << "Complex: "; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << abs(kyosu::complex_t(3.5f,-2.9f)) << "\n"; + + std::cout << "Quaternion: "; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << abs(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; + + std::cout << "SIMD: "; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << abs(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; + + return 0; +} diff --git a/test/doc/acos.cpp b/test/doc/acos.cpp new file mode 100644 index 00000000..9b18e205 --- /dev/null +++ b/test/doc/acos.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acos(zc) = " << kyosu::acos(zc)<< std::endl + << "-> acos(ref2) = " << kyosu::acos(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acosh.cpp b/test/doc/acosh.cpp new file mode 100644 index 00000000..473ec043 --- /dev/null +++ b/test/doc/acosh.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acosh(zc) = " << kyosu::acosh(zc)<< std::endl + << "-> acosh(ref2) = " << kyosu::acosh(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acospi.cpp b/test/doc/acospi.cpp new file mode 100644 index 00000000..1fd684a2 --- /dev/null +++ b/test/doc/acospi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acospi(zc) = " << kyosu::acospi(zc)<< std::endl + << "-> acospi(ref2) = " << kyosu::acospi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acot.cpp b/test/doc/acot.cpp new file mode 100644 index 00000000..8b97a67a --- /dev/null +++ b/test/doc/acot.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acot(zc) = " << kyosu::acot(zc)<< std::endl + << "-> acot(ref2) = " << kyosu::acot(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acoth.cpp b/test/doc/acoth.cpp new file mode 100644 index 00000000..dcfa03fd --- /dev/null +++ b/test/doc/acoth.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acoth(zc) = " << kyosu::acoth(zc)<< std::endl + << "-> acoth(ref2) = " << kyosu::acoth(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acotpi.cpp b/test/doc/acotpi.cpp new file mode 100644 index 00000000..d54e757a --- /dev/null +++ b/test/doc/acotpi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acotpi(zc) = " << kyosu::acotpi(zc)<< std::endl + << "-> acotpi(ref2) = " << kyosu::acotpi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acsc.cpp b/test/doc/acsc.cpp new file mode 100644 index 00000000..a95661d9 --- /dev/null +++ b/test/doc/acsc.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acsc(zc) = " << kyosu::acsc(zc)<< std::endl + << "-> acsc(ref2) = " << kyosu::acsc(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acsch.cpp b/test/doc/acsch.cpp new file mode 100644 index 00000000..c9d1318c --- /dev/null +++ b/test/doc/acsch.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acsch(zc) = " << kyosu::acsch(zc)<< std::endl + << "-> acsch(ref2) = " << kyosu::acsch(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/acscpi.cpp b/test/doc/acscpi.cpp new file mode 100644 index 00000000..b7bae8f4 --- /dev/null +++ b/test/doc/acscpi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> acscpi(zc) = " << kyosu::acscpi(zc)<< std::endl + << "-> acscpi(ref2) = " << kyosu::acscpi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/arg.cpp b/test/doc/arg.cpp new file mode 100644 index 00000000..34245cdf --- /dev/null +++ b/test/doc/arg.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> arg(zc) = " << kyosu::arg(zc)<< std::endl + << "-> arg(ref2) = " << kyosu::arg(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asec.cpp b/test/doc/asec.cpp new file mode 100644 index 00000000..0e2aaabc --- /dev/null +++ b/test/doc/asec.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asec(zc) = " << kyosu::asec(zc)<< std::endl + << "-> asec(ref2) = " << kyosu::asec(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asech.cpp b/test/doc/asech.cpp new file mode 100644 index 00000000..596871aa --- /dev/null +++ b/test/doc/asech.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asech(zc) = " << kyosu::asech(zc)<< std::endl + << "-> asech(ref2) = " << kyosu::asech(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asecpi.cpp b/test/doc/asecpi.cpp new file mode 100644 index 00000000..596871aa --- /dev/null +++ b/test/doc/asecpi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asech(zc) = " << kyosu::asech(zc)<< std::endl + << "-> asech(ref2) = " << kyosu::asech(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asin.cpp b/test/doc/asin.cpp new file mode 100644 index 00000000..03605545 --- /dev/null +++ b/test/doc/asin.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asin(zc) = " << kyosu::asin(zc)<< std::endl + << "-> asin(ref2) = " << kyosu::asin(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asinh.cpp b/test/doc/asinh.cpp new file mode 100644 index 00000000..2955c80a --- /dev/null +++ b/test/doc/asinh.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asinh(zc) = " << kyosu::asinh(zc)<< std::endl + << "-> asinh(ref2) = " << kyosu::asinh(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/asinpi.cpp b/test/doc/asinpi.cpp new file mode 100644 index 00000000..c3e9aa9d --- /dev/null +++ b/test/doc/asinpi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> asinpi(zc) = " << kyosu::asinpi(zc)<< std::endl + << "-> asinpi(ref2) = " << kyosu::asinpi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/atan.cpp b/test/doc/atan.cpp new file mode 100644 index 00000000..20d34284 --- /dev/null +++ b/test/doc/atan.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> atan(zc) = " << kyosu::atan(zc)<< std::endl + << "-> atan(ref2) = " << kyosu::atan(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/atanh.cpp b/test/doc/atanh.cpp new file mode 100644 index 00000000..019ad2d2 --- /dev/null +++ b/test/doc/atanh.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> atanh(zc) = " << kyosu::atanh(zc)<< std::endl + << "-> atanh(ref2) = " << kyosu::atanh(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/atanpi.cpp b/test/doc/atanpi.cpp new file mode 100644 index 00000000..e7fd6c13 --- /dev/null +++ b/test/doc/atanpi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> atanpi(zc) = " << kyosu::atanpi(zc)<< std::endl + << "-> atanpi(ref2) = " << kyosu::atanpi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/average.cpp b/test/doc/average.cpp index 0e579556..fde43861 100644 --- a/test/doc/average.cpp +++ b/test/doc/average.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::average; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/beta.cpp b/test/doc/beta.cpp new file mode 100644 index 00000000..266a7110 --- /dev/null +++ b/test/doc/beta.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +int main() +{ + using kyosu::beta; + using kyosu::complex_t; + using e_t = float; + using c_t = kyosu::complex_t; + using we_t = eve::wide>; + using wc_t = eve::wide, eve::fixed<2>>; + + std::cout << "Real: "<< "\n"; + e_t e0(1); + e_t e1(2); + std::cout << e0 << ", " << e1 << " -> " << beta(e0, e1) << "\n"; + std::cout << e0 << ", " << e0 << " -> " << beta(e0, e0) << "\n"; + we_t we0(e0); + we_t we1(e1); + std::cout << we0 << ", " << we1 << " -> " << beta(we0, we1) << "\n"; + + std::cout << "Complex: "<< "\n"; + c_t c0(1, 5); + c_t c1(5, 9); + std::cout << c0 << ", " << c1 << " -> " << beta(c0, c1) << "\n"; + std::cout << c0 << ", " << c0 << " -> " << beta(c0, c0) << "\n"; + wc_t wc0(c0, c1); + wc_t wc1(c1, c1); + std::cout << wc0 << ", " << wc1 << " -> " << beta(wc0, wc1) << "\n"; + + return 0; +} diff --git a/test/doc/ceil.cpp b/test/doc/ceil.cpp index d4b4a9b9..cbf2b425 100644 --- a/test/doc/ceil.cpp +++ b/test/doc/ceil.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::conj; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << conj(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << conj(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << conj(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << conj(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << conj(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << conj(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << conj(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/conj.cpp b/test/doc/conj.cpp index d4b4a9b9..cbf2b425 100644 --- a/test/doc/conj.cpp +++ b/test/doc/conj.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::conj; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << conj(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << conj(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << conj(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << conj(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << conj(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << conj(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << conj(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/cos.cpp b/test/doc/cos.cpp new file mode 100644 index 00000000..243c1e44 --- /dev/null +++ b/test/doc/cos.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cos; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cos(e) << "\n"; + std::cout << we << " -> " << cos(we) << "\n"; + std::cout << cos(c_t(e))<< "\n"; + std::cout << cos(q_t(e))<< "\n"; + std::cout << cos(wc_t(e))<< "\n"; + std::cout << cos(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cos(c) << "\n"; + std::cout << wc << " -> " << cos(wc) << "\n"; + std::cout << cos(q_t(c))<< "\n"; + std::cout << cos(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cos(q) << "\n"; + std::cout << wq << " -> " << cos(wq) << "\n"; + + return 0; +} diff --git a/test/doc/cosh.cpp b/test/doc/cosh.cpp new file mode 100644 index 00000000..243c1e44 --- /dev/null +++ b/test/doc/cosh.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cos; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cos(e) << "\n"; + std::cout << we << " -> " << cos(we) << "\n"; + std::cout << cos(c_t(e))<< "\n"; + std::cout << cos(q_t(e))<< "\n"; + std::cout << cos(wc_t(e))<< "\n"; + std::cout << cos(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cos(c) << "\n"; + std::cout << wc << " -> " << cos(wc) << "\n"; + std::cout << cos(q_t(c))<< "\n"; + std::cout << cos(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cos(q) << "\n"; + std::cout << wq << " -> " << cos(wq) << "\n"; + + return 0; +} diff --git a/test/doc/cospi.cpp b/test/doc/cospi.cpp new file mode 100644 index 00000000..12d9da33 --- /dev/null +++ b/test/doc/cospi.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cospi; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cospi(e) << "\n"; + std::cout << we << " -> " << cospi(we) << "\n"; + std::cout << cospi(c_t(e))<< "\n"; + std::cout << cospi(q_t(e))<< "\n"; + std::cout << cospi(wc_t(e))<< "\n"; + std::cout << cospi(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cospi(c) << "\n"; + std::cout << wc << " -> " << cospi(wc) << "\n"; + std::cout << cospi(q_t(c))<< "\n"; + std::cout << cospi(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cospi(q) << "\n"; + std::cout << wq << " -> " << cospi(wq) << "\n"; + + return 0; +} diff --git a/test/doc/cot.cpp b/test/doc/cot.cpp new file mode 100644 index 00000000..f39da604 --- /dev/null +++ b/test/doc/cot.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cot; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cot(e) << "\n"; + std::cout << we << " -> " << cot(we) << "\n"; + std::cout << cot(c_t(e))<< "\n"; + std::cout << cot(q_t(e))<< "\n"; + std::cout << cot(wc_t(e))<< "\n"; + std::cout << cot(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cot(c) << "\n"; + std::cout << wc << " -> " << cot(wc) << "\n"; + std::cout << cot(q_t(c))<< "\n"; + std::cout << cot(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cot(q) << "\n"; + std::cout << wq << " -> " << cot(wq) << "\n"; + + return 0; +} diff --git a/test/doc/coth.cpp b/test/doc/coth.cpp new file mode 100644 index 00000000..f9c30105 --- /dev/null +++ b/test/doc/coth.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::coth; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << coth(e) << "\n"; + std::cout << we << " -> " << coth(we) << "\n"; + std::cout << coth(c_t(e))<< "\n"; + std::cout << coth(q_t(e))<< "\n"; + std::cout << coth(wc_t(e))<< "\n"; + std::cout << coth(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << coth(c) << "\n"; + std::cout << wc << " -> " << coth(wc) << "\n"; + std::cout << coth(q_t(c))<< "\n"; + std::cout << coth(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << coth(q) << "\n"; + std::cout << wq << " -> " << coth(wq) << "\n"; + + return 0; +} diff --git a/test/doc/cotpi.cpp b/test/doc/cotpi.cpp new file mode 100644 index 00000000..51f21b05 --- /dev/null +++ b/test/doc/cotpi.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cotpi; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cotpi(e) << "\n"; + std::cout << we << " -> " << cotpi(we) << "\n"; + std::cout << cotpi(c_t(e))<< "\n"; + std::cout << cotpi(q_t(e))<< "\n"; + std::cout << cotpi(wc_t(e))<< "\n"; + std::cout << cotpi(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cotpi(c) << "\n"; + std::cout << wc << " -> " << cotpi(wc) << "\n"; + std::cout << cotpi(q_t(c))<< "\n"; + std::cout << cotpi(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cotpi(q) << "\n"; + std::cout << wq << " -> " << cotpi(wq) << "\n"; + + return 0; +} diff --git a/test/doc/csc.cpp b/test/doc/csc.cpp new file mode 100644 index 00000000..827db515 --- /dev/null +++ b/test/doc/csc.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::csc; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << csc(e) << "\n"; + std::cout << we << " -> " << csc(we) << "\n"; + std::cout << csc(c_t(e))<< "\n"; + std::cout << csc(q_t(e))<< "\n"; + std::cout << csc(wc_t(e))<< "\n"; + std::cout << csc(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << csc(c) << "\n"; + std::cout << wc << " -> " << csc(wc) << "\n"; + std::cout << csc(q_t(c))<< "\n"; + std::cout << csc(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << csc(q) << "\n"; + std::cout << wq << " -> " << csc(wq) << "\n"; + + return 0; +} diff --git a/test/doc/csch.cpp b/test/doc/csch.cpp new file mode 100644 index 00000000..51c92d4a --- /dev/null +++ b/test/doc/csch.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::csch; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << csch(e) << "\n"; + std::cout << we << " -> " << csch(we) << "\n"; + std::cout << csch(c_t(e))<< "\n"; + std::cout << csch(q_t(e))<< "\n"; + std::cout << csch(wc_t(e))<< "\n"; + std::cout << csch(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << csch(c) << "\n"; + std::cout << wc << " -> " << csch(wc) << "\n"; + std::cout << csch(q_t(c))<< "\n"; + std::cout << csch(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << csch(q) << "\n"; + std::cout << wq << " -> " << csch(wq) << "\n"; + + return 0; +} diff --git a/test/doc/cscpi.cpp b/test/doc/cscpi.cpp new file mode 100644 index 00000000..b7a086d4 --- /dev/null +++ b/test/doc/cscpi.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::cscpi; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << cscpi(e) << "\n"; + std::cout << we << " -> " << cscpi(we) << "\n"; + std::cout << cscpi(c_t(e))<< "\n"; + std::cout << cscpi(q_t(e))<< "\n"; + std::cout << cscpi(wc_t(e))<< "\n"; + std::cout << cscpi(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << cscpi(c) << "\n"; + std::cout << wc << " -> " << cscpi(wc) << "\n"; + std::cout << cscpi(q_t(c))<< "\n"; + std::cout << cscpi(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << cscpi(q) << "\n"; + std::cout << wq << " -> " << cscpi(wq) << "\n"; + + return 0; +} diff --git a/test/doc/dec.cpp b/test/doc/dec.cpp index 3278b095..71019b50 100644 --- a/test/doc/dec.cpp +++ b/test/doc/dec.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::dec; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/deta.cpp b/test/doc/deta.cpp new file mode 100644 index 00000000..9d829f63 --- /dev/null +++ b/test/doc/deta.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +int main() +{ + using kyosu::deta; +using wide_ft = eve::wide >; + + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.6f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + auto zc = kyosu::complex_t(ref1, imf1); + auto z = kyosu::complex_t(1.0, 0.0); + auto zf= kyosu::complex_t(1.0, 0.0); + std::cout + << "---- simd" << std::endl + << "<- z = " << z << std::endl + << "-> deta(1, z) = " << deta(1u, z) << std::endl + << "-> deta(2, z) = " << deta(2u, z) << std::endl + << "-> deta(3, z) = " << deta(3u, z) << std::endl + << "-> deta(2, 0.2)= " << deta(2u, 0.2)<< std::endl + << "-> deta(1, 0.2)= " << deta(1u, 0.2)<< std::endl + << "-> deta(1, z) = " << deta(1u, zf) << std::endl + << "-> deta(2, z) = " << deta(2u, zf) << std::endl + << "-> deta(3, z) = " << deta(3u, zf) << std::endl + << "-> deta(2, 0.2)= " << deta(2u, 0.2f)<< std::endl + << "-> deta(1, 0.2)= " << deta(1u, 0.2f)<< std::endl + << "<- zc = " << zc << std::endl + << "-> deta(1, zc) = " << deta(1u, zc)<< std::endl; + return 0; +} diff --git a/test/doc/digamma.cpp b/test/doc/digamma.cpp new file mode 100644 index 00000000..a713be7f --- /dev/null +++ b/test/doc/digamma.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> digamma(zc) = " << kyosu::digamma(zc)<< std::endl + << "-> digamma(ref2) = " << kyosu::digamma(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/dist.cpp b/test/doc/dist.cpp index c10b2fde..9afcd69c 100644 --- a/test/doc/dist.cpp +++ b/test/doc/dist.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::dist; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/dot.cpp b/test/doc/dot.cpp index c8cdf259..135e6227 100644 --- a/test/doc/dot.cpp +++ b/test/doc/dot.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::dot; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/erf.cpp b/test/doc/erf.cpp new file mode 100644 index 00000000..832a8f27 --- /dev/null +++ b/test/doc/erf.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> erf(zc) = " << kyosu::erf(zc)<< std::endl + << "-> erf(ref2) = " << kyosu::erf(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/erfcx.cpp b/test/doc/erfcx.cpp new file mode 100644 index 00000000..e075475c --- /dev/null +++ b/test/doc/erfcx.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> erfcx(zc) = " << kyosu::erfcx(zc)<< std::endl + << "-> erfcx(ref2) = " << kyosu::erfcx(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/erfi.cpp b/test/doc/erfi.cpp new file mode 100644 index 00000000..ee24bcd8 --- /dev/null +++ b/test/doc/erfi.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> erfi(zc) = " << kyosu::erfi(zc)<< std::endl + << "-> erfi(ref2) = " << kyosu::erfi(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/eta.cpp b/test/doc/eta.cpp new file mode 100644 index 00000000..f97fafd0 --- /dev/null +++ b/test/doc/eta.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> eta(zc) = " << kyosu::eta(zc)<< std::endl + << "-> eta(ref2) = " << kyosu::eta(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/exp.cpp b/test/doc/exp.cpp index e49341af..75e416cc 100644 --- a/test/doc/exp.cpp +++ b/test/doc/exp.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::exp; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/exp10.cpp b/test/doc/exp10.cpp new file mode 100644 index 00000000..9ddf409e --- /dev/null +++ b/test/doc/exp10.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::exp10; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << exp10(e) << "\n"; + std::cout << we << " -> " << exp10(we) << "\n"; + std::cout << exp10(c_t(e))<< "\n"; + std::cout << exp10(q_t(e))<< "\n"; + std::cout << exp10(wc_t(e))<< "\n"; + std::cout << exp10(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << exp10(c) << "\n"; + std::cout << wc << " -> " << exp10(wc) << "\n"; + std::cout << exp10(q_t(c))<< "\n"; + std::cout << exp10(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << exp10(q) << "\n"; + std::cout << wq << " -> " << exp10(wq) << "\n"; + + return 0; +} diff --git a/test/doc/exp2.cpp b/test/doc/exp2.cpp new file mode 100644 index 00000000..4558f0be --- /dev/null +++ b/test/doc/exp2.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::exp2; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << exp2(e) << "\n"; + std::cout << we << " -> " << exp2(we) << "\n"; + std::cout << exp2(c_t(e))<< "\n"; + std::cout << exp2(q_t(e))<< "\n"; + std::cout << exp2(wc_t(e))<< "\n"; + std::cout << exp2(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << exp2(c) << "\n"; + std::cout << wc << " -> " << exp2(wc) << "\n"; + std::cout << exp2(q_t(c))<< "\n"; + std::cout << exp2(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << exp2(q) << "\n"; + std::cout << wq << " -> " << exp2(wq) << "\n"; + + return 0; +} diff --git a/test/doc/expm1.cpp b/test/doc/expm1.cpp index 0669efcf..2ae4e8e2 100644 --- a/test/doc/expm1.cpp +++ b/test/doc/expm1.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::expm1; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/expmx2.cpp b/test/doc/expmx2.cpp new file mode 100644 index 00000000..d3246234 --- /dev/null +++ b/test/doc/expmx2.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::expx2; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << expx2(e) << "\n"; + std::cout << we << " -> " << expx2(we) << "\n"; + std::cout << expx2(c_t(e))<< "\n"; + std::cout << expx2(q_t(e))<< "\n"; + std::cout << expx2(wc_t(e))<< "\n"; + std::cout << expx2(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << expx2(c) << "\n"; + std::cout << wc << " -> " << expx2(wc) << "\n"; + std::cout << expx2(q_t(c))<< "\n"; + std::cout << expx2(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << expx2(q) << "\n"; + std::cout << wq << " -> " << expx2(wq) << "\n"; + + return 0; +} diff --git a/test/doc/expx2.cpp b/test/doc/expx2.cpp new file mode 100644 index 00000000..d3246234 --- /dev/null +++ b/test/doc/expx2.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::expx2; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << expx2(e) << "\n"; + std::cout << we << " -> " << expx2(we) << "\n"; + std::cout << expx2(c_t(e))<< "\n"; + std::cout << expx2(q_t(e))<< "\n"; + std::cout << expx2(wc_t(e))<< "\n"; + std::cout << expx2(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << expx2(c) << "\n"; + std::cout << wc << " -> " << expx2(wc) << "\n"; + std::cout << expx2(q_t(c))<< "\n"; + std::cout << expx2(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << expx2(q) << "\n"; + std::cout << wq << " -> " << expx2(wq) << "\n"; + + return 0; +} diff --git a/test/doc/faddeeva.cpp b/test/doc/faddeeva.cpp new file mode 100644 index 00000000..d2382e1f --- /dev/null +++ b/test/doc/faddeeva.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> faddeeva(zc) = " << kyosu::faddeeva(zc)<< std::endl + << "-> faddeeva(ref2) = " << kyosu::faddeeva(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/floor.cpp b/test/doc/floor.cpp index 40753b54..7d36d322 100644 --- a/test/doc/floor.cpp +++ b/test/doc/floor.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::floor; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << floor(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << floor(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << floor(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << floor(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << floor(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << floor(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << floor(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/frac.cpp b/test/doc/frac.cpp index 5f678c30..4fd6e44f 100644 --- a/test/doc/frac.cpp +++ b/test/doc/frac.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::frac; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << frac(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << frac(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << frac(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << frac(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << frac(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << frac(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << frac(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/from_cylindrical.cpp b/test/doc/from_cylindrical.cpp index 9f183dd1..d8b47cdf 100644 --- a/test/doc/from_cylindrical.cpp +++ b/test/doc/from_cylindrical.cpp @@ -5,8 +5,8 @@ int main() { using kyosu::from_cylindrical; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; auto r = 2.0; auto a = eve::pio_3(eve::as(r)); diff --git a/test/doc/hypot.cpp b/test/doc/hypot.cpp index ea791aaa..f0c3149f 100644 --- a/test/doc/hypot.cpp +++ b/test/doc/hypot.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::hypot; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/if_else.cpp b/test/doc/if_else.cpp index 7727c18e..36a7f3ae 100644 --- a/test/doc/if_else.cpp +++ b/test/doc/if_else.cpp @@ -4,12 +4,12 @@ int main() { - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; - auto c = complex(3.5f,-2.9f); - auto q = quaternion(1.f,2.f,3.f,4.f); + auto c = kyosu::complex_t(3.5f,-2.9f); + auto q = kyosu::quaternion_t(1.f,2.f,3.f,4.f); auto t = 1.0f; auto r = kyosu::if_else(t > 2.0f, q, c); std::cout << r << std::endl; diff --git a/test/doc/imag.cpp b/test/doc/imag.cpp new file mode 100644 index 00000000..feee1ac3 --- /dev/null +++ b/test/doc/imag.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> imag(zc) = " << kyosu::imag(zc)<< std::endl + << "-> imag(ref2) = " << kyosu::imag(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/inc.cpp b/test/doc/inc.cpp index fdfac122..a05bce0e 100644 --- a/test/doc/inc.cpp +++ b/test/doc/inc.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::inc; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/ipart.cpp b/test/doc/ipart.cpp index 82b078ba..cf1edbda 100644 --- a/test/doc/ipart.cpp +++ b/test/doc/ipart.cpp @@ -5,27 +5,27 @@ int main() { using kyosu::ipart; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; float f = 72.9f; std::cout << f << " -> " << ipart(f) << "\n"; std::cout << "Complex: "; - auto z = complex(3.5f,-2.9f); + auto z = kyosu::complex_t(3.5f,-2.9f); std::cout << z << " -> " << ipart(z) << " => "; ipart(z) = 11.23f; std::cout << z << "\n"; std::cout << "Quaternion: "; - auto q = quaternion(1.,2.,3.,4.); + auto q = kyosu::quaternion_t(1.,2.,3.,4.); std::cout << q << " -> " << ipart(q) << " => "; ipart(q) = 42.7; std::cout << q << "\n"; std::cout << "SIMD: "; - eve::wide, eve::fixed<2>> wz(complex(1.3,-3.7)); + eve::wide, eve::fixed<2>> wz(kyosu::complex_t(1.3,-3.7)); std::cout << wz << " -> " << ipart(wz) << " => "; ipart(wz) = eve::wide>{13.37,63.24}; std::cout << wz << "\n"; diff --git a/test/doc/is_denormal.cpp b/test/doc/is_denormal.cpp new file mode 100644 index 00000000..e5423cf5 --- /dev/null +++ b/test/doc/is_denormal.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_denormal; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + e_t mind= eve::mindenormal(as(e)); + we_t we = we_t(e, zer, nan, mind); + std::cout << e << " -> " << is_denormal(e) << "\n"; + std::cout << we << " -> " << is_denormal(we) << "\n"; + std::cout << is_denormal(c_t(e))<< "\n"; + std::cout << is_denormal(q_t(e))<< "\n"; + std::cout << is_denormal(kyosu::complex(we))<< "\n"; + std::cout << is_denormal(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, mind); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_denormal(c) << "\n"; + std::cout << wc << " -> " << is_denormal(wc) << "\n"; + std::cout << is_denormal(kyosu::complex(wc))<< "\n";; + std::cout << is_denormal(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, mind, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_denormal(q) << "\n"; + std::cout << wq << " -> " << is_denormal(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_equal.cpp b/test/doc/is_equal.cpp index 990afd5d..6d9854a1 100644 --- a/test/doc/is_equal.cpp +++ b/test/doc/is_equal.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::is_equal; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/is_eqz.cpp b/test/doc/is_eqz.cpp new file mode 100644 index 00000000..0fcab988 --- /dev/null +++ b/test/doc/is_eqz.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_eqz; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_eqz(e) << "\n"; + std::cout << we << " -> " << is_eqz(we) << "\n"; + std::cout << is_eqz(c_t(e))<< "\n"; + std::cout << is_eqz(q_t(e))<< "\n"; + std::cout << is_eqz(kyosu::complex(we))<< "\n"; + std::cout << is_eqz(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_eqz(c) << "\n"; + std::cout << wc << " -> " << is_eqz(wc) << "\n"; + std::cout << is_eqz(kyosu::complex(wc))<< "\n";; + std::cout << is_eqz(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_eqz(q) << "\n"; + std::cout << wq << " -> " << is_eqz(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_finite.cpp b/test/doc/is_finite.cpp new file mode 100644 index 00000000..d0701260 --- /dev/null +++ b/test/doc/is_finite.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_finite; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_finite(e) << "\n"; + std::cout << we << " -> " << is_finite(we) << "\n"; + std::cout << is_finite(c_t(e))<< "\n"; + std::cout << is_finite(q_t(e))<< "\n"; + std::cout << is_finite(kyosu::complex(we))<< "\n"; + std::cout << is_finite(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_finite(c) << "\n"; + std::cout << wc << " -> " << is_finite(wc) << "\n"; + std::cout << is_finite(kyosu::complex(wc))<< "\n";; + std::cout << is_finite(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_finite(q) << "\n"; + std::cout << wq << " -> " << is_finite(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_imag.cpp b/test/doc/is_imag.cpp new file mode 100644 index 00000000..c3bc8fcf --- /dev/null +++ b/test/doc/is_imag.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 0.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> is_imag(zc) = " << kyosu::is_imag(zc)<< std::endl + << "-> is_imag(ref2) = " << kyosu::is_imag(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/is_infinite.cpp b/test/doc/is_infinite.cpp new file mode 100644 index 00000000..766f951d --- /dev/null +++ b/test/doc/is_infinite.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_infinite; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_infinite(e) << "\n"; + std::cout << we << " -> " << is_infinite(we) << "\n"; + std::cout << is_infinite(c_t(e))<< "\n"; + std::cout << is_infinite(q_t(e))<< "\n"; + std::cout << is_infinite(kyosu::complex(we))<< "\n"; + std::cout << is_infinite(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_infinite(c) << "\n"; + std::cout << wc << " -> " << is_infinite(wc) << "\n"; + std::cout << is_infinite(kyosu::complex(wc))<< "\n";; + std::cout << is_infinite(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_infinite(q) << "\n"; + std::cout << wq << " -> " << is_infinite(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_nan.cpp b/test/doc/is_nan.cpp new file mode 100644 index 00000000..e4be1642 --- /dev/null +++ b/test/doc/is_nan.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_nan; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_nan(e) << "\n"; + std::cout << we << " -> " << is_nan(we) << "\n"; + std::cout << is_nan(c_t(e))<< "\n"; + std::cout << is_nan(q_t(e))<< "\n"; + std::cout << is_nan(kyosu::complex(we))<< "\n"; + std::cout << is_nan(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_nan(c) << "\n"; + std::cout << wc << " -> " << is_nan(wc) << "\n"; + std::cout << is_nan(kyosu::complex(wc))<< "\n";; + std::cout << is_nan(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_nan(q) << "\n"; + std::cout << wq << " -> " << is_nan(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_nez.cpp b/test/doc/is_nez.cpp new file mode 100644 index 00000000..75657b1d --- /dev/null +++ b/test/doc/is_nez.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_nez; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_nez(e) << "\n"; + std::cout << we << " -> " << is_nez(we) << "\n"; + std::cout << is_nez(c_t(e))<< "\n"; + std::cout << is_nez(q_t(e))<< "\n"; + std::cout << is_nez(kyosu::complex(we))<< "\n"; + std::cout << is_nez(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_nez(c) << "\n"; + std::cout << wc << " -> " << is_nez(wc) << "\n"; + std::cout << is_nez(kyosu::complex(wc))<< "\n";; + std::cout << is_nez(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_nez(q) << "\n"; + std::cout << wq << " -> " << is_nez(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_not_denormal.cpp b/test/doc/is_not_denormal.cpp new file mode 100644 index 00000000..66914374 --- /dev/null +++ b/test/doc/is_not_denormal.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_not_denormal; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + e_t mind= eve::mindenormal(as(e)); + we_t we = we_t(e, zer, nan, mind); + std::cout << e << " -> " << is_not_denormal(e) << "\n"; + std::cout << we << " -> " << is_not_denormal(we) << "\n"; + std::cout << is_not_denormal(c_t(e))<< "\n"; + std::cout << is_not_denormal(q_t(e))<< "\n"; + std::cout << is_not_denormal(kyosu::complex(we))<< "\n"; + std::cout << is_not_denormal(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, mind); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_not_denormal(c) << "\n"; + std::cout << wc << " -> " << is_not_denormal(wc) << "\n"; + std::cout << is_not_denormal(kyosu::complex(wc))<< "\n";; + std::cout << is_not_denormal(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, mind, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_not_denormal(q) << "\n"; + std::cout << wq << " -> " << is_not_denormal(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_not_equal.cpp b/test/doc/is_not_equal.cpp index 7a5954cf..a27d1cf1 100644 --- a/test/doc/is_not_equal.cpp +++ b/test/doc/is_not_equal.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::is_not_equal; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/is_not_finite.cpp b/test/doc/is_not_finite.cpp new file mode 100644 index 00000000..dba4f727 --- /dev/null +++ b/test/doc/is_not_finite.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_not_finite; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_not_finite(e) << "\n"; + std::cout << we << " -> " << is_not_finite(we) << "\n"; + std::cout << is_not_finite(c_t(e))<< "\n"; + std::cout << is_not_finite(q_t(e))<< "\n"; + std::cout << is_not_finite(kyosu::complex(we))<< "\n"; + std::cout << is_not_finite(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_not_finite(c) << "\n"; + std::cout << wc << " -> " << is_not_finite(wc) << "\n"; + std::cout << is_not_finite(kyosu::complex(wc))<< "\n";; + std::cout << is_not_finite(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_not_finite(q) << "\n"; + std::cout << wq << " -> " << is_not_finite(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_not_infinite.cpp b/test/doc/is_not_infinite.cpp new file mode 100644 index 00000000..06c01d65 --- /dev/null +++ b/test/doc/is_not_infinite.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_not_infinite; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_not_infinite(e) << "\n"; + std::cout << we << " -> " << is_not_infinite(we) << "\n"; + std::cout << is_not_infinite(c_t(e))<< "\n"; + std::cout << is_not_infinite(q_t(e))<< "\n"; + std::cout << is_not_infinite(kyosu::complex(we))<< "\n"; + std::cout << is_not_infinite(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_not_infinite(c) << "\n"; + std::cout << wc << " -> " << is_not_infinite(wc) << "\n"; + std::cout << is_not_infinite(kyosu::complex(wc))<< "\n";; + std::cout << is_not_infinite(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_not_infinite(q) << "\n"; + std::cout << wq << " -> " << is_not_infinite(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_not_nan.cpp b/test/doc/is_not_nan.cpp new file mode 100644 index 00000000..165e0654 --- /dev/null +++ b/test/doc/is_not_nan.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_not_nan; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_not_nan(e) << "\n"; + std::cout << we << " -> " << is_not_nan(we) << "\n"; + std::cout << is_not_nan(c_t(e))<< "\n"; + std::cout << is_not_nan(q_t(e))<< "\n"; + std::cout << is_not_nan(kyosu::complex(we))<< "\n"; + std::cout << is_not_nan(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_not_nan(c) << "\n"; + std::cout << wc << " -> " << is_not_nan(wc) << "\n"; + std::cout << is_not_nan(kyosu::complex(wc))<< "\n";; + std::cout << is_not_nan(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_not_nan(q) << "\n"; + std::cout << wq << " -> " << is_not_nan(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_not_real.cpp b/test/doc/is_not_real.cpp new file mode 100644 index 00000000..e47f7a28 --- /dev/null +++ b/test/doc/is_not_real.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_not_real; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_not_real(e) << "\n"; + std::cout << we << " -> " << is_not_real(we) << "\n"; + std::cout << is_not_real(c_t(e))<< "\n"; + std::cout << is_not_real(q_t(e))<< "\n"; + std::cout << is_not_real(kyosu::complex(we))<< "\n"; + std::cout << is_not_real(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_not_real(c) << "\n"; + std::cout << wc << " -> " << is_not_real(wc) << "\n"; + std::cout << is_not_real(kyosu::complex(wc))<< "\n";; + std::cout << is_not_real(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_not_real(q) << "\n"; + std::cout << wq << " -> " << is_not_real(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_real.cpp b/test/doc/is_real.cpp new file mode 100644 index 00000000..4a7e709d --- /dev/null +++ b/test/doc/is_real.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +int main() +{ + using kyosu::is_real; + using kyosu::complex_t; + using kyosu::quaternion_t; + using eve::as; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + e_t nan = eve::nan(as(e)); + e_t inf = eve::inf(as(e)); + e_t zer = eve::zero(as(e)); + we_t we = we_t(e, zer, nan, inf); + std::cout << e << " -> " << is_real(e) << "\n"; + std::cout << we << " -> " << is_real(we) << "\n"; + std::cout << is_real(c_t(e))<< "\n"; + std::cout << is_real(q_t(e))<< "\n"; + std::cout << is_real(kyosu::complex(we))<< "\n"; + std::cout << is_real(kyosu::quaternion(we))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + c_t d(0.0f, inf); + wc_t wc = wc_t(c, zer, nan, d); + std::cout << c << " -> " << is_real(c) << "\n"; + std::cout << wc << " -> " << is_real(wc) << "\n"; + std::cout << is_real(kyosu::complex(wc))<< "\n";; + std::cout << is_real(kyosu::quaternion(wc))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + q_t r(3.5f, nan, inf, zer); + wq_t wq = wq_t(q, zer, nan, r); + std::cout << q << " -> " << is_real(q) << "\n"; + std::cout << wq << " -> " << is_real(wq) << "\n"; + + return 0; +} diff --git a/test/doc/is_unitary.cpp b/test/doc/is_unitary.cpp index 724bc645..2d3a2ff2 100644 --- a/test/doc/is_unitary.cpp +++ b/test/doc/is_unitary.cpp @@ -5,44 +5,38 @@ int main() { using kyosu::is_unitary; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; std::cout << "Real: \n"; - e_t e(72.9f); + e_t e(2.9f); we_t we = we_t(e); - e_t ue = kyosu::sign(e); - we_t uwe = kyosu::sign(we); std::cout << e << " -> " << is_unitary(e) << "\n"; std::cout << we << " -> " << is_unitary(we) << "\n"; - std::cout << ue << " -> " << is_unitary(ue) << "\n"; - std::cout << uwe << " -> " << is_unitary(uwe) << "\n"; + std::cout << is_unitary(c_t(e))<< "\n"; + std::cout << is_unitary(q_t(e))<< "\n"; + std::cout << is_unitary(wc_t(e))<< "\n"; + std::cout << is_unitary(wq_t(e))<< "\n"; std::cout << "Complex: \n"; c_t c(3.5f,-2.9f); wc_t wc = wc_t(c); - c_t uc = kyosu::sign(c); - wc_t uwc = kyosu::sign(wc); std::cout << c << " -> " << is_unitary(c) << "\n"; std::cout << wc << " -> " << is_unitary(wc) << "\n"; - std::cout << uc << " -> " << is_unitary(uc) << "\n"; - std::cout << uwc << " -> " << is_unitary(uwc) << "\n"; + std::cout << is_unitary(q_t(c))<< "\n"; + std::cout << is_unitary(wq_t(c))<< "\n"; std::cout << "Quaternion: \n"; q_t q(3.5f,-2.9f, 2.1f, 3.2f); wq_t wq = wq_t(q); - q_t uq = kyosu::sign(q); - wq_t uwq = kyosu::sign(wq); std::cout << q << " -> " << is_unitary(q) << "\n"; std::cout << wq << " -> " << is_unitary(wq) << "\n"; - std::cout << uq << " -> " << is_unitary(uq) << "\n"; - std::cout << uwq << " -> " << is_unitary(uwq) << "\n"; return 0; } diff --git a/test/doc/jpart.cpp b/test/doc/jpart.cpp index 368f0c91..5dfd323e 100644 --- a/test/doc/jpart.cpp +++ b/test/doc/jpart.cpp @@ -5,25 +5,25 @@ int main() { using kyosu::jpart; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; float f = 72.9f; std::cout << f << " -> " << jpart(f) << "\n"; std::cout << "Complex: "; - auto z = complex(3.5f,-2.9f); + auto z = kyosu::complex_t(3.5f,-2.9f); std::cout << z << " -> " << jpart(z) << "\n"; std::cout << "Quaternion: "; - auto q = quaternion(1.,2.,3.,4.); + auto q = kyosu::quaternion_t(1.,2.,3.,4.); std::cout << q << " -> " << jpart(q) << " => "; jpart(q) = 42.7; std::cout << q << "\n"; std::cout << "SIMD: "; - eve::wide, eve::fixed<2>> wz(quaternion(1.3,-3.7,4.2,-7.8)); + eve::wide, eve::fixed<2>> wz(kyosu::quaternion_t(1.3,-3.7,4.2,-7.8)); std::cout << wz << " -> " << jpart(wz) << " => "; jpart(wz) = eve::wide>{13.37,63.24}; std::cout << wz << "\n"; diff --git a/test/doc/kpart.cpp b/test/doc/kpart.cpp index a9c92b7a..67e2e35a 100644 --- a/test/doc/kpart.cpp +++ b/test/doc/kpart.cpp @@ -5,25 +5,25 @@ int main() { using kyosu::kpart; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; float f = 72.9f; std::cout << f << " -> " << kpart(f) << "\n"; std::cout << "Complex: "; - auto z = complex(3.5f,-2.9f); + auto z = kyosu::complex_t(3.5f,-2.9f); std::cout << z << " -> " << kpart(z) << "\n"; std::cout << "Quaternion: "; - auto q = quaternion(1.,2.,3.,4.); + auto q = kyosu::quaternion_t(1.,2.,3.,4.); std::cout << q << " -> " << kpart(q) << " => "; kpart(q) = 42.7; std::cout << q << "\n"; std::cout << "SIMD: "; - eve::wide, eve::fixed<2>> wz(quaternion(1.3,-3.7,4.2,-7.8)); + eve::wide, eve::fixed<2>> wz(kyosu::quaternion_t(1.3,-3.7,4.2,-7.8)); std::cout << wz << " -> " << kpart(wz) << " => "; kpart(wz) = eve::wide>{13.37,63.24}; std::cout << wz << "\n"; diff --git a/test/doc/lambda.cpp b/test/doc/lambda.cpp new file mode 100644 index 00000000..3fbf4b54 --- /dev/null +++ b/test/doc/lambda.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "<- ref2 = " << ref2 << std::endl + << "-> lambda(zc) = " << kyosu::lambda(zc)<< std::endl + << "-> lambda(ref2) = " << kyosu::lambda(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/lbeta.cpp b/test/doc/lbeta.cpp new file mode 100644 index 00000000..34c1f8fe --- /dev/null +++ b/test/doc/lbeta.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +int main() +{ + using kyosu::lbeta; + using kyosu::complex_t; + using e_t = float; + using c_t = kyosu::complex_t; + using we_t = eve::wide>; + using wc_t = eve::wide, eve::fixed<2>>; + + std::cout << "Real: "<< "\n"; + e_t e0(1); + e_t e1(2); + std::cout << e0 << ", " << e1 << " -> " << lbeta(e0, e1) << "\n"; + std::cout << e0 << ", " << e0 << " -> " << lbeta(e0, e0) << "\n"; + we_t we0(e0); + we_t we1(e1); + std::cout << we0 << ", " << we1 << " -> " << lbeta(we0, we1) << "\n"; + + std::cout << "Complex: "<< "\n"; + c_t c0(1, 5); + c_t c1(5, 9); + std::cout << c0 << ", " << c1 << " -> " << lbeta(c0, c1) << "\n"; + std::cout << c0 << ", " << c0 << " -> " << lbeta(c0, c0) << "\n"; + wc_t wc0(c0, c1); + wc_t wc1(c1, c1); + std::cout << wc0 << ", " << wc1 << " -> " << lbeta(wc0, wc1) << "\n"; + + return 0; +} diff --git a/test/doc/log.cpp b/test/doc/log.cpp new file mode 100644 index 00000000..a42f5fee --- /dev/null +++ b/test/doc/log.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::log; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << log(e) << "\n"; + std::cout << we << " -> " << log(we) << "\n"; + std::cout << log(c_t(e))<< "\n"; + std::cout << log(q_t(e))<< "\n"; + std::cout << log(wc_t(e))<< "\n"; + std::cout << log(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << log(c) << "\n"; + std::cout << wc << " -> " << log(wc) << "\n"; + std::cout << log(q_t(c))<< "\n"; + std::cout << log(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << log(q) << "\n"; + std::cout << wq << " -> " << log(wq) << "\n"; + + return 0; +} diff --git a/test/doc/log10.cpp b/test/doc/log10.cpp new file mode 100644 index 00000000..afbf02a3 --- /dev/null +++ b/test/doc/log10.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::log10; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << log10(e) << "\n"; + std::cout << we << " -> " << log10(we) << "\n"; + std::cout << log10(c_t(e))<< "\n"; + std::cout << log10(q_t(e))<< "\n"; + std::cout << log10(wc_t(e))<< "\n"; + std::cout << log10(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << log10(c) << "\n"; + std::cout << wc << " -> " << log10(wc) << "\n"; + std::cout << log10(q_t(c))<< "\n"; + std::cout << log10(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << log10(q) << "\n"; + std::cout << wq << " -> " << log10(wq) << "\n"; + + return 0; +} diff --git a/test/doc/log1p.cpp b/test/doc/log1p.cpp new file mode 100644 index 00000000..1ec4748b --- /dev/null +++ b/test/doc/log1p.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::log1p; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << log1p(e) << "\n"; + std::cout << we << " -> " << log1p(we) << "\n"; + std::cout << log1p(c_t(e))<< "\n"; + std::cout << log1p(q_t(e))<< "\n"; + std::cout << log1p(wc_t(e))<< "\n"; + std::cout << log1p(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << log1p(c) << "\n"; + std::cout << wc << " -> " << log1p(wc) << "\n"; + std::cout << log1p(q_t(c))<< "\n"; + std::cout << log1p(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << log1p(q) << "\n"; + std::cout << wq << " -> " << log1p(wq) << "\n"; + + return 0; +} diff --git a/test/doc/log2.cpp b/test/doc/log2.cpp new file mode 100644 index 00000000..ec3130f5 --- /dev/null +++ b/test/doc/log2.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::log2; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << log2(e) << "\n"; + std::cout << we << " -> " << log2(we) << "\n"; + std::cout << log2(c_t(e))<< "\n"; + std::cout << log2(q_t(e))<< "\n"; + std::cout << log2(wc_t(e))<< "\n"; + std::cout << log2(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << log2(c) << "\n"; + std::cout << wc << " -> " << log2(wc) << "\n"; + std::cout << log2(q_t(c))<< "\n"; + std::cout << log2(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << log2(q) << "\n"; + std::cout << wq << " -> " << log2(wq) << "\n"; + + return 0; +} diff --git a/test/doc/log_abs.cpp b/test/doc/log_abs.cpp new file mode 100644 index 00000000..3785262a --- /dev/null +++ b/test/doc/log_abs.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +int main() +{ + using kyosu::log_abs; + using kyosu::complex_t; + using kyosu::quaternion_t; + using e_t = float; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; + using we_t = eve::wide>; + using wc_t = eve::wide>; + using wq_t = eve::wide>; + + std::cout << "Real: \n"; + e_t e(2.9f); + we_t we = we_t(e); + std::cout << e << " -> " << log_abs(e) << "\n"; + std::cout << we << " -> " << log_abs(we) << "\n"; + std::cout << log_abs(c_t(e))<< "\n"; + std::cout << log_abs(q_t(e))<< "\n"; + std::cout << log_abs(wc_t(e))<< "\n"; + std::cout << log_abs(wq_t(e))<< "\n"; + + std::cout << "Complex: \n"; + c_t c(3.5f,-2.9f); + wc_t wc = wc_t(c); + std::cout << c << " -> " << log_abs(c) << "\n"; + std::cout << wc << " -> " << log_abs(wc) << "\n"; + std::cout << log_abs(q_t(c))<< "\n"; + std::cout << log_abs(wq_t(c))<< "\n"; + + std::cout << "Quaternion: \n"; + q_t q(3.5f,-2.9f, 2.1f, 3.2f); + wq_t wq = wq_t(q); + std::cout << q << " -> " << log_abs(q) << "\n"; + std::cout << wq << " -> " << log_abs(wq) << "\n"; + + return 0; +} diff --git a/test/doc/log_abs_gamma.cpp b/test/doc/log_abs_gamma.cpp new file mode 100644 index 00000000..0d597142 --- /dev/null +++ b/test/doc/log_abs_gamma.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> log_abs_gamma(zc) = " << kyosu::log_abs_gamma(zc)<< std::endl + << "-> log_abs_gamma(ref2) = " << kyosu::log_abs_gamma(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/log_gamma.cpp b/test/doc/log_gamma.cpp new file mode 100644 index 00000000..a676576a --- /dev/null +++ b/test/doc/log_gamma.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> log_gamma(zc) = " << kyosu::log_gamma(zc)<< std::endl + << "-> log_gamma(ref2) = " << kyosu::log_gamma(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/lpnorm.cpp b/test/doc/lpnorm.cpp index 77df6a8f..06e07d03 100644 --- a/test/doc/lpnorm.cpp +++ b/test/doc/lpnorm.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::lpnorm; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/manhattan.cpp b/test/doc/manhattan.cpp index f8938642..1d0afe23 100644 --- a/test/doc/manhattan.cpp +++ b/test/doc/manhattan.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::manhattan; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/minus.cpp b/test/doc/minus.cpp index ddbec677..5a0dbbd5 100644 --- a/test/doc/minus.cpp +++ b/test/doc/minus.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::minus; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/nearest.cpp b/test/doc/nearest.cpp index 07b08a3f..6dd43a5a 100644 --- a/test/doc/nearest.cpp +++ b/test/doc/nearest.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::nearest; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << nearest(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << nearest(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << nearest(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << nearest(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << nearest(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << nearest(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << nearest(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/oneminus.cpp b/test/doc/oneminus.cpp index b9ec4394..041a29f3 100644 --- a/test/doc/oneminus.cpp +++ b/test/doc/oneminus.cpp @@ -5,11 +5,11 @@ int main() { using kyosu::oneminus; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; using wc_t = eve::wide>; using wq_t = eve::wide>; diff --git a/test/doc/proj.cpp b/test/doc/proj.cpp new file mode 100644 index 00000000..834d9b3a --- /dev/null +++ b/test/doc/proj.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +int main() +{ + using kyosu::proj; + using kyosu::complex_t; + using kyosu::quaternion_t; + auto inf = eve::inf(eve::as()); + + std::cout << "Real: \n"; + std::cout << " " << 72.9f << " -> " << proj(72.9f) << "\n"; + std::cout << " " << inf << " -> " << proj(inf) << "\n"; + std::cout << " " << -inf << " -> " << proj(-inf) << "\n"; + + std::cout << "Complex: \n"; + std::cout << " " << kyosu::complex_t(3.5f,-2.9f) << " -> " << proj(kyosu::complex_t(3.5f,-2.9f)) << "\n"; + std::cout << " " << kyosu::complex_t(3.5f,inf) << " -> " << proj(kyosu::complex_t(3.5f,inf)) << "\n"; + std::cout << " " << kyosu::complex_t(3.5f,-inf) << " -> " << proj(kyosu::complex_t(3.5f,-inf)) << "\n"; + std::cout << " " << kyosu::complex_t(inf,-2.9f) << " -> " << proj(kyosu::complex_t(inf,-2.9f)) << "\n"; + std::cout << " " << kyosu::complex_t(inf, 2.9f) << " -> " << proj(kyosu::complex_t(inf,2.9f)) << "\n"; + + std::cout << "Quaternion: \n"; + std::cout << " " << kyosu::quaternion_t(1.f,2.f,3.f,4.f) << " -> " << proj(kyosu::quaternion_t(1.f,2.f,3.f,4.f)) << "\n"; + std::cout << " " << kyosu::quaternion_t(-1.f,inf,3.f,-4.f) << " -> " << proj(kyosu::quaternion_t(-1.f,inf,3.f,-4.f)) << "\n"; + + using T = eve::wide < float, eve::fixed < 2 > >; + using c_t = kyosu::quaternion_t; + auto g = c_t(32, 44, 55, 34); + std::cout << g << std::endl; + return 0; +} diff --git a/test/doc/real.cpp b/test/doc/real.cpp index 1549085f..3360aad4 100644 --- a/test/doc/real.cpp +++ b/test/doc/real.cpp @@ -5,8 +5,8 @@ int main() { using kyosu::real; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; float f = 72.9f; @@ -15,19 +15,19 @@ int main() std::cout << f << "\n"; std::cout << "Complex: "; - auto z = complex(3.5f,-2.9f); + auto z = kyosu::complex_t(3.5f,-2.9f); std::cout << z << " -> " << real(z) << " => "; real(z) = 11.23f; std::cout << z << "\n"; std::cout << "Quaternion: "; - auto q = quaternion(1.,2.,3.,4.); + auto q = kyosu::quaternion_t(1.,2.,3.,4.); std::cout << q << " -> " << real(q) << " => "; real(q) = 42.7; std::cout << q << "\n"; std::cout << "SIMD: "; - eve::wide, eve::fixed<2>> wz(complex(1.3,-3.7)); + eve::wide, eve::fixed<2>> wz(kyosu::complex_t(1.3,-3.7)); std::cout << wz << " -> " << real(wz) << " => "; real(wz) = eve::wide>{13.37,63.24}; std::cout << wz << "\n"; diff --git a/test/doc/reldist.cpp b/test/doc/reldist.cpp index 20e7a96c..bd21baf4 100644 --- a/test/doc/reldist.cpp +++ b/test/doc/reldist.cpp @@ -5,14 +5,14 @@ int main() { using kyosu::reldist; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; using e_t = float; - using c_t = complex; - using q_t = quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using we_t = eve::wide>; - using wc_t = eve::wide, eve::fixed<2>>; - using wq_t = eve::wide, eve::fixed<2>>; + using wc_t = eve::wide, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; std::cout << "Real: "<< "\n"; e_t e0(1); diff --git a/test/doc/sqr.cpp b/test/doc/sqr.cpp index c68c919c..6129b2c3 100644 --- a/test/doc/sqr.cpp +++ b/test/doc/sqr.cpp @@ -5,26 +5,26 @@ int main() { using kyosu::sqr; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "<< "\n"; std::cout << 72.9f << " -> " << sqr(72.9f) << "\n"; std::cout << 72.9f << " -> " << (72.9f)*(72.9f) << "\n"; std::cout << "Complex: "<< "\n"; - std::cout << complex(3.5f,-2.9f) << " -> " << sqr(complex(3.5f,-2.9f)) << "\n"; - std::cout << complex(3.5f,-2.9f) << " -> " << (complex(3.5f,-2.9f))*(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << sqr(kyosu::complex_t(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << (kyosu::complex_t(3.5f,-2.9f))*(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "<< "\n"; - std::cout << quaternion(1.1,2.2,-3.3,4.4) << " -> " << sqr(quaternion(1.1,2.2,-3.3,4.4)) << "\n"; - std::cout << quaternion(1.1,2.2,-3.3,4.4) << " -> " << (quaternion(1.1,2.2,-3.3,4.4))*(quaternion(1.1,2.2,-3.3,4.4))<< "\n"; + std::cout << kyosu::quaternion_t(1.1,2.2,-3.3,4.4) << " -> " << sqr(kyosu::quaternion_t(1.1,2.2,-3.3,4.4)) << "\n"; + std::cout << kyosu::quaternion_t(1.1,2.2,-3.3,4.4) << " -> " << (kyosu::quaternion_t(1.1,2.2,-3.3,4.4))*(kyosu::quaternion_t(1.1,2.2,-3.3,4.4))<< "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << sqr(wc_t(complex(1.3,-3.7))) << "\n"; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << (wc_t(complex(1.3,-3.7)))*(wc_t(complex(1.3,-3.7)))<< "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << sqr(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << (wc_t(kyosu::complex_t(1.3,-3.7)))*(wc_t(kyosu::complex_t(1.3,-3.7)))<< "\n"; return 0; } diff --git a/test/doc/tgamma.cpp b/test/doc/tgamma.cpp new file mode 100644 index 00000000..0a20241f --- /dev/null +++ b/test/doc/tgamma.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + wide_ft ref2 = { 0.0, 1.0, 2.0, 3.0}; + auto zc = kyosu::complex_t(ref1, imf1); + + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> tgamma(zc) = " << kyosu::tgamma(zc)<< std::endl + << "-> tgamma(ref2) = " << kyosu::tgamma(ref2) << std::endl; + + return 0; +} diff --git a/test/doc/to_complex.cpp b/test/doc/to_complex.cpp new file mode 100644 index 00000000..f2a241e6 --- /dev/null +++ b/test/doc/to_complex.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main() +{ + using kyosu::complex; + + std::cout << "Real: "; + std::cout << "complex(72.9f) -> " << complex(72.9f) << "\n"; + + std::cout << "Complex: "; + std::cout << "complex(3.5f, 2.9f) -> " << complex(3.5f,-2.9f) << "\n"; + + std::cout << "SIMD complex: "; + using w_t = eve::wide>; + w_t a(3.5f,-2.9f), b(1.0, -3.0); + std::cout << "complex(a, b) -> " << complex(a, b) << "\n"; + + return 0; +} diff --git a/test/doc/to_complex.hpp b/test/doc/to_complex.hpp new file mode 100644 index 00000000..14606bf8 --- /dev/null +++ b/test/doc/to_complex.hpp @@ -0,0 +1,26 @@ +#include +#include +#include + +int main() +{ + using kyosu::abs; + using kyosu::as_complex_t; + using kyosu::as_quaternion_t; + + std::cout << "Real: "; + std::cout << 72.9f << " -> " << complex(72.9f) << "\n"; + + std::cout << "Complex: "; + std::cout << (3.5f,-2.9f) << " -> " << complex(3.5f,-2.9f) << "\n"; + + std::cout << "Quaternion: "; + std::cout << (1.,2.,3.,4.) << " -> " << quaternion(1.,2.,3.,4.) << "\n"; + + std::cout << "SIMD: "; + using w_t = eve::wide>; + w_t a(3.5f,-2.9f), b(1.0, -3.0); + std::cout << complex(a, b) << " -> " << complex(a, b) << "\n"; + + return 0; +} diff --git a/test/doc/to_quaternion.cpp b/test/doc/to_quaternion.cpp new file mode 100644 index 00000000..1112e8f2 --- /dev/null +++ b/test/doc/to_quaternion.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +int main() +{ + using kyosu::complex; + using kyosu::quaternion; + + std::cout << "Real: "; + std::cout << "quaternion(72.9f) -> " << quaternion(72.9f) << "\n"; + + std::cout << "Complex: "; + std::cout << "quaternion(3.5f, 2.9f) -> " << quaternion(3.5f,-2.9f) << "\n"; + + std::cout << "Quaternion: "; + std::cout << "quaternion(1.0, 2.0, 3.0, 4.0) -> " << quaternion(1.,2.,3.,4.) << "\n"; + auto c0 = complex(1.0, 2.3); + auto c1 = complex(-4.0, -1.5); + std::cout << "c0 = " << c0 << "\n"; + std::cout << "c1 = " << c1 << "\n"; + std::cout << "quaternion(c0, c1) -> " << quaternion(c0, c1) << "\n"; + + std::cout << "SIMD quaternion: \n"; + using w_t = eve::wide>; + w_t a(3.5f,-2.9f), b(1.0, -3.0); + std::cout << "a = " << a << "\n"; + std::cout << "b = " << b << "\n"; + std::cout << "quaternion(a, b) -> " << quaternion(a, b) << "\n"; + + return 0; +} diff --git a/test/doc/trunc.cpp b/test/doc/trunc.cpp index 8f27eb10..313845ea 100644 --- a/test/doc/trunc.cpp +++ b/test/doc/trunc.cpp @@ -5,21 +5,21 @@ int main() { using kyosu::trunc; - using kyosu::complex; - using kyosu::quaternion; + using kyosu::complex_t; + using kyosu::quaternion_t; std::cout << "Real: "; std::cout << 72.9f << " -> " << trunc(72.9f) << "\n"; std::cout << "Complex: "; - std::cout << complex(3.5f,-2.9f) << " -> " << trunc(complex(3.5f,-2.9f)) << "\n"; + std::cout << kyosu::complex_t(3.5f,-2.9f) << " -> " << trunc(kyosu::complex_t(3.5f,-2.9f)) << "\n"; std::cout << "Quaternion: "; - std::cout << quaternion(1.,2.,3.,4.) << " -> " << trunc(quaternion(1.,2.,3.,4.)) << "\n"; + std::cout << kyosu::quaternion_t(1.,2.,3.,4.) << " -> " << trunc(kyosu::quaternion_t(1.,2.,3.,4.)) << "\n"; std::cout << "SIMD: "; - using wc_t = eve::wide, eve::fixed<2>>; - std::cout << wc_t(complex(1.3,-3.7)) << " -> " << trunc(wc_t(complex(1.3,-3.7))) << "\n"; + using wc_t = eve::wide, eve::fixed<2>>; + std::cout << wc_t(kyosu::complex_t(1.3,-3.7)) << " -> " << trunc(wc_t(kyosu::complex_t(1.3,-3.7))) << "\n"; return 0; } diff --git a/test/doc/zeta.cpp b/test/doc/zeta.cpp new file mode 100644 index 00000000..6e3924db --- /dev/null +++ b/test/doc/zeta.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() +{ + using wide_ft = eve::wide >; + wide_ft ref1 = { 3.0f, 2.0f, 1.0f, 0.5f}; + wide_ft imf1 = { 2.0f , -1.0, -5.0, 0.0}; + auto zc = kyosu::complex_t(ref1, imf1); + std::cout + << "---- simd" << std::endl + << "<- zc = " << zc << std::endl + << "-> zeta(zc) = " << kyosu::zeta(zc) << std::endl + << "-> zeta(ref1) = " << kyosu::zeta(ref1) << std::endl; + return 0; +} diff --git a/test/integration/main.cpp b/test/integration/main.cpp index a0387aae..d251b63e 100644 --- a/test/integration/main.cpp +++ b/test/integration/main.cpp @@ -3,7 +3,6 @@ int main() { - std::cout << kyosu::complex{3.4f,6.7f} << "\n"; - std::cout << kyosu::quaternion{2,5,8,0.1} << "\n"; - std::cout << kyosu::octonion{8,7,6,5,4,3,2,1} << "\n"; + std::cout << kyosu::complex(3.4f,6.7f) << "\n"; + std::cout << kyosu::quaternion(2.0,5.0,8.0,0.1) << "\n"; } diff --git a/test/test.hpp b/test/test.hpp index a6a8a262..e8b32604 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -52,12 +52,12 @@ namespace kyosu >; using real_types = tts::concatenate_t; - template struct complex_t; - template struct complex_t> { using types_list = tts::types...>; }; + template struct tts_complex_t; + template struct tts_complex_t> { using types_list = tts::types...>; }; - using scalar_complex_types = complex_t; - using simd_complex_types = complex_t; - using complex_types = complex_t; + using scalar_complex_types = tts_complex_t; + using simd_complex_types = tts_complex_t; + using complex_types = tts_complex_t; } //================================================================================================== @@ -97,16 +97,6 @@ namespace tts using types_list = typename make::type; }; - template double relative_distance(T const &l, T const &r) - { - return kyosu::reldist(l,r); - } - - template double absolute_distance(T const &l, T const &r) - { - return kyosu::dist(l, r); - } - template inline bool is_ieee_equal(T const &l, T const &r) { return kumi::all_of(kumi::map( [](auto a, auto b) { return tts::is_ieee_equal(a,b); }, l, r)); @@ -122,6 +112,22 @@ namespace tts return check; } + template double relative_distance(T const &l, T const &r) + { + if(is_ieee_equal(l, r)) + return 0.0; + else + return kyosu::reldist(l,r); + } + + template double absolute_distance(T const &l, T const &r) + { + if(is_ieee_equal(l, r)) + return 0.0; + else + return kyosu::dist(l, r); + } + template inline double ulp_distance(eve::wide const &l, eve::wide const &r) { diff --git a/test/unit/complex/acos.cpp b/test/unit/complex/acos.cpp index fe51b494..43e954fe 100644 --- a/test/unit/complex/acos.cpp +++ b/test/unit/complex/acos.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of acos on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of acos on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of acos on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::acos(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::acos(ke_t{a0,a1}), e, 1.0e-6); @@ -51,7 +51,7 @@ TTS_CASE_TPL( "Check acos lilits", kyosu::real_types) (tts::type) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; const int N = 22; diff --git a/test/unit/complex/acosh.cpp b/test/unit/complex/acosh.cpp index 913310f4..8aed7b60 100644 --- a/test/unit/complex/acosh.cpp +++ b/test/unit/complex/acosh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of acosh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of acosh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of acosh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::acosh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::acosh(ke_t{a0,a1}), e, 1.0e-6); @@ -51,7 +51,7 @@ TTS_CASE_TPL( "Check acosh lilits", kyosu::real_types) (tts::type) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; const int N = 22; diff --git a/test/unit/complex/acospi.cpp b/test/unit/complex/acospi.cpp index 1c3ade37..14e8932e 100644 --- a/test/unit/complex/acospi.cpp +++ b/test/unit/complex/acospi.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH( "Check behavior of acospi on scalar" { auto e = a0[i]; auto f = a1[i]; - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::acospi(z), inv_pi*kyosu::acos(z), 1.0e-6); } }; @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of acospi on wide" (T const& a0, T const& a1 ) { auto inv_pi = eve::inv_pi(eve::as(a0)); - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acospi(z), inv_pi*kyosu::acos(z), 1.0e-6); }; diff --git a/test/unit/complex/acot.cpp b/test/unit/complex/acot.cpp index 47c0f292..32e4e845 100644 --- a/test/unit/complex/acot.cpp +++ b/test/unit/complex/acot.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of acot on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::acot(z), kyosu::atan(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of acot on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acot(z), kyosu::atan(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/acoth.cpp b/test/unit/complex/acoth.cpp index 9873b445..57f11557 100644 --- a/test/unit/complex/acoth.cpp +++ b/test/unit/complex/acoth.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of acoth on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::acoth(z), kyosu::atanh(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of acoth on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acoth(z), kyosu::atanh(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/acotpi.cpp b/test/unit/complex/acotpi.cpp index 99dfc1e7..91398859 100644 --- a/test/unit/complex/acotpi.cpp +++ b/test/unit/complex/acotpi.cpp @@ -19,7 +19,7 @@ TTS_CASE_WITH ( "Check behavior of acotpi on scalar" { for(size_t i = 0; i < a0.size(); ++i) { - auto z = kyosu::to_complex(a0[i], a1[i]); + auto z = kyosu::complex(a0[i], a1[i]); TTS_RELATIVE_EQUAL(kyosu::acotpi(z), kyosu::atanpi(kyosu::rec(z)), 1.0e-5); } }; @@ -31,6 +31,6 @@ TTS_CASE_WITH( "Check behavior of acot on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acotpi(z), kyosu::atanpi(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/acsc.cpp b/test/unit/complex/acsc.cpp index 2ec7fd26..f2b0d134 100644 --- a/test/unit/complex/acsc.cpp +++ b/test/unit/complex/acsc.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of acsc on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::acsc(z), kyosu::asin(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of acsc on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acsc(z), kyosu::asin(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/acsch.cpp b/test/unit/complex/acsch.cpp index ec1f4d79..485fe674 100644 --- a/test/unit/complex/acsch.cpp +++ b/test/unit/complex/acsch.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of acsch on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::acsch(z), kyosu::asinh(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of acsch on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acsch(z), kyosu::asinh(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/acscpi.cpp b/test/unit/complex/acscpi.cpp index 4eb9877c..096751bd 100644 --- a/test/unit/complex/acscpi.cpp +++ b/test/unit/complex/acscpi.cpp @@ -19,7 +19,7 @@ TTS_CASE_WITH ( "Check behavior of acscpi on scalar" { for(size_t i = 0; i < a0.size(); ++i) { - auto z = kyosu::to_complex(a0[i], a1[i]); + auto z = kyosu::complex(a0[i], a1[i]); TTS_RELATIVE_EQUAL(kyosu::acscpi(z), kyosu::asinpi(kyosu::rec(z)), 1.0e-5); } }; @@ -31,6 +31,6 @@ TTS_CASE_WITH( "Check behavior of acsc on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::acscpi(z), kyosu::asinpi(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/add.cpp b/test/unit/complex/add.cpp index 93eead13..907a2d95 100644 --- a/test/unit/complex/add.cpp +++ b/test/unit/complex/add.cpp @@ -11,14 +11,14 @@ TTS_CASE_TPL( "Check complex::add", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; using eve::add; auto fill_r = [](auto i, auto) { return T(1+i); }; auto fill_i = [](auto i, auto) { return T(1)/(1+i); }; - auto fill = [](auto i, auto) { return kyosu::complex(T(1+i),T(1)/(1+i)); }; + auto fill = [](auto i, auto) { return kyosu::complex_t(T(1+i),T(1)/(1+i)); }; c_t z_s1(T{1.234}, T{5.678}), z_s2(T{2.468}, T{1.357}); wc_t z_v1(fill), z_v2(fill_i,fill_r); @@ -63,13 +63,13 @@ TTS_CASE_TPL( "Check complex::add", kyosu::scalar_real_types) TTS_CASE_TPL( "Check complex::operator+ ", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; auto fill_r = [](auto i, auto) { return T(1+i); }; auto fill_i = [](auto i, auto) { return T(1)/(1+i); }; - auto fill = [](auto i, auto) { return kyosu::complex(T(1+i),T(1)/(1+i)); }; + auto fill = [](auto i, auto) { return kyosu::complex_t(T(1+i),T(1)/(1+i)); }; c_t z_s1(T{1.234}, T{5.678}), z_s2(T{2.468}, T{1.357}); wc_t z_v1(fill), z_v2(fill_i,fill_r); diff --git a/test/unit/complex/arg.cpp b/test/unit/complex/arg.cpp index 9effb4d5..ce490267 100644 --- a/test/unit/complex/arg.cpp +++ b/test/unit/complex/arg.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH( "Check behavior of arg on scalar" auto e = a0[i]; auto f = a1[i]; - TTS_RELATIVE_EQUAL(kyosu::arg(kyosu::to_complex(e, f)), eve::atan2(f, e), 1.0e-6); + TTS_RELATIVE_EQUAL(kyosu::arg(kyosu::complex(e, f)), eve::atan2(f, e), 1.0e-6); } }; @@ -32,5 +32,5 @@ TTS_CASE_WITH( "Check behavior of arg on wide" ) (T const& a0, T const& a1 ) { - TTS_RELATIVE_EQUAL(kyosu::arg(kyosu::to_complex(a0,a1)), eve::atan2(a1, a0), 1.0e-6); + TTS_RELATIVE_EQUAL(kyosu::arg(kyosu::complex(a0,a1)), eve::atan2(a1, a0), 1.0e-6); }; diff --git a/test/unit/complex/asec.cpp b/test/unit/complex/asec.cpp index 5cbfacb6..2933f110 100644 --- a/test/unit/complex/asec.cpp +++ b/test/unit/complex/asec.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of asec on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::asec(z), kyosu::acos(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of asec on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::asec(z), kyosu::acos(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/asech.cpp b/test/unit/complex/asech.cpp index 87e97779..4104ae30 100644 --- a/test/unit/complex/asech.cpp +++ b/test/unit/complex/asech.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of asech on scalar" { for(auto f : a1) { - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::asech(z), kyosu::acosh(kyosu::rec(z)), 1.0e-50); } } @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of asech on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::asech(z), kyosu::acosh(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/asecpi.cpp b/test/unit/complex/asecpi.cpp index 0b0ef736..3896e850 100644 --- a/test/unit/complex/asecpi.cpp +++ b/test/unit/complex/asecpi.cpp @@ -19,7 +19,7 @@ TTS_CASE_WITH ( "Check behavior of acscpi on scalar" { for(size_t i = 0; i < a0.size(); ++i) { - auto z = kyosu::to_complex(a0[i], a1[i]); + auto z = kyosu::complex(a0[i], a1[i]); TTS_RELATIVE_EQUAL(kyosu::asecpi(z), kyosu::acospi(kyosu::rec(z)), 1.0e-5); } }; @@ -31,6 +31,6 @@ TTS_CASE_WITH( "Check behavior of acsc on wide" ) (T const& a0, T const& a1) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::asecpi(z), kyosu::acospi(kyosu::rec(z)), 1.0e-5); }; diff --git a/test/unit/complex/asin.cpp b/test/unit/complex/asin.cpp index 7570394f..accb40cb 100644 --- a/test/unit/complex/asin.cpp +++ b/test/unit/complex/asin.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of asin on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of asin on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of asin on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::asin(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::asin(ke_t{a0,a1}), e, 1.0e-6); @@ -57,7 +57,7 @@ TTS_CASE_TPL( "Check asin lilits", kyosu::scalar_real_types) (tts::type) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; const int N = 12; @@ -99,7 +99,7 @@ TTS_CASE_TPL( "Check corner casesof eve::asin", kyosu::scalar_real_types) (tts::type) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; const int N = 12; diff --git a/test/unit/complex/asinh.cpp b/test/unit/complex/asinh.cpp index ad32ee66..7dc5d331 100644 --- a/test/unit/complex/asinh.cpp +++ b/test/unit/complex/asinh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of asinh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of asinh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of asinh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::asinh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::asinh(ke_t{a0,a1}), e, 1.0e-5); @@ -51,7 +51,7 @@ TTS_CASE_TPL( "Check asinh lilits", kyosu::real_types) (tts::type) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; diff --git a/test/unit/complex/asinpi.cpp b/test/unit/complex/asinpi.cpp index 60d27158..eb202118 100644 --- a/test/unit/complex/asinpi.cpp +++ b/test/unit/complex/asinpi.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH( "Check behavior of asinpi on scalar" { auto e = a0[i]; auto f = a1[i]; - auto z = kyosu::to_complex(e, f); + auto z = kyosu::complex(e, f); TTS_RELATIVE_EQUAL(kyosu::asinpi(z), inv_pi*kyosu::asin(z), 1.0e-6); } }; @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of asinpi on wide" (T const& a0, T const& a1 ) { auto inv_pi = eve::inv_pi(eve::as(a0)); - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::asinpi(z), inv_pi*kyosu::asin(z), 1.0e-6); }; diff --git a/test/unit/complex/atanh.cpp b/test/unit/complex/atanh.cpp index 6264724a..7de7ba90 100644 --- a/test/unit/complex/atanh.cpp +++ b/test/unit/complex/atanh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of atanh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of atanh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of atanh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::atanh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::atanh(ke_t{a0,a1}), e, 1.0e-6); @@ -59,7 +59,7 @@ TTS_CASE_TPL( "Check corner casesof eve::atanh", kyosu::scalar_real_types) if constexpr(spy::operating_system != spy::macos_) { using e_t = T; - auto tcx = kyosu::to_complex; + auto tcx = kyosu::complex; using c_t = decltype(tcx(e_t(0))); using eve::as; const int N = 16; diff --git a/test/unit/complex/atanpi.cpp b/test/unit/complex/atanpi.cpp index 1e17f823..9b9fa91b 100644 --- a/test/unit/complex/atanpi.cpp +++ b/test/unit/complex/atanpi.cpp @@ -21,7 +21,7 @@ TTS_CASE_WITH ( "Check behavior of atanpi on scalar" auto inv_pi = eve::inv_pi(eve::as()); for(size_t i = 0; i < a0.size(); ++i) { - auto z = kyosu::to_complex(a0[i], a1[i]); + auto z = kyosu::complex(a0[i], a1[i]); TTS_RELATIVE_EQUAL(kyosu::atanpi(z), inv_pi*kyosu::atan(z), 1.0e-5); } }; @@ -34,6 +34,6 @@ TTS_CASE_WITH( "Check behavior of atan on wide" (T const& a0, T const& a1) { auto inv_pi = eve::inv_pi(eve::as(a0)); - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_RELATIVE_EQUAL(kyosu::atanpi(z), inv_pi*kyosu::atan(z), 1.0e-5); }; diff --git a/test/unit/complex/beta.cpp b/test/unit/complex/beta.cpp new file mode 100644 index 00000000..29e17b9f --- /dev/null +++ b/test/unit/complex/beta.cpp @@ -0,0 +1,43 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check log_abs_gamma", kyosu::scalar_real_types) +(tts::type) +{ + using z_t = kyosu::complex_t; + z_t i = kyosu::complex(T(0), T(1)); + z_t o = kyosu::complex(T(1), T(0)); + z_t h = kyosu::complex(T(0.5), T(0)); + TTS_RELATIVE_EQUAL(kyosu::beta(i, i), z_t(-2.376146124821733192409666, -2.63956852027813624177239618242498), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::beta(i, h), z_t(1.0794242492709257801356755, -1.41003240566416083828875193632476), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::beta(i, T(0.5)), z_t(1.0794242492709257801356755, -1.41003240566416083828875193632476), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::beta(i, o), -i , 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::beta(o, T(0.5)), z_t(2) , 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::beta(i, 2*i), z_t(-2.891319789417896828442673, -1.04053537453220827379062834820451), 1.0e-5); +}; + + +TTS_CASE_WITH ( "Check behavior of pow on wide" + , kyosu::simd_real_types + , tts::generate ( tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + ) + ) + (T const& a0, T const& a1, T const& a2, T const& a3 ) +{ + auto a = kyosu::complex(a0, a1); + auto b = kyosu::complex(a2, a3); + + auto mybeta = [](auto a, auto b){return kyosu::tgamma(a)*kyosu::tgamma(b)/kyosu::tgamma(a+b); }; + TTS_IEEE_EQUAL(kyosu::beta(a, b), mybeta(a, b)); +}; diff --git a/test/unit/complex/constructors.cpp b/test/unit/complex/constructors.cpp index 9b97a86f..2bd947e2 100644 --- a/test/unit/complex/constructors.cpp +++ b/test/unit/complex/constructors.cpp @@ -17,31 +17,31 @@ TTS_CASE_TPL( "Check complex constructor from constants", kyosu::scalar_real_typ auto wpi = w_t(spi); auto wo = w_t(so); - kyosu::complex z_sd{}; + kyosu::complex_t z_sd{}; TTS_EQUAL( get<0>(z_sd), T{0}); TTS_EQUAL( get<1>(z_sd), T{0}); - kyosu::complex z_s0{spi}; + kyosu::complex_t z_s0{spi}; TTS_EQUAL( get<0>(z_s0), spi ); TTS_EQUAL( get<1>(z_s0), T{0}); - kyosu::complex z_ss{spi,so}; + kyosu::complex_t z_ss{spi,so}; TTS_EQUAL( get<0>(z_ss), spi); TTS_EQUAL( get<1>(z_ss), so ); - eve::wide> z_vd{}; + eve::wide> z_vd{}; TTS_EQUAL( get<0>(z_vd), w_t{0}); TTS_EQUAL( get<1>(z_vd), w_t{0}); - eve::wide> z_vs{wo,spi}; + eve::wide> z_vs{wo,spi}; TTS_EQUAL( get<0>(z_vs), wo ); TTS_EQUAL( get<1>(z_vs), wpi); - eve::wide> z_sv{spi,wo}; + eve::wide> z_sv{spi,wo}; TTS_EQUAL( get<0>(z_sv), wpi); TTS_EQUAL( get<1>(z_sv), wo ); - eve::wide> z_vv{wo,wpi}; + eve::wide> z_vv{wo,wpi}; TTS_EQUAL( get<0>(z_vv), wo ); TTS_EQUAL( get<1>(z_vv), wpi); }; @@ -53,12 +53,12 @@ TTS_CASE_TPL("Check complex constructor from lambda", kyosu::scalar_real_types) auto fill_r = [](auto i, auto) { return T(1+i); }; auto fill_i = [](auto i, auto) { return T(1)/(1+i); }; - auto fill = [](auto i, auto) { return kyosu::complex(T(1+i),T(1)/(1+i)); }; + auto fill = [](auto i, auto) { return kyosu::complex_t(T(1+i),T(1)/(1+i)); }; - eve::wide> z_l(fill); - eve::wide> z_ll(fill_r, fill_i); - eve::wide> z_lc(fill_r, T{1.25}); - eve::wide> z_cl(T{8.8},fill_i); + eve::wide> z_l(fill); + eve::wide> z_ll(fill_r, fill_i); + eve::wide> z_lc(fill_r, T{1.25}); + eve::wide> z_cl(T{8.8},fill_i); TTS_EQUAL( get<0>(z_l) , w_t(fill_r)); TTS_EQUAL( get<1>(z_l) , w_t(fill_i)); @@ -79,14 +79,14 @@ TTS_CASE_TPL("Check complex copy/assignment", kyosu::scalar_real_types) auto wpi = w_t(spi); auto wo = w_t(so); - kyosu::complex z_s{spi,so}; + kyosu::complex_t z_s{spi,so}; auto z_sc{z_s}; - kyosu::complex z_sa; + kyosu::complex_t z_sa; z_sa = z_s; - eve::wide> z_v{wo,wpi}; + eve::wide> z_v{wo,wpi}; auto z_vc{z_v}; - eve::wide> z_va; + eve::wide> z_va; z_va = z_v; TTS_EQUAL ( z_sc, z_s ); diff --git a/test/unit/complex/cos.cpp b/test/unit/complex/cos.cpp index 38ce06f9..6871d676 100644 --- a/test/unit/complex/cos.cpp +++ b/test/unit/complex/cos.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of cos on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of cos on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of cos on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::cos(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::cos(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/cosh.cpp b/test/unit/complex/cosh.cpp index 2b00ac7f..339b1d1e 100644 --- a/test/unit/complex/cosh.cpp +++ b/test/unit/complex/cosh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of cosh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of cosh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of cosh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::cosh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::cosh(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/cot.cpp b/test/unit/complex/cot.cpp index 39329e86..0dc10a28 100644 --- a/test/unit/complex/cot.cpp +++ b/test/unit/complex/cot.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of cot on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of cot on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of cot on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return kyosu::rec(cv(std::tan(c_t(a0.get(i), a1.get(i))))); }); TTS_RELATIVE_EQUAL(kyosu::cot(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/coth.cpp b/test/unit/complex/coth.cpp index c3c6c998..8cc625d4 100644 --- a/test/unit/complex/coth.cpp +++ b/test/unit/complex/coth.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of coth on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of coth on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of coth on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return kyosu::rec(cv(std::tanh(c_t(a0.get(i), a1.get(i))))); }); TTS_RELATIVE_EQUAL(kyosu::coth(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/csc.cpp b/test/unit/complex/csc.cpp index a97ac299..8612ac4d 100644 --- a/test/unit/complex/csc.cpp +++ b/test/unit/complex/csc.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of csc on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of csc on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of csc on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return kyosu::rec(cv(std::sin(c_t(a0.get(i), a1.get(i))))); }); TTS_RELATIVE_EQUAL(kyosu::csc(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/digamma.cpp b/test/unit/complex/digamma.cpp new file mode 100644 index 00000000..3963df3e --- /dev/null +++ b/test/unit/complex/digamma.cpp @@ -0,0 +1,34 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check log_abs_gamma", kyosu::real_types) +(tts::type) +{ + using e_t = T; + using z_t = kyosu::complex_t; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + z_t one = tcx(1, 0); + z_t zer = tcx(0, 0); + z_t two = tcx(2, 0); + z_t three = tcx(3, 0); + z_t naninf = tcx(eve::nan(eve::as()), eve::inf(eve::as())); + TTS_IEEE_EQUAL( kyosu::digamma(zer), naninf); + TTS_IEEE_EQUAL( kyosu::digamma(-zer),naninf); + TTS_RELATIVE_EQUAL( kyosu::real(kyosu::digamma(one)), e_t(-0.577215664901532860606512090082402431042159335939923598805767234), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::real(kyosu::digamma(two)), e_t(0.4227843350984671393934879099175975689578406640600764011942327651), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::real(kyosu::digamma(three)), e_t(0.9227843350984671393934879099175975689578406640600764011942327651), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::real(kyosu::digamma(tcx(-3.5, 0))), e_t(1.3888709263595289015114046193821968137592213477205182739052536985), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::real(kyosu::digamma(tcx(-3.75, 0))), e_t(-1.692388598311330343154465211031748512432179503643307206720214624), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::digamma(tcx(1, 1)) , tcx(9.4650320622476947e-02, 1.076674047468581174e+00), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::digamma(tcx(-1, 1)) , tcx(0.594650320622477, 2.576674047468582), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::digamma(tcx(1, -1)) , tcx(9.4650320622476947e-02, -1.076674047468581174e+00), 1.0e-4); + TTS_RELATIVE_EQUAL( kyosu::digamma(tcx(-1, -1)) , tcx(0.594650320622477, -2.576674047468582), 1.0e-4);; +}; diff --git a/test/unit/complex/div.cpp b/test/unit/complex/div.cpp index ac62228d..c5bcdc5c 100644 --- a/test/unit/complex/div.cpp +++ b/test/unit/complex/div.cpp @@ -11,7 +11,7 @@ TTS_CASE_TPL( "Check complex::div", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; using eve::div; @@ -63,7 +63,7 @@ TTS_CASE_TPL( "Check complex::div", kyosu::scalar_real_types) TTS_CASE_TPL( "Check complex::operator/", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; diff --git a/test/unit/complex/erf.cpp b/test/unit/complex/erf.cpp new file mode 100644 index 00000000..f85ae98a --- /dev/null +++ b/test/unit/complex/erf.cpp @@ -0,0 +1,233 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check corner cases of erf", kyosu::real_types) +(tts::type) +{ + using e_t = T; + auto tcx = kyosu::complex; + using c_t = decltype(tcx(e_t(0))); + using eve::as; + const int N = 18; + auto zer = eve::zero(as()); + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto one = eve::one(as()); + auto h = eve::half(as()); + std::array inputs = + { + tcx(zer,zer), //0 + tcx(zer,inf), //1 + tcx(zer,nan), //2 + tcx(one,inf), //3 + tcx(one,nan), //4 + tcx(inf,zer), //5 + tcx(inf,one), //6 + tcx(inf,inf), //7 + tcx(inf,nan), //8 + tcx(nan,zer), //9 + tcx(nan,one), //10 + tcx(nan,nan), //11 + tcx(h, zer ), //12 + tcx(zer, h ), //13 + tcx(e_t(4e-2), one), //14 + tcx(e_t(4e-2), e_t(1e-3)), //15 + tcx(e_t(-4e-2), one), //16 + tcx(e_t(-4e-2), e_t(1e-3)) //17 + }; + + std::array results = + { + tcx(zer,zer), //0 + tcx(zer, inf), //1 + tcx(zer,nan), //2 + tcx(nan, nan), //3 + tcx(nan,nan), //4 + tcx(one,zer), //5 + tcx(one,zer), //6 + tcx(nan, nan), //7 + tcx(nan,nan), //8 + tcx(nan,zer), //9 + tcx(nan,nan), //10 + tcx(nan,nan), //11 + tcx(e_t(5.204998778130465187e-01), zer), //12 + tcx(zer, e_t(6.14952094696510909e-01)), //13 + tcx(e_t(1.224939980392529826e-01), e_t(1.645524692691958002e+00)), //14 + tcx(e_t(4.511115120815541862e-02), e_t(1.126575578306994625e-03)), //15 + tcx(e_t(-1.224939980392529826e-01), e_t(1.645524692691958002e+00)),//16 + tcx(e_t(-4.511115120815541862e-02), e_t(1.126575578306994625e-03)) //17 + }; + using kyosu::conj; + using kyosu::erf; + for(int i=0; i < N; ++i) + { +// if (i < 12) +// TTS_IEEE_EQUAL(erf(inputs[i]), results[i]) << "i = " << i << " <- " << inputs[i] << "\n"; +// else + TTS_RELATIVE_EQUAL(erf(inputs[i]), results[i], 1.0e-4) << "i = " << i << "\n"; + TTS_IEEE_EQUAL(erf(conj(inputs[i])), conj(erf(inputs[i]))) << "i = " << i << "\n"; + } +}; + +TTS_CASE_TPL( "Check corner cases of erf", kyosu::scalar_real_types) + (tts::type) +{ + using e_t = T; + using c_t = decltype(kyosu::complex(e_t(0))); + using eve::as; + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i));}; + constexpr int NTST = 41; + std::array z = { + tcx(1,2), //0 + tcx(-1,2), //1 + tcx(1,-2), //2 + tcx(-1,-2), //3 + tcx(9,-28), //4 + tcx(21,-33), //5 + tcx(1e3,1e3), //6 + tcx(-3001,-1000), //7 + tcx(1e20, -1e19),//8 + tcx(5.1e-3, 1e-8), //9 + tcx(-4.9e-3, 4.95e-3), //10 + tcx(4.9e-3, 0.5), //11 + tcx(4.9e-4, -0.5e1), //12 + tcx(-4.9e-5, -0.5e2),//13 + tcx(5.1e-3, 0.5),//14 + tcx(5.1e-4, -0.5e1),//15 + tcx(-5.1e-5, -0.5e2),//16 + tcx(1e-6,2e-6),//17 + tcx(0,2e-6),//18 + tcx(0,2),//19 + tcx(0,20),//20 + tcx(0,200),//21 + tcx(inf,0),//22 + tcx(-inf,0),//23 + tcx(0,inf),//24 + tcx(0,-inf),//25 + tcx(inf,inf),//26 + tcx(inf,-inf),//27 + tcx(nan,nan),//28 + tcx(nan,0),//29 + tcx(0,nan),//30 + tcx(nan,inf),//31 + tcx(inf,nan),//32 + tcx(1e-3,nan),//33 + tcx(7e-2,7e-2),//34 + tcx(7e-2,-7e-4),//35 + tcx(-9e-2,7e-4),//36 + tcx(-9e-2,9e-2),//37 + tcx(-7e-4,9e-2), //38 + tcx(7e-2,0.9e-2), //39 + tcx(7e-2,1.1e-2) //40 + }; + std::array w = { // erf(z[i]), evaluated with Maple + tcx(-0.5366435657785650339917955593141927494421, + -5.049143703447034669543036958614140565553), //0 + tcx(0.5366435657785650339917955593141927494421, + -5.049143703447034669543036958614140565553), //1 + tcx(-0.5366435657785650339917955593141927494421, + 5.049143703447034669543036958614140565553), //2 + tcx(0.5366435657785650339917955593141927494421, + 5.049143703447034669543036958614140565553), //3 + tcx(0.3359473673830576996788000505817956637777e304, + -0.1999896139679880888755589794455069208455e304), //4 + tcx(0.3584459971462946066523939204836760283645e278, + 0.3818954885257184373734213077678011282505e280), //5 + tcx(0.9996020422657148639102150147542224526887, + 0.00002801044116908227889681753993542916894856), //6 + tcx(-1, 0),//7 + tcx(1, 0),//8 + tcx(0.005754683859034800134412990541076554934877, + 0.1128349818335058741511924929801267822634e-7),//9 + tcx(-0.005529149142341821193633460286828381876955, + 0.005585388387864706679609092447916333443570),//10 + tcx(0.007099365669981359632319829148438283865814, + 0.6149347012854211635026981277569074001219),//11 + tcx(0.3981176338702323417718189922039863062440e8, + -0.8298176341665249121085423917575122140650e10),//12 + tcx(-inf, + -inf), //13 + tcx(0.007389128308257135427153919483147229573895, + 0.6149332524601658796226417164791221815139), + tcx(0.4143671923267934479245651547534414976991e8, + -0.8298168216818314211557046346850921446950e10), + tcx(-inf, + -inf), + tcx(0.1128379167099649964175513742247082845155e-5, + 0.2256758334191777400570377193451519478895e-5), + tcx(0, + 0.2256758334194034158904576117253481476197e-5), + tcx(0, + 18.56480241457555259870429191324101719886), + tcx(0, + 0.1474797539628786202447733153131835124599e173), + tcx(0, + inf), + tcx(1,0), + tcx(-1,0), + tcx(0,inf), + tcx(0,-inf), + tcx(nan,nan), + tcx(nan,nan), + tcx(nan,nan), + tcx(nan,0), + tcx(0,nan), + tcx(nan,nan), + tcx(nan,nan), + tcx(nan,nan), + tcx(0.07924380404615782687930591956705225541145, + 0.07872776218046681145537914954027729115247), + tcx(0.07885775828512276968931773651224684454495, + -0.0007860046704118224342390725280161272277506), + tcx(-0.1012806432747198859687963080684978759881, + 0.0007834934747022035607566216654982820299469), + tcx(-0.1020998418798097910247132140051062512527, + 0.1010030778892310851309082083238896270340), + tcx(-0.0007962891763147907785684591823889484764272, + 0.1018289385936278171741809237435404896152), + tcx(0.07886408666470478681566329888615410479530, + 0.01010604288780868961492224347707949372245), + tcx(0.07886723099940260286824654364807981336591, + 0.01235199327873258197931147306290916629654) + }; + using kyosu::erf; + using kyosu::conj; + double ulps = 2000; + for(int i=0; i < NTST; ++i) + { + auto [er, ei] = erf(z[i]); + auto [wr, wi] = w[i]; + + TTS_ULP_EQUAL(er, wr, ulps) << "i " << i << " -> " << z[i] << " -> " < " < " << z[i] << " -> " < " < " << z[i] << " -> " < " < " << z[i] << " -> " < " <(T const& a0, T const& a1 ) +{ + auto z = kyosu::complex(a0, a1); + auto ez = kyosu::erf(z); + for(int i = 0; i != eve::cardinal_v; ++i) + { + TTS_RELATIVE_EQUAL(ez.get(i), kyosu::erf(z.get(i)), 1.0e-4); + } +}; diff --git a/test/unit/complex/erfcx.cpp b/test/unit/complex/erfcx.cpp new file mode 100644 index 00000000..74ded4a4 --- /dev/null +++ b/test/unit/complex/erfcx.cpp @@ -0,0 +1,78 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check corner cases of erfcx", kyosu::real_types) + (tts::type) +{ + using e_t = T; + using c_t = decltype(kyosu::complex(e_t(0))); + using eve::as; + const int N = 9; + auto zer = eve::zero(as()); + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto one = eve::one(as()); + auto half= eve::half(as()); + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i));}; + + + std::array z = + { + tcx(one,one), //0 + tcx(half,one), //1 + tcx(10, 10), //2 + tcx(65, zer), //3 + tcx(0.01, one), //4 + tcx(1.0e-4, 2), //5 + tcx(0.785398163397448, zer), //6 + tcx(inf,zer), //7 + tcx(nan,nan) //8 + }; + + std::array w = + { + tcx(3.04744205256913e-01, -2.08218938202832e-01 ), //0 + tcx(3.54900332867578e-01, -3.42871719131101e-01 ), //1 + tcx(2.82794674542325e-02, -2.81384332763369e-02 ), //2 + tcx(eve::erfcx(T(65)), zer), //tcx(8.67881291138928e-03, +0.00000000000000e+00 ), //3 + tcx(3.68702417397766e-01, -5.99851994495788e-01 ), //4 + tcx(1.83388101767463e-02, -3.40018889576381e-01 ), //5 + tcx(4.94195834537586e-01, +0.00000000000000e+00 ), //6 + tcx(eve::erfcx(inf), zer), //tcx(0.00000000000000e+00, +0.00000000000000e+00 ), //7 + tcx(nan , nan ) //8 + }; + using kyosu::erfcx; + using kyosu::conj; + double ulps = 2000; + for(int i=0; i < N; ++i) + { + auto [er, ei] = erfcx(z[i]); + auto [wr, wi] = w[i]; + + TTS_ULP_EQUAL(er, wr, ulps) << "i " << i << " -> " << z[i] << " -> " < " < " << z[i] << " -> " < " <(T const& a0, T const& a1 ) +{ + auto z = kyosu::complex(a0, a1); + auto ez = kyosu::erfcx(z); + for(int i = 0; i != eve::cardinal_v; ++i) + { + TTS_RELATIVE_EQUAL(ez.get(i), kyosu::erfcx(z.get(i)), 1.0e-4); + } +}; diff --git a/test/unit/complex/erfi.cpp b/test/unit/complex/erfi.cpp new file mode 100644 index 00000000..2dcc215a --- /dev/null +++ b/test/unit/complex/erfi.cpp @@ -0,0 +1,77 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check corner cases of erfi", kyosu::real_types) + (tts::type) +{ + using e_t = T; + using c_t = decltype(kyosu::complex(e_t(0))); + using eve::as; + const int N = 11; + auto zer = eve::zero(as()); + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto one = eve::one(as()); + auto half= eve::half(as()); + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i));}; + + std::array inputs = + { + tcx(one,one), //0 + tcx(half,one), //1 + tcx(10, 10), //2 + tcx(65, zer), //3* + tcx(0.01, one), //4 + tcx(1.0e-4, 2), //5 + tcx(0.785398163397448, zer), //6 + tcx(inf,zer), //7 + tcx(nan,nan), //8 + tcx(one, 0 ), //9 + tcx(half, 0) //10 + }; + + std::array results = + { + tcx(1.90453469237835e-01, 1.31615128169795e+00), //0 + tcx(1.87973467223383e-01, 9.50709728318957e-01), //1 + tcx(-1.09876846081940e-02, 9.61649374272475e-01), //2 + tcx(inf, 0.00000000000000e+00), //3 + tcx(4.15093659812155e-03, 8.42742304391298e-01), //4 + tcx(2.06669848718624e-06, 9.95322265432292e-01), //5 + tcx(1.10778360148748e+00, 0.00000000000000e+00), //6 + tcx(inf, 0.00000000000000e+00), //7 + tcx(nan, nan ), //8 + tcx(1.65042575879754e+00, 0.00000000000000e+00), //9 + tcx(6.14952094696511e-01, 0.00000000000000e+00) //10 + }; + + using kyosu::erfi; + using kyosu::conj; + for(int i=0; i < N; ++i) + { + TTS_RELATIVE_EQUAL(kyosu::erfi(inputs[i]), results[i], 1.0e-4) << "i " << i << " -> " << inputs[i] <<"\n"; + } +}; + +TTS_CASE_WITH( "Check behavior of erfi on wide" + , kyosu::simd_real_types + , tts::generate( tts::randoms(-10.0, 10.0) + , tts::randoms(-10.0, 10.0)) + ) + (T const& a0, T const& a1 ) +{ + auto z = kyosu::complex(a0, a1); + auto ez = kyosu::erfi(z); + for(int i = 0; i != eve::cardinal_v; ++i) + { + TTS_RELATIVE_EQUAL(ez.get(i), kyosu::erfi(z.get(i)), 1.0e-4); + } +}; diff --git a/test/unit/complex/erfi.hpp b/test/unit/complex/erfi.hpp new file mode 100644 index 00000000..39d68545 --- /dev/null +++ b/test/unit/complex/erfi.hpp @@ -0,0 +1,81 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check corner cases of erfcx", kyosu::real_types) + (tts::type) +{ + using e_t = T; + using c_t = decltype(kyosu::complex(e_t(0))); + using eve::as; + const int N = 9; + auto zer = eve::zero(as()); + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto one = eve::one(as()); + auto half= eve::half(as()); + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i));}; + + + std::array z = + { + tcx(one,one), //0 + tcx(half,one), //1 + tcx(10, 10), //2 + tcx(65, zer), //3 + tcx(0.01, one), //4 + tcx(1.0e-4, 2), //5 + tcx(0.785398163397448, zer), //6 + tcx(inf,zer), //7 + tcx(nan,nan) //8 + }; + + std::array w = + { + tcx(3.04744205256913e-01, -2.08218938202832e-01 ), //0 + tcx(3.54900332867578e-01, -3.42871719131101e-01 ), //1 + tcx(2.82794674542325e-02, -2.81384332763369e-02 ), //2 + tcx(eve::erfcx(T(65)), zer), //tcx(8.67881291138928e-03, +0.00000000000000e+00 ), //3 + tcx(3.68702417397766e-01, -5.99851994495788e-01 ), //4 + tcx(1.83388101767463e-02, -3.40018889576381e-01 ), //5 + tcx(4.94195834537586e-01, +0.00000000000000e+00 ), //6 + tcx(eve::erfcx(inf), zer), //tcx(0.00000000000000e+00, +0.00000000000000e+00 ), //7 + tcx(nan , nan ) //8 + }; + using kyosu::erfcx; + using kyosu::conj; + double ulps = 2000; + for(int i=0; i < N; ++i) + { + if (i < 21 || i > 34) + { + auto [er, ei] = erfcx(z[i]); + auto [wr, wi] = w[i]; + + TTS_ULP_EQUAL(er, wr, ulps) << "i " << i << " -> " << z[i] << " -> " < " < " << z[i] << " -> " < " <(T const& a0, T const& a1 ) +{ + auto z = kyosu::complex(a0, a1); + auto ez = kyosu::erfcx(z); + for(int i = 0; i != eve::cardinal_v; ++i) + { + TTS_RELATIVE_EQUAL(ez.get(i), kyosu::erfcx(z.get(i)), 1.0e-4); + } +}; diff --git a/test/unit/complex/exp.cpp b/test/unit/complex/exp.cpp index 9f29e320..c11a0e39 100644 --- a/test/unit/complex/exp.cpp +++ b/test/unit/complex/exp.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of exp on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of exp on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of exp on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_exp = [](auto x, auto y){return cv(std::exp(c_t(x, y))); }; ke_t e([&](auto i, auto){return std_exp(a0.get(i), a1.get(i)); }); @@ -50,7 +50,7 @@ TTS_CASE_WITH( "Check behavior of exp on wide" TTS_CASE_TPL( "Check corner cases of exp", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using eve::as; const int N = 12; auto zer = eve::zero(as()); diff --git a/test/unit/complex/exp_i.cpp b/test/unit/complex/exp_i.cpp index 0eb9e04b..78ea9903 100644 --- a/test/unit/complex/exp_i.cpp +++ b/test/unit/complex/exp_i.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of exp_i on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of exp_i on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of exp_i on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_exp_i = [](auto x, auto y){return cv(std::exp(c_t(-y, x))); }; ke_t e([&](auto i, auto){return std_exp_i(a0.get(i), a1.get(i)); }); diff --git a/test/unit/complex/exp_ipi.cpp b/test/unit/complex/exp_ipi.cpp index 35b001e3..46727e69 100644 --- a/test/unit/complex/exp_ipi.cpp +++ b/test/unit/complex/exp_ipi.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of exp_ipi on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of exp_ipi on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; auto pis = eve::pi(eve::as()); for(size_t i = 0; i < a0.size(); ++i) { @@ -42,7 +42,7 @@ TTS_CASE_WITH( "Check behavior of exp_ipi on wide" { using e_t = T; using u_t = eve::underlying_type_t; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto pis = eve::pi(eve::as()); auto std_exp_ipi = [&](auto x, auto y){return cv(std::exp(c_t(-y*pis, x*pis))); }; diff --git a/test/unit/complex/expm1.cpp b/test/unit/complex/expm1.cpp index acb3a333..464456fc 100644 --- a/test/unit/complex/expm1.cpp +++ b/test/unit/complex/expm1.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of exp on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of exp on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of exp on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_expm1 = [](auto x, auto y){return kyosu::dec(cv(std::exp(c_t(x, y)))); }; ke_t e([&](auto i, auto){return std_expm1(a0.get(i), a1.get(i)); }); @@ -50,7 +50,7 @@ TTS_CASE_WITH( "Check behavior of exp on wide" TTS_CASE_TPL( "Check corner cases of exp", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using eve::as; const int N = 12; auto zer = eve::zero(as()); diff --git a/test/unit/complex/faddeeva.cpp b/test/unit/complex/faddeeva.cpp new file mode 100644 index 00000000..51137362 --- /dev/null +++ b/test/unit/complex/faddeeva.cpp @@ -0,0 +1,64 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check faddeeva", kyosu::real_types) +(tts::type) +{ + using e_t = T; + auto tcx = kyosu::complex; + using c_t = decltype(tcx(e_t(0))); + using eve::as; + const int N = 10; + auto zer = eve::zero(as()); + auto inf = eve::inf(as()); + auto nan = eve::nan(as()); + auto one = eve::one(as()); + auto half= eve::half(as()); + + + std::array inputs = + { + tcx(one,one), //0 + tcx(half,one), //1 + tcx(T(10.0), T(10.0)),//2 + tcx(T(65.0), zer), //3 + tcx(T(0.01), one), //4 + tcx(T(1.0e-4), T(2.0)), //5 + tcx(T(0.785398163397448), zer), //6 + tcx(inf,zer), //7 + tcx(inf,nan), //8 + tcx(nan,nan) //9 + }; + + std::array results = + { + tcx(T(3.04744205256913e-01), T(2.08218938202832e-01) ),//0 + tcx(T(3.91234021452136e-01), T(1.27202410884648e-01) ),//1 + tcx(T(2.82794674542325e-02), T(2.81384332763369e-02) ),//2 + tcx(T(0.00000000000000e+00), T(8.68086731176095e-03) ),//3 + tcx(T(4.27568139375386e-01), T(2.73204092253626e-03) ),//4 + tcx(T(2.55395675892478e-01), T(1.06796461698883e-05) ),//5 + tcx(T(5.39641485816297e-01), T(5.97805988669632e-01) ),//6 + tcx(T(0.00000000000000e+00), T(0.00000000000000e+00) ),//7 + tcx(T(0.00000000000000e+00), T(0.00000000000000e+00) ),//8 + tcx(nan, nan ) //9 + }; + using eve::conj; + using kyosu::faddeeva; + for(int i=0; i < 7; ++i) + { + TTS_RELATIVE_EQUAL(faddeeva(inputs[i]), results[i], 1.0e-4) << "i " << i << " -> " << inputs[i] << " -> " < " << inputs[i] << " -> " < auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of cos on scalar" @@ -22,7 +22,7 @@ TTS_CASE_WITH( "Check behavior of cos on scalar" (T const& a0, T const& a1 ) { using e_t = typename T::value_type; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -39,6 +39,6 @@ TTS_CASE_WITH( "Check behavior of cos on wide" ) (T const& a0, T const& a1 ) { - auto z = kyosu::to_complex(a0, a1); + auto z = kyosu::complex(a0, a1); TTS_EQUAL(kyosu::is_imag(z), eve::is_eqz(kyosu::real(z))); }; diff --git a/test/unit/complex/lbeta.cpp b/test/unit/complex/lbeta.cpp new file mode 100644 index 00000000..578a2901 --- /dev/null +++ b/test/unit/complex/lbeta.cpp @@ -0,0 +1,41 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check log_abs_gamma", kyosu::scalar_real_types) +(tts::type) +{ + using z_t = kyosu::complex_t; + z_t i = kyosu::complex(T(0), T(1)); + z_t o = kyosu::complex(T(1), T(0)); + TTS_RELATIVE_EQUAL(kyosu::lbeta(i, i), z_t(1.2673795683871619728767940, -2.30372328403975132639009246361848), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lbeta(i, T(0.5)), z_t(0.574232387827216663459561, -0.917428922919860707555628220702128), 1.0e-5); + TTS_ABSOLUTE_EQUAL(kyosu::lbeta(i, o), z_t(0, -eve::pio_2(eve::as())) , 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lbeta(o, T(0.5)), z_t(eve::log(T(2))) , 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lbeta(i, 2*i), z_t(1.122607421965134893435985, -2.796141102021254706058936433559202), 1.0e-5); +}; + + +TTS_CASE_WITH ( "Check behavior of pow on wide" + , kyosu::simd_real_types + , tts::generate ( tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + ) + ) + (T const& a0, T const& a1, T const& a2, T const& a3 ) +{ + auto a = kyosu::complex(a0, a1); + auto b = kyosu::complex(a2, a3); + + auto mylbeta = [](auto a, auto b){return kyosu::log(kyosu::beta(a, b)); }; + TTS_IEEE_EQUAL(kyosu::lbeta(a, b), mylbeta(a, b)); +}; diff --git a/test/unit/complex/log.cpp b/test/unit/complex/log.cpp index dbd65dab..6a7df0d8 100644 --- a/test/unit/complex/log.cpp +++ b/test/unit/complex/log.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of log on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of log on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of log on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_log = [](auto x, auto y){return cv(std::log(c_t(x, y))); }; ke_t e([&](auto i, auto){return std_log(a0.get(i), a1.get(i)); }); @@ -50,7 +50,7 @@ TTS_CASE_WITH( "Check behavior of log on wide" TTS_CASE_TPL( "Check corner cases of log", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using eve::as; const int N = 14; auto zer = eve::zero(as()); @@ -102,7 +102,6 @@ TTS_CASE_TPL( "Check corner cases of log", kyosu::scalar_real_types) using kyosu::log; for(int i=0; i < N; ++i) { - std::cout << "i " << i << " input " << inputs[i] << " ->" << log(inputs[i]) << std::endl; TTS_IEEE_EQUAL(log(inputs[i]), results[i]) << "i " << i << " -> " << inputs[i] << "\n"; TTS_IEEE_EQUAL(log(conj(inputs[i])), conj(log(inputs[i]))); } diff --git a/test/unit/complex/log10.cpp b/test/unit/complex/log10.cpp index 953e8169..295bb3f5 100644 --- a/test/unit/complex/log10.cpp +++ b/test/unit/complex/log10.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of log10 on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of log10 on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of log10 on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_log10 = [](auto x, auto y){return cv(std::log10(c_t(x, y))); }; ke_t e([&](auto i, auto){return std_log10(a0.get(i), a1.get(i)); }); diff --git a/test/unit/complex/log1p.cpp b/test/unit/complex/log1p.cpp index 16fa3f8a..a81d95cd 100644 --- a/test/unit/complex/log1p.cpp +++ b/test/unit/complex/log1p.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of log1p on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of log1p on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of log1p on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::log(c_t(eve::inc(a0.get(i)), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::log1p(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/log2.cpp b/test/unit/complex/log2.cpp index 5790511c..24df8ee7 100644 --- a/test/unit/complex/log2.cpp +++ b/test/unit/complex/log2.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of log2 on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of log2 on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -42,7 +42,7 @@ TTS_CASE_WITH( "Check behavior of log2 on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; auto std_log2 = [](auto x, auto y){return cv(std::log(c_t(x, y)))*eve::invlog_2(eve::as(x)); }; ke_t e([&](auto i, auto){return std_log2(a0.get(i), a1.get(i)); }); diff --git a/test/unit/complex/log_abs_gamma.cpp b/test/unit/complex/log_abs_gamma.cpp new file mode 100644 index 00000000..6c4a7534 --- /dev/null +++ b/test/unit/complex/log_abs_gamma.cpp @@ -0,0 +1,28 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check log_abs_gamma", kyosu::real_types) +(tts::type) +{ + using z_t = kyosu::complex_t; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + T inf(eve::inf(eve::as())); + z_t one = tcx(1, 0); + z_t zer = tcx(0, 0); + z_t two = tcx(2, 0); + z_t three = tcx(3, 0); + TTS_IEEE_EQUAL( kyosu::log_abs_gamma(zer), inf ); + TTS_EQUAL( kyosu::log_abs_gamma(one), T(0)); + TTS_EQUAL( kyosu::log_abs_gamma(two), T(0)); + TTS_ULP_EQUAL( kyosu::log_abs_gamma(three), eve::log(T(2)), 2.0); + TTS_ULP_EQUAL( kyosu::log_abs_gamma(tcx(-3.5, 0)), kyosu::log_abs_gamma(T(-3.5)), 2.0); + TTS_ULP_EQUAL( kyosu::log_abs_gamma(tcx(1, 1)) , eve::log(kyosu::abs(tcx(0.49801566811835585, 0.1549498283018106))), 2.0); +}; diff --git a/test/unit/complex/log_gamma.cpp b/test/unit/complex/log_gamma.cpp new file mode 100644 index 00000000..52e6423c --- /dev/null +++ b/test/unit/complex/log_gamma.cpp @@ -0,0 +1,42 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check log_abs_gamma", kyosu::real_types) +(tts::type) +{ + using z_t = kyosu::complex_t; + using e_t = T; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + T nan(eve::nan(eve::as())); + z_t one = tcx(1, 0); + z_t zer = tcx(0, 0); + z_t two = tcx(2, 0); + z_t three = tcx(3, 0); + TTS_IEEE_EQUAL( kyosu::log_gamma(zer), kyosu::complex(nan, nan) ); + TTS_EQUAL( kyosu::log_gamma(one), zer ); + TTS_EQUAL( kyosu::log_gamma(two), zer); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(three), kyosu::log(two), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-3.5, 0)), tcx(-1.309006684993043, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(1, 1)) , tcx( -0.650923199301856, -0.301640320467534), 1.0e-5); + + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx( 3.5, 0)), tcx(1.2009736023470742, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-3.5, 0)), tcx(-1.309006684993042, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(3.75, 0)), tcx(1.48681557859341705, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-3.75, 0)), tcx(-1.317267942446363, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(4, 0)) , tcx(eve::log(T(6)), 0) , 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(1, 1)) , tcx(-0.6509231993018563, -0.301640320467533197887531), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-1,1)) , tcx(-0.9974967895818289, +2.054554169724811730959450), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(1, -1)) , tcx(-0.6509231993018563, +0.301640320467533197887531), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-1,-1)) , tcx(-0.997496789581828993, -2.054554169724811730959450), 1.0e-5); + TTS_IEEE_EQUAL( kyosu::log_gamma(tcx(-1,0)) , tcx(eve::nan(eve::as()), eve::inf(eve::as()))); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(1, -2)) , tcx(-1.876078786430929341, -0.12964631630978831138370), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log_gamma(tcx(-1,-2)) , tcx(-3.37394492320792483, -2.80759136089877543363209), 1.0e-5); +}; diff --git a/test/unit/complex/lrising_factorial.cpp b/test/unit/complex/lrising_factorial.cpp new file mode 100644 index 00000000..da5f8b95 --- /dev/null +++ b/test/unit/complex/lrising_factorial.cpp @@ -0,0 +1,50 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_WITH ( "Check behavior of lrising_factorial on wide" + , kyosu::real_types + , tts::generate ( tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + ) + ) +(T const& a0, T const& a1, T const& a2, T const& a3 ) +{ + using e_t = T; + using z_t = kyosu::complex_t; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + auto a = tcx(a0, a1); + auto b = tcx(a2, a3); + using z_t = kyosu::complex_t; + z_t i = tcx(T(0), T(1)); + z_t o = tcx(T(1), T(0)); + auto lrf = [](auto a, auto b){return kyosu::log(kyosu::tgamma(a+b)/kyosu::tgamma(a)); }; + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(a, b) , lrf(a, b), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(a, 0.0) , tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(a, 1.0), kyosu::log(a), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(a, 2.0), kyosu::log(a*a+a), 1.0e-5); + + using eve::as; + auto inf = eve::inf(as()); + auto minf = eve::minf(as()); + auto nan = eve::nan(as()); + + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(tcx(inf, 0), tcx(0, 0)), tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(tcx(minf, 0), tcx(0, 0)), tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(tcx(nan, 0), tcx(0, 0)), tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(tcx(nan, 1), tcx(0, 0)), tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::lrising_factorial(tcx(0, 0), tcx(0, 0)), tcx(0, 0), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lrising_factorial(i, i), tcx(-1.918302767689018311762010, +0.4312866367773215092712391), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lrising_factorial(i, T(0.5)), tcx(-0.0018674449025165763, +0.9174289229198607075556282), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lrising_factorial(o, T(0.5)), tcx(-0.120782237635245222345518445781647212251852727902599468363868473, 0), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::lrising_factorial(i, 2*i), tcx(-3.69183338895600954408, +1.3549910915361463982113221), 1.0e-5); +}; diff --git a/test/unit/complex/mul.cpp b/test/unit/complex/mul.cpp index bc0f621b..83f31a94 100644 --- a/test/unit/complex/mul.cpp +++ b/test/unit/complex/mul.cpp @@ -11,7 +11,7 @@ TTS_CASE_TPL( "Check complex::mul", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; using eve::mul; @@ -63,7 +63,7 @@ TTS_CASE_TPL( "Check complex::mul", kyosu::scalar_real_types) TTS_CASE_TPL( "Check complex::operator*", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; auto fill_r = [](auto i, auto) { return T(1+i); }; diff --git a/test/unit/complex/rising_factorial.cpp b/test/unit/complex/rising_factorial.cpp new file mode 100644 index 00000000..72ae7f2f --- /dev/null +++ b/test/unit/complex/rising_factorial.cpp @@ -0,0 +1,60 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_WITH ( "Check behavior of rising_factorial on wide" + , kyosu::real_types + , tts::generate ( tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + , tts::randoms(0.1, 10) + ) + ) +(T const& a0, T const& a1, T const& a2, T const& a3 ) +{ + using e_t = T; + using z_t = kyosu::complex_t; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + auto a = tcx(a0, a1); + auto b = tcx(a2, a3); + + auto rf = [](auto x, auto a){return kyosu::tgamma(a+x)/kyosu::tgamma(x); }; + + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, b) , rf(a, b),1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, tcx(2, 0)), a*(a+1), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, tcx(3, 0)), a*(a+1)*(a+2), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(kyosu::abs(a0), b) , rf(kyosu::abs(a0), b), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(-kyosu::abs(a0), b) , rf(-kyosu::abs(a0), b), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(b, kyosu::abs(a0)) , rf(b, kyosu::abs(a0)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, 3u) , kyosu::rising_factorial(a, e_t(3)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, 2u) , kyosu::rising_factorial(a, e_t(2)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(a, -2) , kyosu::rising_factorial(a, e_t(-2)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(0, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(1, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(1, 3), tcx(0, 0)), tcx(1, 0), 1.0e-5); + + using eve::as; + auto inf = eve::inf(as()); + auto minf = eve::minf(as()); + auto nan = eve::nan(as()); + + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(inf, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(minf, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(nan, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(nan, 1), tcx(0, 0)), tcx(1, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::rising_factorial(tcx(0, 0), tcx(0, 0)), tcx(1, 0), 1.0e-5); + z_t i = tcx(0, 1); + z_t o = tcx(1, 0); + TTS_RELATIVE_EQUAL(kyosu::rising_factorial(i, i), tcx(0.133408195318916183621, +0.06139167700318597540461), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::rising_factorial(i, T(0.5)), tcx(0.60672961239287904055952, +0.7925599369551407652246), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::rising_factorial(i, o), i, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::rising_factorial(o, T(0.5)), tcx(0.88622692545275801364908, 0), 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::rising_factorial(i, 2*i), tcx(0.00533756125402432030171473451274, +0.024348078097112309674412896870731), 1.0e-5); +}; diff --git a/test/unit/complex/sec.cpp b/test/unit/complex/sec.cpp index 5bffe82d..ebee60ae 100644 --- a/test/unit/complex/sec.cpp +++ b/test/unit/complex/sec.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of sec on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of sec on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -40,7 +40,7 @@ TTS_CASE_WITH( "Check behavior of sec on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return kyosu::rec(cv(std::cos(c_t(a0.get(i), a1.get(i))))); }); TTS_RELATIVE_EQUAL(kyosu::sec(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/sin.cpp b/test/unit/complex/sin.cpp index d33469ba..153a15dd 100644 --- a/test/unit/complex/sin.cpp +++ b/test/unit/complex/sin.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of sin on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of sin on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of sin on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::sin(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::sin(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/sincos.cpp b/test/unit/complex/sincos.cpp index a11ad21f..4ad1d8ce 100644 --- a/test/unit/complex/sincos.cpp +++ b/test/unit/complex/sincos.cpp @@ -17,7 +17,7 @@ TTS_CASE_WITH( "Check behavior of sincos on scalar" (T const& a0, T const& a1 ) { using e_t = typename T::value_type; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = kc_t(a0[i], a1[i]); @@ -35,7 +35,7 @@ TTS_CASE_WITH( "Check behavior of sincos on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; auto e = ke_t(a0, a1); auto [s, c] = kyosu::sincos(e); TTS_RELATIVE_EQUAL(c, kyosu::cos(e), 1.0e-6); diff --git a/test/unit/complex/sinh.cpp b/test/unit/complex/sinh.cpp index e88e89b1..20166316 100644 --- a/test/unit/complex/sinh.cpp +++ b/test/unit/complex/sinh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of sinh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of sinh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of sinh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::sinh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::sinh(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/sinhcosh.cpp b/test/unit/complex/sinhcosh.cpp index aff4cf2e..78aa6fdd 100644 --- a/test/unit/complex/sinhcosh.cpp +++ b/test/unit/complex/sinhcosh.cpp @@ -17,7 +17,7 @@ TTS_CASE_WITH( "Check behavior of sinhcosh on scalar" (T const& a0, T const& a1 ) { using e_t = typename T::value_type; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = kc_t(a0[i], a1[i]); @@ -35,7 +35,7 @@ TTS_CASE_WITH( "Check behavior of sinhcosh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; auto e = ke_t(a0, a1); auto [s, c] = kyosu::sinhcosh(e); TTS_RELATIVE_EQUAL(c, kyosu::cosh(e), 1.0e-6); diff --git a/test/unit/complex/sqrt.cpp b/test/unit/complex/sqrt.cpp index 563d8b5c..3747e2a0 100644 --- a/test/unit/complex/sqrt.cpp +++ b/test/unit/complex/sqrt.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of sqrt on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of sqrt on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of sqrt on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::sqrt(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::sqrt(ke_t{a0,a1}), e, 1.0e-6); @@ -50,7 +50,7 @@ TTS_CASE_WITH( "Check behavior of sqrt on wide" TTS_CASE_TPL( "Check corner cases of sqrt", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using eve::as; const int N = 14; auto zer = eve::zero(as()); diff --git a/test/unit/complex/sub.cpp b/test/unit/complex/sub.cpp index 6ece1c39..b3117cb5 100644 --- a/test/unit/complex/sub.cpp +++ b/test/unit/complex/sub.cpp @@ -11,14 +11,14 @@ TTS_CASE_TPL( "Check complex::sub", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; using eve::sub; auto fill_ur = [](auto i, auto) { return -T(1+i); }; auto fill_ui = [](auto i, auto) { return -T(1)/(1+i); }; - auto fill_u = [](auto i, auto) { return kyosu::complex(T(1+i),T(1)/(1+i)); }; + auto fill_u = [](auto i, auto) { return kyosu::complex_t(T(1+i),T(1)/(1+i)); }; c_t z_s(T{1.234}, T{5.678}); wc_t z_v(fill_u); @@ -28,7 +28,7 @@ TTS_CASE_TPL( "Check complex::sub", kyosu::scalar_real_types) auto fill_r = [](auto i, auto) { return T(1+i); }; auto fill_i = [](auto i, auto) { return 13+(1+i); }; - auto fill = [](auto i, auto) { return kyosu::complex(T(1+i),13+(1+i)); }; + auto fill = [](auto i, auto) { return kyosu::complex_t(T(1+i),13+(1+i)); }; c_t z_s1(T{1.5}, T{5.5}), z_s2(T{2.5}, T{1.25}); wc_t z_v1(fill), z_v2(fill_i,fill_r); @@ -74,13 +74,13 @@ TTS_CASE_TPL( "Check complex::sub", kyosu::scalar_real_types) TTS_CASE_TPL( "Check complex::operator-", kyosu::scalar_real_types) (tts::type) { - using c_t = kyosu::complex; + using c_t = kyosu::complex_t; using w_t = eve::wide; using wc_t = eve::wide; auto fill_ur = [](auto i, auto) { return -T(1+i); }; auto fill_ui = [](auto i, auto) { return -T(1)/(1+i); }; - auto fill_u = [](auto i, auto) { return kyosu::complex(T(1+i),T(1)/(1+i)); }; + auto fill_u = [](auto i, auto) { return kyosu::complex_t(T(1+i),T(1)/(1+i)); }; c_t z_s(T{1.234}, T{5.678}); wc_t z_v(fill_u); @@ -90,7 +90,7 @@ TTS_CASE_TPL( "Check complex::operator-", kyosu::scalar_real_types) auto fill_r = [](auto i, auto) { return T(1+i); }; auto fill_i = [](auto i, auto) { return 13+(1+i); }; - auto fill = [](auto i, auto) { return kyosu::complex(T(1+i),13+(1+i)); }; + auto fill = [](auto i, auto) { return kyosu::complex_t(T(1+i),13+(1+i)); }; c_t z_s1(T{1.5}, T{5.5}), z_s2(T{2.5}, T{1.25}); wc_t z_v1(fill), z_v2(fill_i,fill_r); diff --git a/test/unit/complex/tan.cpp b/test/unit/complex/tan.cpp index 989e3e98..69d9ce56 100644 --- a/test/unit/complex/tan.cpp +++ b/test/unit/complex/tan.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of tan on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of tan on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of tan on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::tan(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::tan(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/tanh.cpp b/test/unit/complex/tanh.cpp index 85456aa5..2be37202 100644 --- a/test/unit/complex/tanh.cpp +++ b/test/unit/complex/tanh.cpp @@ -12,7 +12,7 @@ template < typename T > auto cv(std::complex < T > const &sc) { - return kyosu::to_complex(sc.real(), sc.imag()); + return kyosu::complex(sc.real(), sc.imag()); } TTS_CASE_WITH( "Check behavior of tanh on scalar" @@ -23,7 +23,7 @@ TTS_CASE_WITH( "Check behavior of tanh on scalar" { using e_t = typename T::value_type; using c_t = std::complex; - using kc_t = kyosu::as_complex_t; + using kc_t = kyosu::complex_t; for(size_t i = 0; i < a0.size(); ++i) { auto e = a0[i]; @@ -41,7 +41,7 @@ TTS_CASE_WITH( "Check behavior of tanh on wide" (T const& a0, T const& a1 ) { using e_t = T; - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; using c_t = std::complex>; ke_t e([&](auto i, auto){return cv(std::tanh(c_t(a0.get(i), a1.get(i)))); }); TTS_RELATIVE_EQUAL(kyosu::tanh(ke_t{a0,a1}), e, 1.0e-6); diff --git a/test/unit/complex/tgamma.cpp b/test/unit/complex/tgamma.cpp new file mode 100644 index 00000000..c4ecec66 --- /dev/null +++ b/test/unit/complex/tgamma.cpp @@ -0,0 +1,42 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + +TTS_CASE_TPL( "Check acos lilits", kyosu::real_types) +(tts::type) +{ + using e_t = T; + using z_t = kyosu::complex_t; + auto tcx = [](auto r, auto i){return kyosu::complex(T(r), T(i)); }; + z_t inf(eve::inf(eve::as()), 0); + z_t nan(eve::nan(eve::as()), eve::nan(eve::as())); + z_t one = tcx(1, 0); + z_t zer = tcx(0, 0); + z_t two = tcx(2, 0); + z_t three = tcx(3, 0); + TTS_IEEE_EQUAL( kyosu::tgamma(zer), inf ); + TTS_IEEE_EQUAL( kyosu::tgamma(-zer), -inf); + TTS_EQUAL( kyosu::tgamma(one), one ); + TTS_EQUAL( kyosu::tgamma(two), one); + TTS_RELATIVE_EQUAL( kyosu::tgamma(three), two, 1); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx( 3.5, 0)), tcx(3.323350970447843, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(-3.5, 0)), tcx(0.270088205852269, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(3.75, 0)), tcx(4.422988410460251, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(-3.75, 0)), tcx(0.267866128861417, 0), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(4, 0)) , tcx(6, 0) , 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(1, 1)) , tcx( 0.498015668118356, -0.154949828301811), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(-1,1)) , tcx(-0.17153291990827267, +0.326482748210083), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(1, -1)) , tcx( 0.498015668118356, +0.154949828301811), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(-1,-1)) , tcx(-0.17153291990827267, -0.326482748210083), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(1, -2)) , tcx(0.1519040026700361, -0.01980488016185498), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::tgamma(tcx(-1,-2)) , tcx(-0.0323612885501927257, -0.0112294242346326173504), 1.0e-5); + TTS_IEEE_EQUAL( kyosu::tgamma(tcx(-1,0)) , tcx(eve::nan(eve::as()), eve::inf(eve::as()))); + TTS_RELATIVE_EQUAL( kyosu::tgamma(kyosu::complex(eve::half(eve::as()))), kyosu::complex(eve::tgamma(eve::half(eve::as()))), 1.0e-5); +}; diff --git a/test/unit/complex/to_complex.cpp b/test/unit/complex/to_complex.cpp index 4d8d7ada..2e5dc1ef 100644 --- a/test/unit/complex/to_complex.cpp +++ b/test/unit/complex/to_complex.cpp @@ -13,41 +13,41 @@ TTS_CASE_TPL( "Check to_complex converter from constants", kyosu::scalar_real_ty { using e_t = T; using w_t = eve::wide; - using c_t = kyosu::complex; - using wc_t = eve::wide>; + using c_t = kyosu::complex_t; + using wc_t = eve::wide>; auto zer (e_t(0)); auto wzer(w_t(0)); auto o(e_t(1)); auto wo(w_t(1)); - c_t z_0 = kyosu::to_complex(zer); + c_t z_0 = kyosu::complex(zer); TTS_EQUAL( get<0>(z_0), T{0}); TTS_EQUAL( get<1>(z_0), T{0}); - wc_t wz_0 = kyosu::to_complex(wzer); + wc_t wz_0 = kyosu::complex(wzer); TTS_EQUAL( get<0>(wz_0), w_t{0}); TTS_EQUAL( get<1>(wz_0), w_t{0}); { - auto z_1 = kyosu::to_complex(o, o); + auto z_1 = kyosu::complex(o, o); TTS_EQUAL( get<0>(z_1), T(1)); TTS_EQUAL( get<1>(z_1), T(1)); - auto zc = kyosu::to_complex(c_t(1, 1)); + auto zc = kyosu::complex(c_t(1, 1)); TTS_EQUAL( get<0>(zc), T(1)); TTS_EQUAL( get<1>(zc), T(1)); - wc_t wz_1 = kyosu::to_complex(wo, wo); + wc_t wz_1 = kyosu::complex(wo, wo); TTS_EQUAL( get<0>(wz_1), wo); TTS_EQUAL( get<1>(wz_1), wo); - wc_t wz_2 = kyosu::to_complex(wo, o); + wc_t wz_2 = kyosu::complex(wo, o); TTS_EQUAL( get<0>(wz_2), wo); TTS_EQUAL( get<1>(wz_2), wo); - wc_t wz_3 = kyosu::to_complex(o, wo); + wc_t wz_3 = kyosu::complex(o, wo); TTS_EQUAL( get<0>(wz_3), wo); TTS_EQUAL( get<1>(wz_3), wo); } diff --git a/test/unit/complex/to_polar.cpp b/test/unit/complex/to_polar.cpp index a6f8d7f3..c4ab6408 100644 --- a/test/unit/complex/to_polar.cpp +++ b/test/unit/complex/to_polar.cpp @@ -17,7 +17,7 @@ TTS_CASE_WITH ( "Check behavior of from_polar on wide" (T const& a0, T const& a1) { { - auto c = kyosu::to_complex(a0, a1); + auto c = kyosu::complex(a0, a1); auto [r1, t1] = kyosu::to_polar(c); auto c1 = kyosu::from_polar(r1, t1); TTS_RELATIVE_EQUAL(c, c1, 1.0e-5); @@ -25,7 +25,7 @@ TTS_CASE_WITH ( "Check behavior of from_polar on wide" { auto [r1, t1] = kyosu::to_polar(a0); auto c1 = kyosu::from_polar(r1, t1); - TTS_RELATIVE_EQUAL(kyosu::to_complex(a0), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::complex(a0), c1, 1.0e-5); } diff --git a/test/unit/complex/zeta.cpp b/test/unit/complex/zeta.cpp new file mode 100644 index 00000000..9a2ead1f --- /dev/null +++ b/test/unit/complex/zeta.cpp @@ -0,0 +1,44 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include +#include + + +TTS_CASE_WITH("Check behavior of zeta on wide" + , kyosu::scalar_real_types + , tts::generate( tts::between(-10, 10)) + ) + ([[maybe_unused]] T const& a0) +{ + using eve::as; + using kyosu::real; + using kyosu::zeta; + using v_t = eve::element_type_t; + +#if defined(__cpp_lib_math_special_functions) +// TTS_RELATIVE_EQUAL(real(zeta(a0)), map([](auto e) -> v_t { return std::riemann_zeta(v_t(e)); }, a0), 01.0e-4); + TTS_ULP_EQUAL(real(zeta(T(0))), T(std::riemann_zeta(v_t(0))), 0.5); + TTS_ULP_EQUAL(real(zeta(T(-0.0))), T(std::riemann_zeta(v_t(-0.0))), 0.5); + TTS_ULP_EQUAL(real(zeta(T(1.5))), T(std::riemann_zeta(v_t(1.5))), 1.5); + TTS_ULP_EQUAL(real(zeta(T(-1.5))), T(std::riemann_zeta(v_t(-1.5))), 3.5); + TTS_ULP_EQUAL(real(zeta(T(14))), T(std::riemann_zeta(v_t(14))), 0.5); + TTS_ULP_EQUAL(real(zeta(T(-14))), T(std::riemann_zeta(v_t(-14))), 0.5); + TTS_ULP_EQUAL(real(zeta(T(14.5))), T(std::riemann_zeta(v_t(14.5))), 0.5); + TTS_ULP_EQUAL(real(zeta(T(-14.5))), T(std::riemann_zeta(v_t(-14.5))), 18); +#endif + + if constexpr( eve::platform::supports_invalids ) + { + TTS_IEEE_EQUAL(real(zeta(eve::nan(eve::as()))), eve::nan(eve::as())); + TTS_IEEE_EQUAL(real(zeta(eve::inf(eve::as()))), eve::one(eve::as())); + TTS_IEEE_EQUAL(real(zeta(eve::minf(eve::as()))), eve::nan(eve::as())); + }; + + TTS_IEEE_EQUAL(real(zeta(T(1))), eve::nan(eve::as())); +}; diff --git a/test/unit/function/abs.cpp b/test/unit/function/abs.cpp index b32dbb3a..05edc6d4 100644 --- a/test/unit/function/abs.cpp +++ b/test/unit/function/abs.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::abs over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::abs(kyosu::to_complex(r,i)), eve::hypot(r, i)); + TTS_EQUAL(kyosu::abs(kyosu::complex(r,i)), eve::hypot(r, i)); }; TTS_CASE_WITH ( "Check kyosu::abs over quaternion" @@ -34,6 +34,6 @@ TTS_CASE_WITH ( "Check kyosu::abs over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::abs(type(r,i,j,k)), eve::hypot(r, i, j, k)); }; diff --git a/test/unit/function/average.cpp b/test/unit/function/average.cpp index fc0a07a8..a1f470ce 100644 --- a/test/unit/function/average.cpp +++ b/test/unit/function/average.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::average over complex" ) (T r0, T i0, T r1, T i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::average(c0, c1), (c0+c1)*T(0.5), 1e-7); }; @@ -42,7 +42,7 @@ TTS_CASE_WITH ( "Check kyosu::average over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::average(q0, q1), (q0+q1)*T(0.5) , 1e-7); diff --git a/test/unit/function/ceil.cpp b/test/unit/function/ceil.cpp index 7e297495..c05741e8 100644 --- a/test/unit/function/ceil.cpp +++ b/test/unit/function/ceil.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::ceil over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::ceil(kyosu::to_complex(r,i)), kyosu::to_complex(eve::ceil(r),eve::ceil(i))); + TTS_EQUAL(kyosu::ceil(kyosu::complex(r,i)), kyosu::complex(eve::ceil(r),eve::ceil(i))); }; TTS_CASE_WITH ( "Check kyosu::ceil over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::ceil over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::ceil(type(r,i,j,k)), type(eve::ceil(r), eve::ceil(i), eve::ceil(j), eve::ceil(k))); }; @@ -47,7 +47,7 @@ TTS_CASE_WITH ( "Check kyosu::ceil over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::ceil(type(r,i,j,k,l,li,lj,lk)), type(eve::ceil(r), eve::ceil(i), eve::ceil(j), eve::ceil(k) , eve::ceil(l), eve::ceil(li), eve::ceil(lj), eve::ceil(lk) )); }; diff --git a/test/unit/function/conj.cpp b/test/unit/function/conj.cpp index 2781d4fc..74abd1bc 100644 --- a/test/unit/function/conj.cpp +++ b/test/unit/function/conj.cpp @@ -23,9 +23,9 @@ TTS_CASE_WITH ( "Check kyosu::conj over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::conj(kyosu::to_complex(r,i)), kyosu::to_complex(r,-i)); - TTS_IEEE_EQUAL(kyosu::conj(kyosu::to_complex(eve::nan(eve::as(r)),i)) , kyosu::to_complex(eve::nan(eve::as(r)),-i)); - TTS_IEEE_EQUAL(kyosu::conj(kyosu::to_complex(r,eve::nan(eve::as(i)))) , kyosu::to_complex(r,eve::nan(eve::as(i)))); + TTS_EQUAL(kyosu::conj(kyosu::complex(r,i)), kyosu::complex(r,-i)); + TTS_IEEE_EQUAL(kyosu::conj(kyosu::complex(eve::nan(eve::as(r)),i)) , kyosu::complex(eve::nan(eve::as(r)),-i)); + TTS_IEEE_EQUAL(kyosu::conj(kyosu::complex(r,eve::nan(eve::as(i)))) , kyosu::complex(r,eve::nan(eve::as(i)))); }; TTS_CASE_WITH ( "Check kyosu::conj over quaternion" @@ -36,6 +36,6 @@ TTS_CASE_WITH ( "Check kyosu::conj over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::conj(type(r,i,j,k)), type(r,-i,-j,-k)); }; diff --git a/test/unit/function/cos.cpp b/test/unit/function/cos.cpp index f52d5ee2..f38953ce 100644 --- a/test/unit/function/cos.cpp +++ b/test/unit/function/cos.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::cos over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::cos over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_cos = [](auto x, auto y, auto z, auto t){return cv(boost::math::cos(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_cos(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/cosh.cpp b/test/unit/function/cosh.cpp index 586328b0..fd3c23e7 100644 --- a/test/unit/function/cosh.cpp +++ b/test/unit/function/cosh.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::cosh over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::cosh over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_cosh = [](auto x, auto y, auto z, auto t){return cv(boost::math::cosh(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_cosh(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/cospi.cpp b/test/unit/function/cospi.cpp index 5d1b023a..ec81b874 100644 --- a/test/unit/function/cospi.cpp +++ b/test/unit/function/cospi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::cospi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/cot.cpp b/test/unit/function/cot.cpp index 6b24e591..b94ebfa0 100644 --- a/test/unit/function/cot.cpp +++ b/test/unit/function/cot.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::cot over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::cot over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_cot = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::tan(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_cot(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/coth.cpp b/test/unit/function/coth.cpp index 23800aa8..bfca0ef5 100644 --- a/test/unit/function/coth.cpp +++ b/test/unit/function/coth.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::coth over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::coth over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_coth = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::tanh(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_coth(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/cotpi.cpp b/test/unit/function/cotpi.cpp index 50630dab..b0d2cd1a 100644 --- a/test/unit/function/cotpi.cpp +++ b/test/unit/function/cotpi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::cotpi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/csc.cpp b/test/unit/function/csc.cpp index 043a4789..f727247f 100644 --- a/test/unit/function/csc.cpp +++ b/test/unit/function/csc.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::csc over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::csc over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_csc = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::sin(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_csc(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/csch.cpp b/test/unit/function/csch.cpp index 2ed2ecf6..fa32a06f 100644 --- a/test/unit/function/csch.cpp +++ b/test/unit/function/csch.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::csch over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::csch over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_csch = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::sinh(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_csch(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/cscpi.cpp b/test/unit/function/cscpi.cpp index 9e9a78c4..cb84d2fc 100644 --- a/test/unit/function/cscpi.cpp +++ b/test/unit/function/cscpi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::cscpi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/dec.cpp b/test/unit/function/dec.cpp index 5acac332..9e707204 100644 --- a/test/unit/function/dec.cpp +++ b/test/unit/function/dec.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::dec over complex" ) (T r, T i) { - using type = kyosu::as_complex_t; + using type = kyosu::complex_t; TTS_EQUAL(kyosu::dec(type(r,i)), type(r-1,i)); }; @@ -35,6 +35,6 @@ TTS_CASE_WITH ( "Check kyosu::dec over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::dec(type(r,i,j,k)), type(r-1,i,j,k)); }; diff --git a/test/unit/function/dist.cpp b/test/unit/function/dist.cpp index 2dd9e0f5..c3497ea8 100644 --- a/test/unit/function/dist.cpp +++ b/test/unit/function/dist.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::dist over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::dist(c0, c1), kyosu::abs(c0-c1), 1e-7); }; @@ -42,7 +42,7 @@ TTS_CASE_WITH ( "Check kyosu::dist over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::dist(q0, q1), kyosu::abs(q0-q1) , 1e-7); diff --git a/test/unit/function/dot.cpp b/test/unit/function/dot.cpp index 31aedbc9..c2070f54 100644 --- a/test/unit/function/dot.cpp +++ b/test/unit/function/dot.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::dot over complex" ) (T r0, T i0, T r1, T i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::dot(c0, c1) , kyosu::real(c0)*kyosu::real(c1)+kyosu::imag(c0)*kyosu::imag(c1), 1e-7); }; @@ -43,7 +43,7 @@ TTS_CASE_WITH ( "Check kyosu::dot over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::dot(q0, q1), kyosu::real(q0)*kyosu::real(q1)+ diff --git a/test/unit/function/exp.cpp b/test/unit/function/exp.cpp index f157500b..a54e9125 100644 --- a/test/unit/function/exp.cpp +++ b/test/unit/function/exp.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::exp over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_exp = [](auto x, auto y, auto z, auto t){return cv(boost::math::exp(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_exp(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/exp10.cpp b/test/unit/function/exp10.cpp index aa82e8fe..4a1301ac 100644 --- a/test/unit/function/exp10.cpp +++ b/test/unit/function/exp10.cpp @@ -25,10 +25,10 @@ TTS_CASE_WITH ( "Check kyosu::exp10 over quaternion" ) (T r, T i, T j, T k) { - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::exp10(c), kyosu::exp(eve::log_10(eve::as())*c), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::exp10(q), kyosu::exp(eve::log_10(eve::as())*q), 1e-5); }; diff --git a/test/unit/function/exp2.cpp b/test/unit/function/exp2.cpp index 2d9cacd7..6b1091a1 100644 --- a/test/unit/function/exp2.cpp +++ b/test/unit/function/exp2.cpp @@ -25,10 +25,10 @@ TTS_CASE_WITH ( "Check kyosu::exp2 over quaternion" ) (T r, T i, T j, T k) { - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::exp2(c), kyosu::exp(eve::log_2(eve::as())*c), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::exp2(q), kyosu::exp(eve::log_2(eve::as())*q), 1e-5); }; diff --git a/test/unit/function/exp_i.cpp b/test/unit/function/exp_i.cpp index 637d529c..89ca334d 100644 --- a/test/unit/function/exp_i.cpp +++ b/test/unit/function/exp_i.cpp @@ -17,13 +17,13 @@ TTS_CASE_WITH ( "Check kyosu::exp_i over quaternion" (T r, T i, T j, T k) { using u_t = eve::underlying_type_t; - constexpr auto ii = kyosu::as_complex_t(u_t(0), u_t(1)); + constexpr auto ii = kyosu::complex_t(u_t(0), u_t(1)); TTS_RELATIVE_EQUAL(kyosu::exp_i(r), kyosu::exp(ii*r), 1e-5); - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::exp_i(c), kyosu::exp(ii*c), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::exp_i(q), kyosu::exp(ii*q), 1e-5); }; diff --git a/test/unit/function/exp_ipi.cpp b/test/unit/function/exp_ipi.cpp index f04a1da5..e1de6889 100644 --- a/test/unit/function/exp_ipi.cpp +++ b/test/unit/function/exp_ipi.cpp @@ -17,13 +17,13 @@ TTS_CASE_WITH ( "Check kyosu::exp_ipi over quaternion" (T r, T i, T j, T k) { using u_t = eve::underlying_type_t; - auto ipi = kyosu::as_complex_t(u_t(0), eve::pi(eve::as())); + auto ipi = kyosu::complex_t(u_t(0), eve::pi(eve::as())); TTS_RELATIVE_EQUAL(kyosu::exp_ipi(r), kyosu::exp(ipi*r), 1e-5); - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::exp_ipi(c), kyosu::exp(ipi*c), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::exp_ipi(q), kyosu::exp(ipi*q), 1e-5); }; diff --git a/test/unit/function/expm1.cpp b/test/unit/function/expm1.cpp index 0d77f728..ffbdadfd 100644 --- a/test/unit/function/expm1.cpp +++ b/test/unit/function/expm1.cpp @@ -25,7 +25,7 @@ TTS_CASE_WITH ( "Check kyosu::expm1 over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; auto q = ke_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::expm1(q), kyosu::dec(kyosu::exp(q)), 1e-5); }; diff --git a/test/unit/function/expmx2.cpp b/test/unit/function/expmx2.cpp index 49702a8d..c0a3da5b 100644 --- a/test/unit/function/expmx2.cpp +++ b/test/unit/function/expmx2.cpp @@ -17,10 +17,10 @@ TTS_CASE_WITH ( "Check kyosu::expmx2 over quaternion" (T r, T i, T j, T k) { TTS_RELATIVE_EQUAL(kyosu::expmx2(r), kyosu::exp(-kyosu::sqr(r)), 1e-5); - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::expmx2(c), kyosu::exp(-kyosu::sqr(c)), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::expmx2(q), kyosu::exp(-kyosu::sqr(q)), 1e-5); }; diff --git a/test/unit/function/expx2.cpp b/test/unit/function/expx2.cpp index 71eae311..89095f66 100644 --- a/test/unit/function/expx2.cpp +++ b/test/unit/function/expx2.cpp @@ -17,10 +17,10 @@ TTS_CASE_WITH ( "Check kyosu::expx2 over quaternion" (T r, T i, T j, T k) { TTS_RELATIVE_EQUAL(kyosu::expx2(r), kyosu::exp(kyosu::sqr(r)), 1e-5); - using ce_t = kyosu::as_complex_t; + using ce_t = kyosu::complex_t; auto c = ce_t(r,i); TTS_RELATIVE_EQUAL(kyosu::expx2(c), kyosu::exp(kyosu::sqr(c)), 1e-5); - using qe_t = kyosu::as_quaternion_t; + using qe_t = kyosu::quaternion_t; auto q = qe_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::expx2(q), kyosu::exp(kyosu::sqr(q)), 1e-5); }; diff --git a/test/unit/function/floor.cpp b/test/unit/function/floor.cpp index 22a79900..ad57980e 100644 --- a/test/unit/function/floor.cpp +++ b/test/unit/function/floor.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::floor over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::floor(kyosu::to_complex(r,i)), kyosu::to_complex(eve::floor(r),eve::floor(i))); + TTS_EQUAL(kyosu::floor(kyosu::complex(r,i)), kyosu::complex(eve::floor(r),eve::floor(i))); }; TTS_CASE_WITH ( "Check kyosu::floor over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::floor over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::floor(type(r,i,j,k)), type(eve::floor(r), eve::floor(i), eve::floor(j), eve::floor(k))); }; @@ -47,7 +47,7 @@ TTS_CASE_WITH ( "Check kyosu::floor over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::floor(type(r,i,j,k,l,li,lj,lk)), type(eve::floor(r), eve::floor(i), eve::floor(j), eve::floor(k) , eve::floor(l), eve::floor(li), eve::floor(lj), eve::floor(lk) )); }; diff --git a/test/unit/function/frac.cpp b/test/unit/function/frac.cpp index cab6454a..3ac6471d 100644 --- a/test/unit/function/frac.cpp +++ b/test/unit/function/frac.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::frac over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::frac(kyosu::to_complex(r,i)), kyosu::to_complex(eve::frac(r),eve::frac(i))); + TTS_EQUAL(kyosu::frac(kyosu::complex(r,i)), kyosu::complex(eve::frac(r),eve::frac(i))); }; TTS_CASE_WITH ( "Check kyosu::frac over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::frac over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::frac(type(r,i,j,k)), type(eve::frac(r), eve::frac(i), eve::frac(j), eve::frac(k))); }; @@ -47,7 +47,7 @@ TTS_CASE_WITH ( "Check kyosu::frac over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::frac(type(r,i,j,k,l,li,lj,lk)), type(eve::frac(r), eve::frac(i), eve::frac(j), eve::frac(k) , eve::frac(l), eve::frac(li), eve::frac(lj), eve::frac(lk) )); }; diff --git a/test/unit/function/hypot.cpp b/test/unit/function/hypot.cpp index 47bd1438..1fc725cd 100644 --- a/test/unit/function/hypot.cpp +++ b/test/unit/function/hypot.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::hypot over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::hypot(c0, c1), eve::hypot(r0, i0, r1, i1), 2e-5); }; @@ -42,7 +42,7 @@ TTS_CASE_WITH ( "Check kyosu::hypot over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::hypot(q0, q1), eve::hypot(r0, i0, j0, k0, r1, i1, j1, k1), 1e-5); diff --git a/test/unit/function/if_else.cpp b/test/unit/function/if_else.cpp index bb55e6e6..d121c712 100644 --- a/test/unit/function/if_else.cpp +++ b/test/unit/function/if_else.cpp @@ -18,25 +18,25 @@ TTS_CASE_WITH ( "Check behavior of if_else on scalar cayley-dickson" for(auto e : a0) { auto m = eve::is_odd(e); - TTS_EQUAL ( kyosu::if_else( m, kyosu::complex(0,-e), kyosu::complex(0, e)) - , kyosu::complex(0,m ? -e : e) + TTS_EQUAL ( kyosu::if_else( m, kyosu::complex_t(0,-e), kyosu::complex_t(0, e)) + , kyosu::complex_t(0,m ? -e : e) ); - TTS_EQUAL ( kyosu::if_else(m, kyosu::quaternion(0,-e,1,-2), kyosu::quaternion(0,e,-1, 2)) - , kyosu::quaternion(0,m ? -e : e,m ? 1 : -1,m ? -2 : 2) + TTS_EQUAL ( kyosu::if_else(m, kyosu::quaternion_t(0,-e,1,-2), kyosu::quaternion_t(0,e,-1, 2)) + , kyosu::quaternion_t(0,m ? -e : e,m ? 1 : -1,m ? -2 : 2) ); TTS_EQUAL ( kyosu::if_else( eve::is_odd(e) - , kyosu::complex(0,-e) - , kyosu::quaternion(0, e,-1, 2) + , kyosu::complex_t(0,-e) + , kyosu::quaternion_t(0, e,-1, 2) ) - , kyosu::quaternion(0,m ? -e : e,m ? 0 : -1,m ? 0 : 2) + , kyosu::quaternion_t(0,m ? -e : e,m ? 0 : -1,m ? 0 : 2) ); TTS_EQUAL ( kyosu::if_else( eve::is_odd(e) - , kyosu::quaternion(0,-e, 1, -2) - , kyosu::complex(0, e) + , kyosu::quaternion_t(0,-e, 1, -2) + , kyosu::complex_t(0, e) ) - , kyosu::quaternion(0,m ? -e : e,m ? 1 : 0,m ? -2 : 0) + , kyosu::quaternion_t(0,m ? -e : e,m ? 1 : 0,m ? -2 : 0) ); } }; @@ -48,8 +48,8 @@ TTS_CASE_WITH ( "Check behavior of if_else on SIMD cayley-dickson" (T const& a0 ) { using e_t = typename T::value_type; - using c_t = kyosu::complex; - using q_t = kyosu::quaternion; + using c_t = kyosu::complex_t; + using q_t = kyosu::quaternion_t; using wc_t = eve::wide; using wq_t = eve::wide; diff --git a/test/unit/function/inc.cpp b/test/unit/function/inc.cpp index 74f1b905..42aee9b8 100644 --- a/test/unit/function/inc.cpp +++ b/test/unit/function/inc.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::inc over complex" ) (T r, T i) { - using type = kyosu::as_complex_t; + using type = kyosu::complex_t; TTS_EQUAL(kyosu::inc(type(r,i)), type(r+1,i)); }; @@ -35,6 +35,6 @@ TTS_CASE_WITH ( "Check kyosu::inc over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::inc(type(r,i,j,k)), type(r+1,i,j,k)); }; diff --git a/test/unit/function/ipart.cpp b/test/unit/function/ipart.cpp index bb400e73..208c3648 100644 --- a/test/unit/function/ipart.cpp +++ b/test/unit/function/ipart.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::ipart over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::ipart(kyosu::to_complex(r,i)), i); + TTS_EQUAL(kyosu::ipart(kyosu::complex(r,i)), i); }; TTS_CASE_WITH ( "Check kyosu::ipart over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::ipart over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::ipart(type(r,i,j,k)), i); }; @@ -47,6 +47,6 @@ TTS_CASE_WITH ( "Check kyosu::ipart over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::ipart(type(r,i,j,k,l,li,lj,lk)), i ); }; diff --git a/test/unit/function/is_denormal.cpp b/test/unit/function/is_denormal.cpp index c36f9d35..4092b6a7 100644 --- a/test/unit/function/is_denormal.cpp +++ b/test/unit/function/is_denormal.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_denormal over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_denormal(kyosu::to_complex(r,i)), eve::is_denormal(r) || eve::is_denormal(i)); + TTS_EQUAL(kyosu::is_denormal(kyosu::complex(r,i)), eve::is_denormal(r) || eve::is_denormal(i)); auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_denormal(z), eve::true_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_denormal over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_denormal(type(r,i,j,k)), eve::is_denormal(r) || eve::is_denormal(i) || eve::is_denormal(j) || eve::is_denormal(k)); TTS_EQUAL(kyosu::is_denormal(z), eve::true_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_denormal over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_denormal(type(r,i,j,k,l,li,lj,lk)), eve::is_denormal(r) || eve::is_denormal(i) || eve::is_denormal(j) || eve::is_denormal(k) || eve::is_denormal(l) || eve::is_denormal(li) || eve::is_denormal(lj) || eve::is_denormal(lk) ); diff --git a/test/unit/function/is_equal.cpp b/test/unit/function/is_equal.cpp index 69f49424..64a3fff8 100644 --- a/test/unit/function/is_equal.cpp +++ b/test/unit/function/is_equal.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::is_equal over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); using kyosu::abs; TTS_EQUAL(kyosu::is_equal(c0, c1), (r0 == r1) && (i0 == i1)); }; @@ -43,7 +43,7 @@ TTS_CASE_WITH ( "Check kyosu::is_equal over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); using kyosu::abs; diff --git a/test/unit/function/is_eqz.cpp b/test/unit/function/is_eqz.cpp index 0b7449ab..8d6f687f 100644 --- a/test/unit/function/is_eqz.cpp +++ b/test/unit/function/is_eqz.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_eqz over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_eqz(kyosu::to_complex(r,i)), eve::is_eqz(r) && eve::is_eqz(i)); + TTS_EQUAL(kyosu::is_eqz(kyosu::complex(r,i)), eve::is_eqz(r) && eve::is_eqz(i)); auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_eqz(z), eve::true_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_eqz over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_eqz(type(r,i,j,k)), eve::is_eqz(r) && eve::is_eqz(i) && eve::is_eqz(j) && eve::is_eqz(k)); TTS_EQUAL(kyosu::is_eqz(z), eve::true_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_eqz over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_eqz(type(r,i,j,k,l,li,lj,lk)), eve::is_eqz(r) && eve::is_eqz(i) && eve::is_eqz(j) && eve::is_eqz(k) && eve::is_eqz(l) && eve::is_eqz(li) && eve::is_eqz(lj) && eve::is_eqz(lk) ); diff --git a/test/unit/function/is_finite.cpp b/test/unit/function/is_finite.cpp index 34f982ac..69172b08 100644 --- a/test/unit/function/is_finite.cpp +++ b/test/unit/function/is_finite.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_finite over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_finite(kyosu::to_complex(r,i)), eve::is_finite(r) && eve::is_finite(i)); + TTS_EQUAL(kyosu::is_finite(kyosu::complex(r,i)), eve::is_finite(r) && eve::is_finite(i)); auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_finite(z), eve::false_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_finite over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_finite(type(r,i,j,k)), eve::is_finite(r) && eve::is_finite(i) && eve::is_finite(j) && eve::is_finite(k)); TTS_EQUAL(kyosu::is_finite(z), eve::false_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_finite over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_finite(type(r,i,j,k,l,li,lj,lk)), eve::is_finite(r) && eve::is_finite(i) && eve::is_finite(j) && eve::is_finite(k) && eve::is_finite(l) && eve::is_finite(li) && eve::is_finite(lj) && eve::is_finite(lk) ); diff --git a/test/unit/function/is_infinite.cpp b/test/unit/function/is_infinite.cpp index bbc68888..b6c917ce 100644 --- a/test/unit/function/is_infinite.cpp +++ b/test/unit/function/is_infinite.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_infinite over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_infinite(kyosu::to_complex(r,i)), eve::is_infinite(r) || eve::is_infinite(i)); + TTS_EQUAL(kyosu::is_infinite(kyosu::complex(r,i)), eve::is_infinite(r) || eve::is_infinite(i)); auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_infinite(z), eve::true_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_infinite over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_infinite(type(r,i,j,k)), eve::is_infinite(r) || eve::is_infinite(i) || eve::is_infinite(j) || eve::is_infinite(k)); TTS_EQUAL(kyosu::is_infinite(z), eve::true_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_infinite over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_infinite(type(r,i,j,k,l,li,lj,lk)), eve::is_infinite(r) || eve::is_infinite(i) || eve::is_infinite(j) || eve::is_infinite(k) || eve::is_infinite(l) || eve::is_infinite(li) || eve::is_infinite(lj) || eve::is_infinite(lk) ); diff --git a/test/unit/function/is_nan.cpp b/test/unit/function/is_nan.cpp index d81f917d..4c1cfad9 100644 --- a/test/unit/function/is_nan.cpp +++ b/test/unit/function/is_nan.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nan over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_nan(kyosu::to_complex(r,i)), eve::is_nan(r) || eve::is_nan(i)); + TTS_EQUAL(kyosu::is_nan(kyosu::complex(r,i)), eve::is_nan(r) || eve::is_nan(i)); auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_nan(z), eve::true_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nan over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_nan(type(r,i,j,k)), eve::is_nan(r) || eve::is_nan(i) || eve::is_nan(j) || eve::is_nan(k)); TTS_EQUAL(kyosu::is_nan(z), eve::true_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nan over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_nan(type(r,i,j,k,l,li,lj,lk)), eve::is_nan(r) || eve::is_nan(i) || eve::is_nan(j) || eve::is_nan(k) || eve::is_nan(l) || eve::is_nan(li) || eve::is_nan(lj) || eve::is_nan(lk) ); diff --git a/test/unit/function/is_nez.cpp b/test/unit/function/is_nez.cpp index 6de060a5..50cc607a 100644 --- a/test/unit/function/is_nez.cpp +++ b/test/unit/function/is_nez.cpp @@ -24,7 +24,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nez over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_nez(kyosu::to_complex(r,i)), eve::is_nez(r) && eve::is_nez(i)); + TTS_EQUAL(kyosu::is_nez(kyosu::complex(r,i)), eve::is_nez(r) && eve::is_nez(i)); auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_nez(z), eve::false_(eve::as(r))); }; @@ -37,7 +37,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nez over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_nez(type(r,i,j,k)), eve::is_nez(r) && eve::is_nez(i) && eve::is_nez(j) && eve::is_nez(k)); TTS_EQUAL(kyosu::is_nez(z), eve::false_(eve::as(r))); @@ -52,7 +52,7 @@ TTS_CASE_WITH ( "Check kyosu::is_nez over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::zero(eve::as(r))); TTS_EQUAL(kyosu::is_nez(type(r,i,j,k,l,li,lj,lk)), eve::is_nez(r) && eve::is_nez(i) && eve::is_nez(j) && eve::is_nez(k) && eve::is_nez(l) && eve::is_nez(li) && eve::is_nez(lj) && eve::is_nez(lk) ); diff --git a/test/unit/function/is_not_denormal.cpp b/test/unit/function/is_not_denormal.cpp index 2d0d1ee3..32125275 100644 --- a/test/unit/function/is_not_denormal.cpp +++ b/test/unit/function/is_not_denormal.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_denormal over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_not_denormal(kyosu::to_complex(r,i)), eve::is_not_denormal(r) && eve::is_not_denormal(i)); + TTS_EQUAL(kyosu::is_not_denormal(kyosu::complex(r,i)), eve::is_not_denormal(r) && eve::is_not_denormal(i)); auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_not_denormal(z), eve::false_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_denormal over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_not_denormal(type(r,i,j,k)), eve::is_not_denormal(r) && eve::is_not_denormal(i) && eve::is_not_denormal(j) && eve::is_not_denormal(k)); TTS_EQUAL(kyosu::is_not_denormal(z), eve::false_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_denormal over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::mindenormal(eve::as(r))); TTS_EQUAL(kyosu::is_not_denormal(type(r,i,j,k,l,li,lj,lk)), eve::is_not_denormal(r) && eve::is_not_denormal(i) && eve::is_not_denormal(j) && eve::is_not_denormal(k) && eve::is_not_denormal(l) && eve::is_not_denormal(li) && eve::is_not_denormal(lj) && eve::is_not_denormal(lk) ); diff --git a/test/unit/function/is_not_equal.cpp b/test/unit/function/is_not_equal.cpp index 381c01e7..29d3da3d 100644 --- a/test/unit/function/is_not_equal.cpp +++ b/test/unit/function/is_not_equal.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::is_not_equal over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); using kyosu::abs; TTS_EQUAL(kyosu::is_not_equal(c0, c1), (r0 != r1) || (i0 != i1)); }; @@ -43,7 +43,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_equal over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); using kyosu::abs; diff --git a/test/unit/function/is_not_finite.cpp b/test/unit/function/is_not_finite.cpp index fb3e3b44..cf54262e 100644 --- a/test/unit/function/is_not_finite.cpp +++ b/test/unit/function/is_not_finite.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_finite over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_not_finite(kyosu::to_complex(r,i)), eve::is_not_finite(r) || eve::is_not_finite(i)); + TTS_EQUAL(kyosu::is_not_finite(kyosu::complex(r,i)), eve::is_not_finite(r) || eve::is_not_finite(i)); auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_finite(z), eve::true_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_finite over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_finite(type(r,i,j,k)), eve::is_not_finite(r) || eve::is_not_finite(i) || eve::is_not_finite(j) || eve::is_not_finite(k)); TTS_EQUAL(kyosu::is_not_finite(z), eve::true_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_finite over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_finite(type(r,i,j,k,l,li,lj,lk)), eve::is_not_finite(r) || eve::is_not_finite(i) || eve::is_not_finite(j) || eve::is_not_finite(k) || eve::is_not_finite(l) || eve::is_not_finite(li) || eve::is_not_finite(lj) || eve::is_not_finite(lk) ); diff --git a/test/unit/function/is_not_infinite.cpp b/test/unit/function/is_not_infinite.cpp index e92fc5d1..3738309c 100644 --- a/test/unit/function/is_not_infinite.cpp +++ b/test/unit/function/is_not_infinite.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_infinite over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_not_infinite(kyosu::to_complex(r,i)), eve::is_not_infinite(r) && eve::is_not_infinite(i)); + TTS_EQUAL(kyosu::is_not_infinite(kyosu::complex(r,i)), eve::is_not_infinite(r) && eve::is_not_infinite(i)); auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_infinite(z), eve::false_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_infinite over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_infinite(type(r,i,j,k)), eve::is_not_infinite(r) && eve::is_not_infinite(i) && eve::is_not_infinite(j) && eve::is_not_infinite(k)); TTS_EQUAL(kyosu::is_not_infinite(z), eve::false_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_infinite over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::inf(eve::as(r))); TTS_EQUAL(kyosu::is_not_infinite(type(r,i,j,k,l,li,lj,lk)), eve::is_not_infinite(r) && eve::is_not_infinite(i) && eve::is_not_infinite(j) && eve::is_not_infinite(k) && eve::is_not_infinite(l) && eve::is_not_infinite(li) && eve::is_not_infinite(lj) && eve::is_not_infinite(lk) ); diff --git a/test/unit/function/is_not_nan.cpp b/test/unit/function/is_not_nan.cpp index dc88ce0b..a6008092 100644 --- a/test/unit/function/is_not_nan.cpp +++ b/test/unit/function/is_not_nan.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_nan over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_not_nan(kyosu::to_complex(r,i)), eve::is_not_nan(r) && eve::is_not_nan(i)); + TTS_EQUAL(kyosu::is_not_nan(kyosu::complex(r,i)), eve::is_not_nan(r) && eve::is_not_nan(i)); auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_not_nan(z), eve::false_(eve::as(r))); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_nan over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_not_nan(type(r,i,j,k)), eve::is_not_nan(r) && eve::is_not_nan(i) && eve::is_not_nan(j) && eve::is_not_nan(k)); TTS_EQUAL(kyosu::is_not_nan(z), eve::false_(eve::as(r))); @@ -51,7 +51,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_nan over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(eve::nan(eve::as(r))); TTS_EQUAL(kyosu::is_not_nan(type(r,i,j,k,l,li,lj,lk)), eve::is_not_nan(r) && eve::is_not_nan(i) && eve::is_not_nan(j) && eve::is_not_nan(k) && eve::is_not_nan(l) && eve::is_not_nan(li) && eve::is_not_nan(lj) && eve::is_not_nan(lk) ); diff --git a/test/unit/function/is_not_real.cpp b/test/unit/function/is_not_real.cpp index e8e607b0..13905765 100644 --- a/test/unit/function/is_not_real.cpp +++ b/test/unit/function/is_not_real.cpp @@ -23,8 +23,8 @@ TTS_CASE_WITH ( "Check kyosu::is_not_real over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_not_real(kyosu::to_complex(r,i)), eve::is_nez(i)); - TTS_EQUAL(kyosu::is_not_real(kyosu::to_complex(r,eve::zero(eve::as(r)))), eve::false_(eve::as(r))); + TTS_EQUAL(kyosu::is_not_real(kyosu::complex(r,i)), eve::is_nez(i)); + TTS_EQUAL(kyosu::is_not_real(kyosu::complex(r,eve::zero(eve::as(r)))), eve::false_(eve::as(r))); }; TTS_CASE_WITH ( "Check kyosu::is_not_real over quaternion" @@ -35,7 +35,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_real over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::is_not_real(type(r,i,j,k)), eve::is_nez(i) || eve::is_nez(j) || eve::is_nez(k)); TTS_EQUAL(kyosu::is_not_real(type(r)), eve::false_(eve::as(r))); }; @@ -49,7 +49,7 @@ TTS_CASE_WITH ( "Check kyosu::is_not_real over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::is_not_real(type(r,i,j,k,l,li,lj,lk)), eve::is_nez(i) || eve::is_nez(j) || eve::is_nez(k) || eve::is_nez(l) || eve::is_nez(li) || eve::is_nez(lj) || eve::is_nez(lk) ); TTS_EQUAL(kyosu::is_not_real(type(r)), eve::false_(eve::as(r))); diff --git a/test/unit/function/is_real.cpp b/test/unit/function/is_real.cpp index c19fd3d5..da3f9049 100644 --- a/test/unit/function/is_real.cpp +++ b/test/unit/function/is_real.cpp @@ -23,8 +23,8 @@ TTS_CASE_WITH ( "Check kyosu::is_real over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::is_real(kyosu::to_complex(r,i)), eve::is_eqz(i)); - TTS_EQUAL(kyosu::is_real(kyosu::to_complex(r,eve::zero(eve::as(r)))), eve::true_(eve::as(r))); + TTS_EQUAL(kyosu::is_real(kyosu::complex(r,i)), eve::is_eqz(i)); + TTS_EQUAL(kyosu::is_real(kyosu::complex(r,eve::zero(eve::as(r)))), eve::true_(eve::as(r))); }; TTS_CASE_WITH ( "Check kyosu::is_real over quaternion" @@ -35,7 +35,7 @@ TTS_CASE_WITH ( "Check kyosu::is_real over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::is_real(type(r,i,j,k)), eve::is_eqz(i) && eve::is_eqz(j) && eve::is_eqz(k)); TTS_EQUAL(kyosu::is_real(type(r)), eve::true_(eve::as(r))); }; @@ -49,7 +49,7 @@ TTS_CASE_WITH ( "Check kyosu::is_real over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::is_real(type(r,i,j,k,l,li,lj,lk)), eve::is_eqz(i) && eve::is_eqz(j) && eve::is_eqz(k) && eve::is_eqz(l) && eve::is_eqz(li) && eve::is_eqz(lj) && eve::is_eqz(lk) ); TTS_EQUAL(kyosu::is_real(type(r)), eve::true_(eve::as(r))); diff --git a/test/unit/function/is_unitary.cpp b/test/unit/function/is_unitary.cpp index f4e014c6..56f9f09d 100644 --- a/test/unit/function/is_unitary.cpp +++ b/test/unit/function/is_unitary.cpp @@ -24,7 +24,7 @@ TTS_CASE_WITH ( "Check kyosu::is_unitary over complex" ) (auto r, auto i) { - auto c = kyosu::to_complex(r,i); + auto c = kyosu::complex(r,i); c /= kyosu::abs(c); auto o = eve::one(eve::as(kyosu::abs(c))); TTS_EQUAL(kyosu::is_unitary(c), eve::almost(eve::is_equal)(kyosu::abs(c), o)); @@ -38,7 +38,7 @@ TTS_CASE_WITH ( "Check kyosu::is_unitary over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto z(type(r,i,j,k)); z /= kyosu::abs(z); auto o = eve::one(eve::as(kyosu::abs(z))); @@ -54,7 +54,7 @@ TTS_CASE_WITH ( "Check kyosu::is_unitary over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; auto z(type(r,i,j,k,l,li,lj,lk)); z /= kyosu::abs(z); auto o = eve::one(eve::as(kyosu::abs(z))); diff --git a/test/unit/function/jpart.cpp b/test/unit/function/jpart.cpp index 99a01587..468fd6ce 100644 --- a/test/unit/function/jpart.cpp +++ b/test/unit/function/jpart.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::jpart over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::jpart(kyosu::to_complex(r,i)), eve::zero(eve::as(r))); + TTS_EQUAL(kyosu::jpart(kyosu::complex(r,i)), eve::zero(eve::as(r))); }; TTS_CASE_WITH ( "Check kyosu::jpart over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::jpart over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::jpart(type(r,i,j,k)), j); }; @@ -47,6 +47,6 @@ TTS_CASE_WITH ( "Check kyosu::jpart over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::jpart(type(r,i,j,k,l,li,lj,lk)), j ); }; diff --git a/test/unit/function/kpart.cpp b/test/unit/function/kpart.cpp index 8c732de0..09731ae0 100644 --- a/test/unit/function/kpart.cpp +++ b/test/unit/function/kpart.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::kpart over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::kpart(kyosu::to_complex(r,i)), eve::zero(eve::as(r))); + TTS_EQUAL(kyosu::kpart(kyosu::complex(r,i)), eve::zero(eve::as(r))); }; TTS_CASE_WITH ( "Check kyosu::kpart over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::kpart over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::kpart(type(r,i,j,k)), k); }; @@ -47,6 +47,6 @@ TTS_CASE_WITH ( "Check kyosu::kpart over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::kpart(type(r,i,j,k,l,li,lj,lk)), k); }; diff --git a/test/unit/function/ldiv.cpp b/test/unit/function/ldiv.cpp new file mode 100644 index 00000000..ea0a94c3 --- /dev/null +++ b/test/unit/function/ldiv.cpp @@ -0,0 +1,49 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include + +TTS_CASE_WITH ( "Check kyosu::ldiv over real" + , kyosu::real_types + , tts::generate(tts::between(-10,10) + ,tts::between(-10,10) + ) + ) +(auto r0, auto r1) +{ + TTS_EQUAL(kyosu::ldiv(r0, r1), r1/r0); +}; + +TTS_CASE_WITH ( "Check kyosu::ldiv over complex" + , kyosu::real_types + , tts::generate(tts::between(-10,10), tts::between(-10,10) + ,tts::between(-10,10), tts::between(-10,10) + ) + ) +(T r0, T i0, T r1, T i1) +{ + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); + TTS_RELATIVE_EQUAL(kyosu::ldiv(c0, c1), c1/c0, 1e-7); +}; + +TTS_CASE_WITH ( "Check kyosu::ldiv over quaternion" + , kyosu::real_types + , tts::generate ( tts::between(-10,10), tts::between(-10,10) + , tts::between(-10,10), tts::between(-10,10) + , tts::between(-10,10), tts::between(-10,10) + , tts::between(-10,10), tts::between(-10,10) + ) + ) +(T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) +{ + using type = kyosu::quaternion_t; + auto q0 = type(r0,i0,j0,k0); + auto q1 = type(r1,i1,j1,k1); + TTS_RELATIVE_EQUAL(kyosu::ldiv(q0, q1), kyosu::conj(q0)*q1/kyosu::sqr_abs(q0) , 1e-7); +}; diff --git a/test/unit/function/lerp.cpp b/test/unit/function/lerp.cpp index ad957c11..444b6244 100644 --- a/test/unit/function/lerp.cpp +++ b/test/unit/function/lerp.cpp @@ -29,8 +29,8 @@ TTS_CASE_WITH ( "Check kyosu::lerp over complex" ) (auto r0, auto i0, auto r1, auto i1, auto t) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::lerp(c0, c1, t), c0+t*(c1-c0), 1e-7); }; @@ -45,7 +45,7 @@ TTS_CASE_WITH ( "Check kyosu::lerp over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1, auto t) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::lerp(q0, q1, t), q0+t*(q1-q0) , 1e-7); diff --git a/test/unit/function/log.cpp b/test/unit/function/log.cpp index 8cbc345b..18032cf5 100644 --- a/test/unit/function/log.cpp +++ b/test/unit/function/log.cpp @@ -16,8 +16,8 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T a0, T a1, T a2, T a3) { - using ce_t = kyosu::as_complex_t; - using qe_t = kyosu::as_quaternion_t; + using ce_t = kyosu::complex_t; + using qe_t = kyosu::quaternion_t; auto r = T(a0); auto c = ce_t(a0,a1); @@ -26,7 +26,7 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" auto lr = kyosu::log(r); auto lc = kyosu::log(c); auto lq = kyosu::log(q); - TTS_RELATIVE_EQUAL(kyosu::exp(lr), kyosu::to_complex(r), 1e-5); + TTS_RELATIVE_EQUAL(kyosu::exp(lr), kyosu::complex(r), 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp(lc), c, 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp(lq), q, 1e-5); }; diff --git a/test/unit/function/log10.cpp b/test/unit/function/log10.cpp index 4680fb5e..aed783d2 100644 --- a/test/unit/function/log10.cpp +++ b/test/unit/function/log10.cpp @@ -16,8 +16,8 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T a0, T a1, T a2, T a3) { - using ce_t = kyosu::as_complex_t; - using qe_t = kyosu::as_quaternion_t; + using ce_t = kyosu::complex_t; + using qe_t = kyosu::quaternion_t; auto r = T(a0); auto c = ce_t(a0,a1); @@ -26,7 +26,7 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" auto lr = kyosu::log10(r); auto lc = kyosu::log10(c); auto lq = kyosu::log10(q); - TTS_RELATIVE_EQUAL(kyosu::exp10(lr), kyosu::to_complex(r), 1e-5); + TTS_RELATIVE_EQUAL(kyosu::exp10(lr), kyosu::complex(r), 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp10(lc), c, 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp10(lq), q, 1e-5); }; diff --git a/test/unit/function/log1p.cpp b/test/unit/function/log1p.cpp index 5a80a623..433e027a 100644 --- a/test/unit/function/log1p.cpp +++ b/test/unit/function/log1p.cpp @@ -16,22 +16,15 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T a0, T a1, T a2, T a3) { - using ce_t = kyosu::as_complex_t; - using qe_t = kyosu::as_quaternion_t; + using ce_t = kyosu::complex_t; + using qe_t = kyosu::quaternion_t; auto r = T(a0); auto c = ce_t(a0,a1); auto q = qe_t(a0,a1,a2,a3); -// auto lr = kyosu::log1p(r); -// auto lc = kyosu::log1p(c); -// auto lq = kyosu::log1p(q); -// TTS_RELATIVE_EQUAL(kyosu::expm1(lr), kyosu::to_complex(r), 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::expm1(lc), c, 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::expm1(lq), q, 1e-5); - - TTS_RELATIVE_EQUAL( kyosu::log1p(r), kyosu::log(kyosu::inc(r)), 1.0e-6); - TTS_RELATIVE_EQUAL( kyosu::log1p(c), kyosu::log(kyosu::inc(c)), 1.0e-6); - TTS_RELATIVE_EQUAL( kyosu::log1p(q), kyosu::log(kyosu::inc(q)), 1.0e-6); + TTS_RELATIVE_EQUAL( kyosu::log1p(r), kyosu::log(kyosu::inc(r)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log1p(c), kyosu::log(kyosu::inc(c)), 1.0e-5); + TTS_RELATIVE_EQUAL( kyosu::log1p(q), kyosu::log(kyosu::inc(q)), 1.0e-5); }; diff --git a/test/unit/function/log2.cpp b/test/unit/function/log2.cpp index 35039e41..ce833fdb 100644 --- a/test/unit/function/log2.cpp +++ b/test/unit/function/log2.cpp @@ -16,8 +16,8 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T a0, T a1, T a2, T a3) { - using ce_t = kyosu::as_complex_t; - using qe_t = kyosu::as_quaternion_t; + using ce_t = kyosu::complex_t; + using qe_t = kyosu::quaternion_t; auto r = T(a0); auto c = ce_t(a0,a1); @@ -26,7 +26,7 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" auto lr = kyosu::log2(r); auto lc = kyosu::log2(c); auto lq = kyosu::log2(q); - TTS_RELATIVE_EQUAL(kyosu::exp2(lr), kyosu::to_complex(r), 1e-5); + TTS_RELATIVE_EQUAL(kyosu::exp2(lr), kyosu::complex(r), 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp2(lc), c, 1e-5); TTS_RELATIVE_EQUAL(kyosu::exp2(lq), q, 1e-5); }; diff --git a/test/unit/function/log_abs.cpp b/test/unit/function/log_abs.cpp index 2210ac04..b659e49e 100644 --- a/test/unit/function/log_abs.cpp +++ b/test/unit/function/log_abs.cpp @@ -16,8 +16,8 @@ TTS_CASE_WITH ( "Check kyosu::exp over quaternion" ) (T a0, T a1, T a2, T a3) { - using ce_t = kyosu::as_complex_t; - using qe_t = kyosu::as_quaternion_t; + using ce_t = kyosu::complex_t; + using qe_t = kyosu::quaternion_t; auto r = T(a0); auto c = ce_t(a0,a1); diff --git a/test/unit/function/lpnorm.cpp b/test/unit/function/lpnorm.cpp index 63030901..235fcd58 100644 --- a/test/unit/function/lpnorm.cpp +++ b/test/unit/function/lpnorm.cpp @@ -29,8 +29,8 @@ TTS_CASE_WITH ( "Check kyosu::lpnorm over complex" ) (auto r0, auto i0, auto r1, auto i1, auto p) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::lpnorm(p, c0, c1), eve::lpnorm(p, kyosu::abs(c0), kyosu::abs(c1)), 1e-7); }; @@ -45,7 +45,7 @@ TTS_CASE_WITH ( "Check kyosu::lpnorm over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1, T p) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::lpnorm(p, q0, q1), eve::lpnorm(p, kyosu::abs(q0), kyosu::abs(q1)), 1e-7); diff --git a/test/unit/function/manhattan.cpp b/test/unit/function/manhattan.cpp index cd8819c1..31a70b47 100644 --- a/test/unit/function/manhattan.cpp +++ b/test/unit/function/manhattan.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::manhattan over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::manhattan(c0, c1), eve::manhattan(r0, i0, r1, i1), 2e-5); }; @@ -42,7 +42,7 @@ TTS_CASE_WITH ( "Check kyosu::manhattan over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::manhattan(q0, q1), eve::manhattan(r0, i0, j0, k0, r1, i1, j1, k1 ), 1e-5); diff --git a/test/unit/function/minus.cpp b/test/unit/function/minus.cpp index 46c5ee01..16163a9c 100644 --- a/test/unit/function/minus.cpp +++ b/test/unit/function/minus.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::minus over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::minus(kyosu::to_complex(r,i)), kyosu::to_complex(-r,-i)); + TTS_EQUAL(kyosu::minus(kyosu::complex(r,i)), kyosu::complex(-r,-i)); }; TTS_CASE_WITH ( "Check kyosu::minus over quaternion" @@ -34,6 +34,6 @@ TTS_CASE_WITH ( "Check kyosu::minus over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::minus(type(r,i,j,k)), type(-r,-i,-j,-k)); }; diff --git a/test/unit/function/nearest.cpp b/test/unit/function/nearest.cpp index 8a9f7e3c..e237ae1c 100644 --- a/test/unit/function/nearest.cpp +++ b/test/unit/function/nearest.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::nearest over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::nearest(kyosu::to_complex(r,i)), kyosu::to_complex(eve::nearest(r),eve::nearest(i))); + TTS_EQUAL(kyosu::nearest(kyosu::complex(r,i)), kyosu::complex(eve::nearest(r),eve::nearest(i))); }; TTS_CASE_WITH ( "Check kyosu::nearest over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::nearest over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::nearest(type(r,i,j,k)), type(eve::nearest(r), eve::nearest(i), eve::nearest(j), eve::nearest(k))); }; @@ -47,7 +47,7 @@ TTS_CASE_WITH ( "Check kyosu::nearest over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::nearest(type(r,i,j,k,l,li,lj,lk)), type(eve::nearest(r), eve::nearest(i), eve::nearest(j), eve::nearest(k) , eve::nearest(l), eve::nearest(li), eve::nearest(lj), eve::nearest(lk) )); }; diff --git a/test/unit/function/oneminus.cpp b/test/unit/function/oneminus.cpp index e537aa34..e1a6f118 100644 --- a/test/unit/function/oneminus.cpp +++ b/test/unit/function/oneminus.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::oneminus over complex" ) (T r, T i) { - using type = kyosu::as_complex_t; + using type = kyosu::complex_t; auto o = type(1); TTS_EQUAL(kyosu::oneminus(type(r,i)), o-type(r,i)); }; @@ -36,7 +36,7 @@ TTS_CASE_WITH ( "Check kyosu::oneminus over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto o = type(T(1)); TTS_EQUAL(kyosu::oneminus(type(r,i,j,k)), o-type(r,i,j,k)); }; diff --git a/test/unit/function/pow.cpp b/test/unit/function/pow.cpp index 8dfda5b0..b46de6af 100644 --- a/test/unit/function/pow.cpp +++ b/test/unit/function/pow.cpp @@ -28,20 +28,11 @@ TTS_CASE_WITH ( "Check kyosu::pow over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::pow(c0, c1), kyosu::exp(c1*kyosu::log(c0)), 1e-5); TTS_RELATIVE_EQUAL(kyosu::pow(r0, c1), kyosu::exp(c1*kyosu::log(r0)), 1e-5); TTS_RELATIVE_EQUAL(kyosu::pow(c0, r1), kyosu::exp(r1*kyosu::log(c0)), 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::pow(c0, 4u), c0*kyosu::sqr(kyosu::sqr(c0)), 1.0e-5); - - auto o = 1.0f; - auto oo = kyosu::to_complex(o+o, o); - auto z = kyosu::if_else(4 < 2, o*oo, o); - std::cout << "o " << o << std::endl; - std::cout << "oo " << oo << std::endl; - std::cout << "o*oo " << o*oo << std::endl; - std::cout << "z " << z << std::endl; }; TTS_CASE_WITH ( "Check kyosu::pow over quaternion" @@ -54,9 +45,8 @@ TTS_CASE_WITH ( "Check kyosu::pow over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::pow(q0, q1), kyosu::exp(q1*kyosu::log(q0)), 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::pow(q0, 4), kyosu::sqr(kyosu::sqr(q0)), 1.0e-5); }; diff --git a/test/unit/function/pow1p.cpp b/test/unit/function/pow1p.cpp index 83e87c27..3ac1b35f 100644 --- a/test/unit/function/pow1p.cpp +++ b/test/unit/function/pow1p.cpp @@ -28,8 +28,8 @@ TTS_CASE_WITH ( "Check kyosu::pow1p over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::pow1p(c0, c1), kyosu::exp(c1*kyosu::log(kyosu::inc(c0))), 1e-5); TTS_RELATIVE_EQUAL(kyosu::pow1p(r0, c1), kyosu::exp(c1*kyosu::log(kyosu::inc(r0))), 1e-5); TTS_RELATIVE_EQUAL(kyosu::pow1p(c0, r1), kyosu::exp(r1*kyosu::log(kyosu::inc(c0))), 1e-5); @@ -46,7 +46,7 @@ TTS_CASE_WITH ( "Check kyosu::pow1p over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::pow1p(q0, q1), kyosu::exp(q1*kyosu::log(kyosu::inc(q0))), 1e-5); diff --git a/test/unit/function/pow_abs.cpp b/test/unit/function/pow_abs.cpp index 5ad4dbb0..65e37f99 100644 --- a/test/unit/function/pow_abs.cpp +++ b/test/unit/function/pow_abs.cpp @@ -28,20 +28,11 @@ TTS_CASE_WITH ( "Check kyosu::pow_abs over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::pow_abs(c0, c1), kyosu::exp(c1*kyosu::log_abs(c0)), 1e-4); TTS_RELATIVE_EQUAL(kyosu::pow_abs(r0, c1), kyosu::exp(c1*kyosu::log_abs(r0)), 1e-4); TTS_RELATIVE_EQUAL(kyosu::pow_abs(c0, r1), kyosu::exp(r1*kyosu::log_abs(c0)), 2e-4); -// TTS_RELATIVE_EQUAL(kyosu::pow_abs(c0, 4u), c0*kyosu::sqr(kyosu::sqr(c0)), 1.0e-4); - - auto o = 1.0f; - auto oo = kyosu::to_complex(o+o, o); - auto z = kyosu::if_else(4 < 2, o*oo, o); - std::cout << "o " << o << std::endl; - std::cout << "oo " << oo << std::endl; - std::cout << "o*oo " << o*oo << std::endl; - std::cout << "z " << z << std::endl; }; TTS_CASE_WITH ( "Check kyosu::pow_abs over quaternion" @@ -54,11 +45,10 @@ TTS_CASE_WITH ( "Check kyosu::pow_abs over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::pow_abs(q0, q1), kyosu::exp(q1*kyosu::log_abs(q0)), 1e-4); TTS_RELATIVE_EQUAL(kyosu::pow_abs(r0, q1), kyosu::exp(q1*kyosu::log_abs(r0)), 1e-4); - TTS_RELATIVE_EQUAL(kyosu::pow_abs(q0, r1), kyosu::exp(r1*kyosu::log_abs(q0)), 1e-4); -// TTS_RELATIVE_EQUAL(kyosu::pow_abs(q0, 4), kyosu::sqr(kyosu::sqr(q0)), 1.0e-4); + TTS_RELATIVE_EQUAL(kyosu::pow_abs(q0, r1), kyosu::exp(r1*kyosu::log_abs(q0)), 3e-4); }; diff --git a/test/unit/function/powm1.cpp b/test/unit/function/powm1.cpp index 5ab0f780..62f46bd5 100644 --- a/test/unit/function/powm1.cpp +++ b/test/unit/function/powm1.cpp @@ -28,20 +28,11 @@ TTS_CASE_WITH ( "Check kyosu::powm1 over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); TTS_RELATIVE_EQUAL(kyosu::powm1(c0, c1), kyosu::dec(kyosu::exp(c1*kyosu::log(c0))), 1e-5); TTS_RELATIVE_EQUAL(kyosu::powm1(r0, c1), kyosu::dec(kyosu::exp(c1*kyosu::log(r0))), 1e-5); TTS_RELATIVE_EQUAL(kyosu::powm1(c0, r1), kyosu::dec(kyosu::exp(r1*kyosu::log(c0))), 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::powm1(c0, 4u), kyosu::dec(c0*kyosu::sqr(kyosu::sqr(c0))), 1.0e-5); - - auto o = 1.0f; - auto oo = kyosu::to_complex(o+o, o); - auto z = kyosu::if_else(4 < 2, o*oo, o); - std::cout << "o " << o << std::endl; - std::cout << "oo " << oo << std::endl; - std::cout << "o*oo " << o*oo << std::endl; - std::cout << "z " << z << std::endl; }; TTS_CASE_WITH ( "Check kyosu::powm1 over quaternion" @@ -54,9 +45,8 @@ TTS_CASE_WITH ( "Check kyosu::powm1 over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); TTS_RELATIVE_EQUAL(kyosu::powm1(q0, q1), kyosu::dec(kyosu::exp(q1*kyosu::log((q0)))), 1e-5); -// TTS_RELATIVE_EQUAL(kyosu::powm1(q0, 4), kyosu::dec(kyosu::sqr(kyosu::sqr(q0))), 1.0e-5); }; diff --git a/test/unit/function/pure.cpp b/test/unit/function/pure.cpp index 9605bafe..7f897c95 100644 --- a/test/unit/function/pure.cpp +++ b/test/unit/function/pure.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::pure over complex" ) (T r, T i) { - TTS_EQUAL(kyosu::pure(kyosu::to_complex(r,i)), kyosu::to_complex(T(0),i)); + TTS_EQUAL(kyosu::pure(kyosu::complex(r,i)), kyosu::complex(T(0),i)); }; TTS_CASE_WITH ( "Check kyosu::pure over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::pure over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::pure(type(r,i,j,k)), type(T(0), i, j, k)); }; @@ -47,6 +47,6 @@ TTS_CASE_WITH ( "Check kyosu::pure over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::pure(type(r,i,j,k,l,li,lj,lk)), type(T(0),i,j,k,l,li,lj,lk) ); }; diff --git a/test/unit/function/real.cpp b/test/unit/function/real.cpp index 6e97b050..636f5d4c 100644 --- a/test/unit/function/real.cpp +++ b/test/unit/function/real.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::real over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::real(kyosu::to_complex(r,i)), r); + TTS_EQUAL(kyosu::real(kyosu::complex(r,i)), r); }; TTS_CASE_WITH ( "Check kyosu::real over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::real over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::real(type(r,i,j,k)), r); }; @@ -47,6 +47,6 @@ TTS_CASE_WITH ( "Check kyosu::real over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::real(type(r,i,j,k,l,li,lj,lk)), r ); }; diff --git a/test/unit/function/rec.cpp b/test/unit/function/rec.cpp index 5a987c1d..78d139ca 100644 --- a/test/unit/function/rec.cpp +++ b/test/unit/function/rec.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::rec over quaternion" (T r, T i, T j, T k) { auto o = eve::one(eve::as(eve::underlying_type_t())); - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; auto q = ke_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::rec(q), o/q, 1e-5); }; diff --git a/test/unit/function/reldist.cpp b/test/unit/function/reldist.cpp index fce28e95..1d5cf465 100644 --- a/test/unit/function/reldist.cpp +++ b/test/unit/function/reldist.cpp @@ -27,8 +27,8 @@ TTS_CASE_WITH ( "Check kyosu::reldist over complex" ) (auto r0, auto i0, auto r1, auto i1) { - auto c0 = kyosu::to_complex(r0,i0); - auto c1 = kyosu::to_complex(r1,i1); + auto c0 = kyosu::complex(r0,i0); + auto c1 = kyosu::complex(r1,i1); using kyosu::abs; auto one = eve::one(eve::as(r0)); TTS_RELATIVE_EQUAL(kyosu::reldist(c0, c1), abs(c0-c1)/eve::max(abs(c0), abs(c1), one), 1e-7); @@ -44,7 +44,7 @@ TTS_CASE_WITH ( "Check kyosu::reldist over quaternion" ) (T r0, T i0, T j0, T k0, T r1, T i1, T j1, T k1) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q0 = type(r0,i0,j0,k0); auto q1 = type(r1,i1,j1,k1); using kyosu::abs; diff --git a/test/unit/function/sec.cpp b/test/unit/function/sec.cpp index ec45bc64..8b0c4e97 100644 --- a/test/unit/function/sec.cpp +++ b/test/unit/function/sec.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::sec over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::sec over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_sec = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::cos(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_sec(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/sech.cpp b/test/unit/function/sech.cpp index dc782e66..fcc9d6f0 100644 --- a/test/unit/function/sech.cpp +++ b/test/unit/function/sech.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::sech over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::sech over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_sech = [](auto x, auto y, auto z, auto t){return kyosu::rec(cv(boost::math::cosh(bq_t(x, y, z, t)))); }; ke_t e([&](auto n, auto){return boost_sech(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/secpi.cpp b/test/unit/function/secpi.cpp index 03ffe478..71294519 100644 --- a/test/unit/function/secpi.cpp +++ b/test/unit/function/secpi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::secpi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/sign.cpp b/test/unit/function/sign.cpp index c676cd1c..396331cc 100644 --- a/test/unit/function/sign.cpp +++ b/test/unit/function/sign.cpp @@ -26,7 +26,7 @@ TTS_CASE_WITH ( "Check kyosu::sign over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; auto q = ke_t(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::sign(q), q/kyosu::abs(q), 1e-5); }; diff --git a/test/unit/function/sin.cpp b/test/unit/function/sin.cpp index 8ff12201..17cf431c 100644 --- a/test/unit/function/sin.cpp +++ b/test/unit/function/sin.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::sin over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::sin over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_sin = [](auto x, auto y, auto z, auto t){return cv(boost::math::sin(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_sin(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/sinc.cpp b/test/unit/function/sinc.cpp index 3c123e3c..58c4be80 100644 --- a/test/unit/function/sinc.cpp +++ b/test/unit/function/sinc.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::sinc over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::sinc over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_sinc = [](auto x, auto y, auto z, auto t){return cv(boost::math::sin(bq_t(x, y, z, t))/bq_t(x, y, z, t)); }; ke_t e([&](auto n, auto){return boost_sinc(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/sincos.cpp b/test/unit/function/sincos.cpp index 1192fdc3..df54abaf 100644 --- a/test/unit/function/sincos.cpp +++ b/test/unit/function/sincos.cpp @@ -22,14 +22,14 @@ TTS_CASE_WITH ( "Check kyosu::sin over quaternion" TTS_RELATIVE_EQUAL(c, kyosu::cos(r), 1e-5); } { - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; auto cq= ke_t(r,i); auto [s, c] = kyosu::sincos(cq); TTS_RELATIVE_EQUAL(s, kyosu::sin(cq), 1e-5); TTS_RELATIVE_EQUAL(c, kyosu::cos(cq), 1e-5); } { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; auto q = ke_t(r,i,j,k); auto [s, c] = kyosu::sincos(q); TTS_RELATIVE_EQUAL(s, kyosu::sin(q), 1e-5); diff --git a/test/unit/function/sinh.cpp b/test/unit/function/sinh.cpp index a896146e..88b2b6db 100644 --- a/test/unit/function/sinh.cpp +++ b/test/unit/function/sinh.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::sinh over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::sinh over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_sinh = [](auto x, auto y, auto z, auto t){return cv(boost::math::sinh(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_sinh(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/sinhcosh.cpp b/test/unit/function/sinhcosh.cpp index 435fef3b..db6fc486 100644 --- a/test/unit/function/sinhcosh.cpp +++ b/test/unit/function/sinhcosh.cpp @@ -22,14 +22,14 @@ TTS_CASE_WITH ( "Check kyosu::sinh over quaternion" TTS_RELATIVE_EQUAL(c, kyosu::cosh(r), 1e-5); } { - using ke_t = kyosu::as_complex_t; + using ke_t = kyosu::complex_t; auto cq= ke_t(r,i); auto [s, c] = kyosu::sinhcosh(cq); TTS_RELATIVE_EQUAL(s, kyosu::sinh(cq), 1e-5); TTS_RELATIVE_EQUAL(c, kyosu::cosh(cq), 1e-5); } { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; auto q = ke_t(r,i,j,k); auto [s, c] = kyosu::sinhcosh(q); TTS_RELATIVE_EQUAL(s, kyosu::sinh(q), 1e-5); diff --git a/test/unit/function/sinpi.cpp b/test/unit/function/sinpi.cpp index 68d8051c..042e7b92 100644 --- a/test/unit/function/sinpi.cpp +++ b/test/unit/function/sinpi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::sinpi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/sqr.cpp b/test/unit/function/sqr.cpp index 51eea541..54397cf7 100644 --- a/test/unit/function/sqr.cpp +++ b/test/unit/function/sqr.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::sqr over complex" ) (auto r, auto i) { - auto c = kyosu::to_complex(r,i); + auto c = kyosu::complex(r,i); TTS_RELATIVE_EQUAL(kyosu::sqr(c), c*c, 1e-7); }; @@ -35,7 +35,7 @@ TTS_CASE_WITH ( "Check kyosu::sqr over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q = type(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::sqr(q), q*q, 1e-7); }; diff --git a/test/unit/function/sqr_abs.cpp b/test/unit/function/sqr_abs.cpp index 9cd36e46..3e403d75 100644 --- a/test/unit/function/sqr_abs.cpp +++ b/test/unit/function/sqr_abs.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::sqr_abs over complex" ) (auto r, auto i) { - TTS_ULP_EQUAL(kyosu::sqr_abs(kyosu::to_complex(r,i)), r*r+i*i, 0.5); + TTS_ULP_EQUAL(kyosu::sqr_abs(kyosu::complex(r,i)), r*r+i*i, 0.5); }; TTS_CASE_WITH ( "Check kyosu::sqr_abs over quaternion" @@ -34,6 +34,6 @@ TTS_CASE_WITH ( "Check kyosu::sqr_abs over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_ULP_EQUAL(kyosu::sqr_abs(type(r,i,j,k)), r*r+i*i+j*j+k*k, 0.5); }; diff --git a/test/unit/function/sqrt.cpp b/test/unit/function/sqrt.cpp index 865140ac..e26d8c5a 100644 --- a/test/unit/function/sqrt.cpp +++ b/test/unit/function/sqrt.cpp @@ -16,8 +16,8 @@ TTS_CASE_WITH ( "Check kyosu::sqrt over real" { auto asq = eve::sqrt(eve::abs(v)); TTS_RELATIVE_EQUAL(kyosu::sqrt(v), kyosu::if_else(eve::is_gez(v) - , kyosu::to_complex(asq, T(0)) - , kyosu::to_complex(T(0), asq)), 1.0e-5); + , kyosu::complex(asq, T(0)) + , kyosu::complex(T(0), asq)), 1.0e-5); }; TTS_CASE_WITH ( "Check kyosu::sqrt over complex" @@ -26,7 +26,7 @@ TTS_CASE_WITH ( "Check kyosu::sqrt over complex" ) (auto r, auto i) { - auto c = kyosu::to_complex(r,i); + auto c = kyosu::complex(r,i); TTS_RELATIVE_EQUAL(kyosu::sqr(kyosu::sqrt(c)), c, 1e-5); }; @@ -38,7 +38,7 @@ TTS_CASE_WITH ( "Check kyosu::sqrt over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; auto q = type(r,i,j,k); TTS_RELATIVE_EQUAL(kyosu::sqr((kyosu::sqrt(q))), q, 1e-5); }; diff --git a/test/unit/function/tan.cpp b/test/unit/function/tan.cpp index 33249a75..50fcb66a 100644 --- a/test/unit/function/tan.cpp +++ b/test/unit/function/tan.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::tan over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::tan over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_tan = [](auto x, auto y, auto z, auto t){return cv(boost::math::tan(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_tan(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/tanh.cpp b/test/unit/function/tanh.cpp index 207d0fd3..5dad2911 100644 --- a/test/unit/function/tanh.cpp +++ b/test/unit/function/tanh.cpp @@ -27,7 +27,7 @@ TTS_CASE_WITH ( "Check kyosu::tanh over real" template < typename T > auto cv(boost::math::quaternion const &bq) { - return kyosu::quaternion(bq.R_component_1(), bq.R_component_2(), + return kyosu::quaternion_t(bq.R_component_1(), bq.R_component_2(), bq.R_component_3(), bq.R_component_4()); } @@ -39,7 +39,7 @@ TTS_CASE_WITH ( "Check kyosu::tanh over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using bq_t = boost::math::quaternion>; auto boost_tanh = [](auto x, auto y, auto z, auto t){return cv(boost::math::tanh(bq_t(x, y, z, t))); }; ke_t e([&](auto n, auto){return boost_tanh(r.get(n), i.get(n), j.get(n), k.get(n)); }); diff --git a/test/unit/function/tanpi.cpp b/test/unit/function/tanpi.cpp index fe7c570f..69c5e196 100644 --- a/test/unit/function/tanpi.cpp +++ b/test/unit/function/tanpi.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::tanpi over quaternion" ) (T r, T i, T j, T k) { - using ke_t = kyosu::as_quaternion_t; + using ke_t = kyosu::quaternion_t; using u_t = eve::underlying_type_t; auto pi = eve::pi(eve::as()); auto q = ke_t(r,i,j,k); diff --git a/test/unit/function/trunc.cpp b/test/unit/function/trunc.cpp index f5990bfb..15a434db 100644 --- a/test/unit/function/trunc.cpp +++ b/test/unit/function/trunc.cpp @@ -23,7 +23,7 @@ TTS_CASE_WITH ( "Check kyosu::trunc over complex" ) (auto r, auto i) { - TTS_EQUAL(kyosu::trunc(kyosu::to_complex(r,i)), kyosu::to_complex(eve::trunc(r),eve::trunc(i))); + TTS_EQUAL(kyosu::trunc(kyosu::complex(r,i)), kyosu::complex(eve::trunc(r),eve::trunc(i))); }; TTS_CASE_WITH ( "Check kyosu::trunc over quaternion" @@ -34,7 +34,7 @@ TTS_CASE_WITH ( "Check kyosu::trunc over quaternion" ) (T r, T i, T j, T k) { - using type = kyosu::as_quaternion_t; + using type = kyosu::quaternion_t; TTS_EQUAL(kyosu::trunc(type(r,i,j,k)), type(eve::trunc(r), eve::trunc(i), eve::trunc(j), eve::trunc(k))); }; @@ -47,7 +47,7 @@ TTS_CASE_WITH ( "Check kyosu::trunc over octonion" ) (T r, T i, T j, T k, T l, T li, T lj, T lk) { - using type = kyosu::as_octonion_t; + using type = kyosu::octonion_t; TTS_EQUAL(kyosu::trunc(type(r,i,j,k,l,li,lj,lk)), type(eve::trunc(r), eve::trunc(i), eve::trunc(j), eve::trunc(k) , eve::trunc(l), eve::trunc(li), eve::trunc(lj), eve::trunc(lk) )); }; diff --git a/test/unit/infra/as_cayley_dickinson.cpp b/test/unit/infra/as_cayley_dickinson.cpp index 3f3ac823..9a19c20f 100644 --- a/test/unit/infra/as_cayley_dickinson.cpp +++ b/test/unit/infra/as_cayley_dickinson.cpp @@ -8,117 +8,117 @@ #include #include -TTS_CASE( "Check as_cayley_dickson_n with scalar reals") -{ - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int32_t > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, std::int32_t > ), kyosu::quaternion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, float > ), kyosu::quaternion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, std::int64_t > ), kyosu::quaternion); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, double > ), kyosu::quaternion); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, std::int32_t > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, float > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, std::int64_t > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, double > ), kyosu::octonion ); -}; +// TTS_CASE( "Check as_cayley_dickson_n with scalar reals") +// { +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int32_t > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, std::int32_t > ), kyosu::quaternion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, float > ), kyosu::quaternion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, std::int64_t > ), kyosu::quaternion); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, double > ), kyosu::quaternion); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, std::int32_t > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, float > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, std::int64_t > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, double > ), kyosu::octonion ); +// }; -TTS_CASE( "Check as_cayley_dickson_n with scalar non-reals") -{ - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::complex > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::complex > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::complex > ), kyosu::quaternion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::complex > ), kyosu::quaternion); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::complex > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::complex > ), kyosu::octonion ); +// TTS_CASE( "Check as_cayley_dickson_n with scalar non-reals") +// { +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::complex > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::complex > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::complex > ), kyosu::quaternion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::complex > ), kyosu::quaternion); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::complex > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::complex > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::quaternion > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::quaternion > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::quaternion > ), kyosu::quaternion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::quaternion > ), kyosu::quaternion); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::quaternion > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::quaternion > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::quaternion > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::quaternion > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::quaternion > ), kyosu::quaternion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::quaternion > ), kyosu::quaternion); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::quaternion > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::quaternion > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::octonion > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::octonion > ), kyosu::complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::octonion > ), kyosu::quaternion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::octonion > ), kyosu::quaternion); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::octonion > ), kyosu::octonion ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::octonion > ), kyosu::octonion ); -}; +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::octonion > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, kyosu::octonion > ), kyosu::complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::octonion > ), kyosu::quaternion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, kyosu::octonion > ), kyosu::quaternion); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::octonion > ), kyosu::octonion ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, kyosu::octonion > ), kyosu::octonion ); +// }; -TTS_CASE( "Check as_cayley_dickson_n with mixed scalar") -{ - using kyosu::complex; - using kyosu::quaternion; - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , int > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , std::int64_t > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , float > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , double > ), complex ); +// TTS_CASE( "Check as_cayley_dickson_n with mixed scalar") +// { +// using kyosu::complex; +// using kyosu::quaternion; +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , int > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , std::int64_t > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , float > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , double > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, int , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, int , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, complex>), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, int > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, std::int64_t > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, float > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, double > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, complex>), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, int > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, std::int64_t > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, float > ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, double > ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, int , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, complex, complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, int , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, std::int64_t , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, float , complex> ), complex ); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, double , complex> ), complex ); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, complex, quaternion> ), quaternion ); -}; +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, complex, quaternion> ), quaternion ); +// }; -TTS_CASE( "Check as_cayley_dickson_n on SIMD reals") -{ - using eve::wide; +// TTS_CASE( "Check as_cayley_dickson_n on SIMD reals") +// { +// using eve::wide; - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); -}; +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide> ), wide >); +// }; -TTS_CASE( "Check as_cayley_dickson_n on SIMD non-reals") -{ - using eve::wide; +// TTS_CASE( "Check as_cayley_dickson_n on SIMD non-reals") +// { +// using eve::wide; - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<2, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<4, wide >> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); - TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); -}; +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide >); +// TTS_TYPE_IS((kyosu::as_cayley_dickson_n_t<8, wide >> ), wide>); +// }; diff --git a/test/unit/infra/as_real.cpp b/test/unit/infra/as_real.cpp index 4a749b38..8382e339 100644 --- a/test/unit/infra/as_real.cpp +++ b/test/unit/infra/as_real.cpp @@ -17,7 +17,7 @@ TTS_CASE_TPL( "Check as_real behavior on real types", kyosu::real_types) TTS_CASE_TPL( "Check as_real behavior on non-real types", kyosu::real_types) (tts::type) { - TTS_TYPE_IS(kyosu::as_real_t> , T); - TTS_TYPE_IS(kyosu::as_real_t> , T); - TTS_TYPE_IS(kyosu::as_real_t> , T); + TTS_TYPE_IS(kyosu::as_real_t> , T); + TTS_TYPE_IS(kyosu::as_real_t> , T); + TTS_TYPE_IS(kyosu::as_real_t> , T); }; diff --git a/test/unit/infra/literals.cpp b/test/unit/infra/literals.cpp index d72f17a9..f77745e4 100644 --- a/test/unit/infra/literals.cpp +++ b/test/unit/infra/literals.cpp @@ -12,23 +12,23 @@ TTS_CASE( "Check literals behavior") { using namespace kyosu; - TTS_EQUAL( 3.25_i , (kyosu::complex {0. ,3.25 })); - TTS_EQUAL( 3.25_if, (kyosu::complex {0.f,3.25f })); - TTS_EQUAL( 3.25_j , (kyosu::quaternion {0. ,0. ,3.25 ,0. })); - TTS_EQUAL( 3.25_jf, (kyosu::quaternion {0.f,0.f,3.25f,0.f })); - TTS_EQUAL( 3.25_k , (kyosu::quaternion {0. ,0. ,0. ,3.25 })); - TTS_EQUAL( 3.25_kf, (kyosu::quaternion {0.f,0.f,0.f ,3.25f})); + TTS_EQUAL( 3.25_i , (kyosu::complex (0. ,3.25 ))); + TTS_EQUAL( 3.25_if, (kyosu::complex (0.f,3.25f ))); + TTS_EQUAL( 3.25_j , (kyosu::quaternion (0. ,0. ,3.25 ,0. ))); + TTS_EQUAL( 3.25_jf, (kyosu::quaternion (0.f,0.f,3.25f,0.f ))); + TTS_EQUAL( 3.25_k , (kyosu::quaternion (0. ,0. ,0. ,3.25 ))); + TTS_EQUAL( 3.25_kf, (kyosu::quaternion (0.f,0.f,0.f ,3.25f))); }; TTS_CASE( "Check literals composition") { using namespace kyosu; - TTS_EQUAL( 1. - 2._i , (kyosu::complex {1,-2 })); - TTS_EQUAL( 1. - 2._i + 3._j , (kyosu::quaternion {1,-2,3,0 })); - TTS_EQUAL( 1. - 2._i + 3._j - 4._k , (kyosu::quaternion {1,-2,3,-4})); + TTS_EQUAL( 1. - 2._i , (kyosu::complex (1.,-2. ))); + TTS_EQUAL( 1. - 2._i + 3._j , (kyosu::quaternion (1.,-2.,3.,0. ))); + TTS_EQUAL( 1. - 2._i + 3._j - 4._k , (kyosu::quaternion (1.,-2.,3.,-4.))); - TTS_EQUAL( 1. - 2._if , (kyosu::complex {1,-2 })); - TTS_EQUAL( 1. - 2._if + 3._jf , (kyosu::quaternion {1,-2,3,0 })); - TTS_EQUAL( 1. - 2._if + 3._jf - 4._kf , (kyosu::quaternion {1,-2,3,-4})); + TTS_EQUAL( 1. - 2._if , (kyosu::complex (1.f,-2.f ))); + TTS_EQUAL( 1. - 2._if + 3._jf , (kyosu::quaternion (1.f,-2.f,3.f,0.f ))); + TTS_EQUAL( 1. - 2._if + 3._jf - 4._kf , (kyosu::quaternion (1.f,-2.f,3.f,-4.f))); }; diff --git a/test/unit/quaternion/constructors.cpp b/test/unit/quaternion/constructors.cpp index 082988c7..f72d5658 100644 --- a/test/unit/quaternion/constructors.cpp +++ b/test/unit/quaternion/constructors.cpp @@ -17,16 +17,16 @@ TTS_CASE_TPL( "Check quaternion constructor from constants", kyosu::scalar_real_ auto wpi = w_t(spi); auto wo = w_t(so); - kyosu::quaternion z_sd{}; - kyosu::quaternion z_s0{spi}; - kyosu::quaternion z_ss{spi,so, so, so}; - eve::wide> z_vd{}; - eve::wide> z_vs{wo,spi,spi,spi}; - eve::wide> z_sv{spi,wo,wo,wo}; - eve::wide> z_vv{wo,wpi,wpi,wpi}; + kyosu::quaternion_t z_sd{}; + kyosu::quaternion_t z_s0{spi}; + kyosu::quaternion_t z_ss{spi,so, so, so}; + eve::wide> z_vd{}; + eve::wide> z_vs{wo,spi,spi,spi}; + eve::wide> z_sv{spi,wo,wo,wo}; + eve::wide> z_vv{wo,wpi,wpi,wpi}; // auto a = kumi::make_tuple(wpi,wpi,wpi); - // eve::wide> z_ra = eve::to_quaternion(wo,a); + // eve::wide> z_ra = eve::quaternion(wo,a); TTS_EQUAL( get<0>(z_sd), T{0} ); TTS_EQUAL( get<1>(z_sd), T{0} ); @@ -78,12 +78,12 @@ TTS_CASE_TPL("Check quaternion constructor from lambda", kyosu::scalar_real_type auto fill_i = [](auto i, auto) { return T(1)/(1+i); }; auto fill_j = [](auto i, auto) { return T(i); }; auto fill_k = [](auto , auto) { return T(1); }; - auto fill = [](auto i, auto) { return kyosu::quaternion(T(1+i),T(1)/(1+i),T(i),T(1)); }; + auto fill = [](auto i, auto) { return kyosu::quaternion_t(T(1+i),T(1)/(1+i),T(i),T(1)); }; - eve::wide> z_l(fill); - eve::wide> z_ll(fill_r, fill_i, fill_j, fill_k); - eve::wide> z_lc(fill_r, T{1.25}, T{2.25}, T{3.25}); - eve::wide> z_cl(T{8.8},fill_i, T(1.0), fill_k); + eve::wide> z_l(fill); + eve::wide> z_ll(fill_r, fill_i, fill_j, fill_k); + eve::wide> z_lc(fill_r, T{1.25}, T{2.25}, T{3.25}); + eve::wide> z_cl(T{8.8},fill_i, T(1.0), fill_k); TTS_EQUAL( get<0>(z_l) , w_t(fill_r)); TTS_EQUAL( get<1>(z_l) , w_t(fill_i)); @@ -115,14 +115,14 @@ TTS_CASE_TPL("Check quaternion copy/assignment", kyosu::scalar_real_types) auto wpi = w_t(spi); auto wo = w_t(so); - kyosu::quaternion z_s{spi,so, so, so}; + kyosu::quaternion_t z_s{spi,so, so, so}; auto z_sc{z_s}; - kyosu::quaternion z_sa; + kyosu::quaternion_t z_sa; z_sa = z_s; - eve::wide> z_v{wo,wpi, wpi, wpi}; + eve::wide> z_v{wo,wpi, wpi, wpi}; auto z_vc{z_v}; - eve::wide> z_va; + eve::wide> z_va; z_va = z_v; TTS_EQUAL ( z_sc, z_s ); diff --git a/test/unit/quaternion/slerp.cpp b/test/unit/quaternion/slerp.cpp index a5aa3fe5..f4e9eb1d 100644 --- a/test/unit/quaternion/slerp.cpp +++ b/test/unit/quaternion/slerp.cpp @@ -24,9 +24,8 @@ TTS_CASE_WITH ( "Check behavior of slerp on" (T const& a0, T const& a1, T const& a2, T const& a3 , T const& a4, T const& a5, T const& a6, T const& a7) { -// auto pr = [](auto name, auto v){std::cout << name << v[0] << ", " << v[1] << ", " << v[2] << std::endl; }; using e_t = eve::element_type_t; - using q_t = kyosu::as_quaternion_t; + using q_t = kyosu::quaternion_t; if constexpr(sizeof(e_t) == 8) { auto z1 = kyosu::sign(q_t(a0, a1, a2, a3)); diff --git a/test/unit/quaternion/to_angle_axis.cpp b/test/unit/quaternion/to_angle_axis.cpp index e8cb9b06..44dfaea8 100644 --- a/test/unit/quaternion/to_angle_axis.cpp +++ b/test/unit/quaternion/to_angle_axis.cpp @@ -19,25 +19,25 @@ TTS_CASE_WITH ( "Check behavior of from_angle_axis on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { { - auto q = kyosu::sign(kyosu::to_quaternion(a0, a1, a2, a3)); + auto q = kyosu::sign(kyosu::quaternion(a0, a1, a2, a3)); auto [a, v] = kyosu::to_angle_axis(q); std::span vv(v); auto q1 = kyosu::from_angle_axis(a, vv); TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); } { - auto c = kyosu::sign(kyosu::to_complex(a0, a1)); + auto c = kyosu::sign(kyosu::complex(a0, a1)); auto [a, v] = kyosu::to_angle_axis(c); std::span vv(v); auto c1 = kyosu::from_angle_axis(a, vv); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(c), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); } { auto [a, v] = kyosu::to_angle_axis(kyosu::sign(a0)); std::span vv(v); auto q1 = kyosu::from_angle_axis(a, vv); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(eve::sign(a0)), q1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(eve::sign(a0)), q1, 1.0e-5); } diff --git a/test/unit/quaternion/to_cylindrical.cpp b/test/unit/quaternion/to_cylindrical.cpp index ffaaf966..a8ee0faf 100644 --- a/test/unit/quaternion/to_cylindrical.cpp +++ b/test/unit/quaternion/to_cylindrical.cpp @@ -19,22 +19,22 @@ TTS_CASE_WITH ( "Check behavior of to_cylindrical on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { { - auto q = kyosu::to_quaternion(a0, a1, a2, a3); + auto q = kyosu::quaternion(a0, a1, a2, a3); auto [r1, t1, r2, t2] = kyosu::to_cylindrical(q); auto q1 = kyosu::from_cylindrical(r1, t1, r2, t2); TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); } { - auto c = kyosu::to_complex(a0, a1); + auto c = kyosu::complex(a0, a1); auto [r1, t1, r2, t2] = kyosu::to_cylindrical(c); auto c1 = kyosu::from_cylindrical(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(c), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); } { auto [r1, t1, r2, t2] = kyosu::to_cylindrical(a0); auto q1 = kyosu::from_cylindrical(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(a0), q1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(a0), q1, 1.0e-5); } diff --git a/test/unit/quaternion/to_multipolar.cpp b/test/unit/quaternion/to_multipolar.cpp index 3e89ec8d..3cb4bcd7 100644 --- a/test/unit/quaternion/to_multipolar.cpp +++ b/test/unit/quaternion/to_multipolar.cpp @@ -19,22 +19,22 @@ TTS_CASE_WITH ( "Check behavior of from_multipolar on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { { - auto q = kyosu::to_quaternion(a0, a1, a2, a3); + auto q = kyosu::quaternion(a0, a1, a2, a3); auto [r1, t1, r2, t2] = kyosu::to_multipolar(q); auto q1 = kyosu::from_multipolar(r1, t1, r2, t2); TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); } { - auto c = kyosu::to_complex(a0, a1); + auto c = kyosu::complex(a0, a1); auto [r1, t1, r2, t2] = kyosu::to_multipolar(c); auto c1 = kyosu::from_multipolar(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(c), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); } { auto [r1, t1, r2, t2] = kyosu::to_multipolar(a0); auto q1 = kyosu::from_multipolar(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(a0), q1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(a0), q1, 1.0e-5); } diff --git a/test/unit/quaternion/to_quaternion.cpp b/test/unit/quaternion/to_quaternion.cpp index 2a76f944..7fa2b713 100644 --- a/test/unit/quaternion/to_quaternion.cpp +++ b/test/unit/quaternion/to_quaternion.cpp @@ -13,8 +13,8 @@ TTS_CASE_TPL( "Check to_quaternion converter from constants", kyosu::scalar_real { using e_t = T; using w_t = eve::wide; - using q_t = kyosu::quaternion; - using wq_t = eve::wide>; + using q_t = kyosu::quaternion_t; + using wq_t = eve::wide>; auto zer (e_t(0)); auto wzer(w_t(0)); auto o(e_t(1)); @@ -22,20 +22,20 @@ TTS_CASE_TPL( "Check to_quaternion converter from constants", kyosu::scalar_real auto wo(w_t(1)); auto wz(w_t(0)); - q_t z_0 = kyosu::to_quaternion(zer); + q_t z_0 = kyosu::quaternion(zer); TTS_EQUAL( get<0>(z_0), T{0}); TTS_EQUAL( get<1>(z_0), T{0}); TTS_EQUAL( get<2>(z_0), T{0}); TTS_EQUAL( get<3>(z_0), T{0}); - wq_t wz_0 = kyosu::to_quaternion(wzer); + wq_t wz_0 = kyosu::quaternion(wzer); TTS_EQUAL( get<0>(wz_0), w_t{0}); TTS_EQUAL( get<1>(wz_0), w_t{0}); TTS_EQUAL( get<2>(wz_0), w_t{0}); TTS_EQUAL( get<3>(wz_0), w_t{0}); { - auto z_1 = kyosu::to_quaternion(o, o); + auto z_1 = kyosu::quaternion(o, o); TTS_EQUAL( get<0>(z_1), T(1)); TTS_EQUAL( get<1>(z_1), T(1)); @@ -43,34 +43,34 @@ TTS_CASE_TPL( "Check to_quaternion converter from constants", kyosu::scalar_real TTS_EQUAL( get<3>(z_1), T(0)); - wq_t wz_1 = kyosu::to_quaternion(wo, wo); + wq_t wz_1 = kyosu::quaternion(wo, wo); TTS_EQUAL( get<0>(wz_1), wo); TTS_EQUAL( get<1>(wz_1), wo); TTS_EQUAL( get<2>(wz_1), wz); TTS_EQUAL( get<3>(wz_1), wz); - wq_t wz_2 = kyosu::to_quaternion(wo, o, wo, o); + wq_t wz_2 = kyosu::quaternion(wo, o, wo, o); TTS_EQUAL( get<0>(wz_2), wo); TTS_EQUAL( get<1>(wz_2), wo); TTS_EQUAL( get<2>(wz_2), wo); TTS_EQUAL( get<3>(wz_2), wo); - wq_t wz_3 = kyosu::to_quaternion(o, wo, z, o); + wq_t wz_3 = kyosu::quaternion(o, wo, z, o); TTS_EQUAL( get<0>(wz_3), wo); TTS_EQUAL( get<1>(wz_3), wo); TTS_EQUAL( get<2>(wz_3), wz); TTS_EQUAL( get<3>(wz_3), wo); } - using c_t = kyosu::complex; - auto zcc = kyosu::to_quaternion(c_t(1, 1), c_t(0, 1)); + using c_t = kyosu::complex_t; + auto zcc = kyosu::quaternion(c_t(1, 1), c_t(0, 1)); TTS_EQUAL( get<0>(zcc), T(1)); TTS_EQUAL( get<1>(zcc), T(1)); TTS_EQUAL( get<2>(zcc), T(0)); TTS_EQUAL( get<3>(zcc), T(1)); - auto zc = kyosu::to_quaternion(c_t(1, 1)); + auto zc = kyosu::quaternion(c_t(1, 1)); TTS_EQUAL( get<0>(zc), T(1)); TTS_EQUAL( get<1>(zc), T(1)); diff --git a/test/unit/quaternion/to_rotation_matrix.cpp b/test/unit/quaternion/to_rotation_matrix.cpp index 3d15152a..b88e9ede 100644 --- a/test/unit/quaternion/to_rotation_matrix.cpp +++ b/test/unit/quaternion/to_rotation_matrix.cpp @@ -30,7 +30,7 @@ TTS_CASE_WITH ( "Check behavior of to_rotation_matrix on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { using e_t = eve::element_type_t ; - using wq_t = eve::wide, eve::cardinal_t>; + using wq_t = eve::wide, eve::cardinal_t>; std::array v{T(1), T(2), T(3)}; auto q = kyosu::sign(wq_t(a0, a1, a2, a3)); wq_t qv(0, v[0], v[1], v[2]); diff --git a/test/unit/quaternion/to_semipolar.cpp b/test/unit/quaternion/to_semipolar.cpp index 98875367..ce36b464 100644 --- a/test/unit/quaternion/to_semipolar.cpp +++ b/test/unit/quaternion/to_semipolar.cpp @@ -19,22 +19,22 @@ TTS_CASE_WITH ( "Check behavior of to_semipolar on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { { - auto q = kyosu::to_quaternion(a0, a1, a2, a3); + auto q = kyosu::quaternion(a0, a1, a2, a3); auto [r1, t1, r2, t2] = kyosu::to_semipolar(q); auto q1 = kyosu::from_semipolar(r1, t1, r2, t2); TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); } { - auto c = kyosu::to_complex(a0, a1); + auto c = kyosu::complex(a0, a1); auto [r1, t1, r2, t2] = kyosu::to_semipolar(c); auto c1 = kyosu::from_semipolar(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(c), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); } { auto [r1, t1, r2, t2] = kyosu::to_semipolar(a0); auto q1 = kyosu::from_semipolar(r1, t1, r2, t2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(a0), q1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(a0), q1, 1.0e-5); } diff --git a/test/unit/quaternion/to_spherical.cpp b/test/unit/quaternion/to_spherical.cpp index 6c507f3c..21c473b9 100644 --- a/test/unit/quaternion/to_spherical.cpp +++ b/test/unit/quaternion/to_spherical.cpp @@ -19,22 +19,22 @@ TTS_CASE_WITH ( "Check behavior of to_spherical on wide" (T const& a0, T const& a1, T const& a2, T const& a3 ) { { - auto q = kyosu::to_quaternion(a0, a1, a2, a3); + auto q = kyosu::quaternion(a0, a1, a2, a3); auto [rho, theta, phi1, phi2] = kyosu::to_spherical(q); auto q1 = kyosu::from_spherical(rho, theta, phi1, phi2); TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); } { - auto c = kyosu::to_complex(a0, a1); + auto c = kyosu::complex(a0, a1); auto [rho, theta, ph11, phi2] = kyosu::to_spherical(c); auto c1 = kyosu::from_spherical(rho, theta, ph11, phi2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(c), c1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); } { auto [rho, theta, ph11, phi2] = kyosu::to_spherical(a0); auto q1 = kyosu::from_spherical(rho, theta, ph11, phi2); - TTS_RELATIVE_EQUAL(kyosu::to_quaternion(a0), q1, 1.0e-5); + TTS_RELATIVE_EQUAL(kyosu::quaternion(a0), q1, 1.0e-5); }