diff --git a/doc/index.md b/doc/index.md index 647805bf..386c16d7 100644 --- a/doc/index.md +++ b/doc/index.md @@ -58,9 +58,15 @@ Higher are the dimensions weirder are these algebras - quaternion is a non-commutative field - octonion is a non associative (but alternative) division algebra +The functions [commutator](@ref kyosu::commutator ) (resp. [associator](@ref kyosu::associator )) +can be used to see if two (resp. three) Cayley-Dickson value commute (resp. associate). + Greater dimensions are not even alternative but keep power-associativity which allows to define most elementary functions. +@note Let us recall that alternative means that every subalgrebra generated by + two elements is associative. + What does this implementation provide ====================================== @@ -69,32 +75,48 @@ All operators and functions implemented can receive a mix of scalar or simd of c dimensionnality and are defined in the namespace kyosu. Of course the algebra operation +, -, * and / are provided, but as \ is not an usable **C++** -character as an operator, the left division a\b is provided as the call ldiv(a,b). +character as an operator, the left division `a \ b` is provided as the call ldiv(a,b). Constructors ------------ complex and quaternion can be constructed using callables facilities `complex` and `quaternion`. -complex can also be constructed from their polar representation +complex can also be constructed from their polar representation\n quaternion from various parametrizations of \f$\mathbb{R}^4\f$ or from \f$\mathbb{R}^3\f$ rotations: - * angle and axis - * cylindrical - * cylindricospherical - * euler - * multipolar - * rotation_matrix - * semipolar - * spherical + | | | | + |-------------------------|-----------------------------------------------------------------|-------------------------------------------------------------| + | angle and axis | [from_angle_axis](@ref kyosu::from_angle_axis ) | [to_angle_axis](@ref kyosu::to_angle_axis ) | + | cylindrical | [from_cylindrical](@ref kyosu::from_cylindrical ) | [to_cylindrical](@ref kyosu::to_cylindrical ) | + | cylindrospherical | [from_cylindrospherical](@ref kyosu::from_cylindrospherical ) | [to_cylindrospherical](@ref kyosu::to_cylindrospherical ) | + | euler | [from_euler](@ref kyosu::from_euler ) | [to_euler](@ref kyosu::to_euler ) | + | multipolar | [from_multipolar](@ref kyosu::from_multipolar ) | [to_multipolar](@ref kyosu::to_multipolar ) | + | rotation matrix | [from_rotation_matrix](@ref kyosu::from_rotation_matrix ) | [to_rotation_matrix](@ref kyosu::to_rotation_matrix ) | + | semipolar | [from_semipolar](@ref kyosu::from_semipolar ) | [to_semipolar](@ref kyosu::to_semipolar ) | + | spherical | [from_spherical](@ref kyosu::from_spherical ) | [to_spherical](@ref kyosu::to_spherical ) | + | two vectors | [align](@ref kyosu::align ) | | + +The third column references to the corresponding to_xxx version that gives back the +chosen representation from a quaternion input. + +TODO cayley_dickson construction by a function. + +Operators +--------- -TODO cayley_dickson +Operators (as said before) `+`, `-`, `*` and `/` can be used in infix form and can mix cayley-dickson values of + different dimensinalities. Of course the biggest dimensionlity is recovered in the output. + +Prefix forms are also provided as `add`, `sub`, `multiply` and `div`. Also plus and minus for unary versions. + +The left division sometimes necessary if the dimensionality is greater than 2 is given as `ldiv`. Functions --------- Most **KYOSU** callables are usable with all cayley_dickson types. The exception being mainly special - complex functions and rotation related quaternion usage. +complex functions and rotation related quaternion usage. @warning: **EVE** callables that correspond to mathematical functions that are only defined on a proper part of the real axis as, for example, `acos` DOES NOT ever provide the same result @@ -107,10 +129,48 @@ Most **KYOSU** callables are usable with all cayley_dickson types. The exception * callables usable with all cayley_dickson types - Most **EVE** arithmetic functions are provided. - - * callables usable with complex only - - * callables usable with quaternion (and complex) only - -Most **EVE** arithmetic functions are provided. + Most **EVE** arithmetic and math functions are provided. + + | | | | | | + |--------------|---------------|-----------------|------------|-----------------| + | [abs](@ref kyosu::abs ) | [acos](@ref kyosu::acos ) | [acosh](@ref kyosu::acosh ) | [acospi](@ref kyosu::acospi ) | [acot](@ref kyosu::acot ) | + | [acotpi](@ref kyosu::acotpi ) | [atanpi](@ref kyosu::atanpi ) | [acoth](@ref kyosu::acoth ) | [arg](@ref kyosu::arg ) | [acsc](@ref kyosu::acsc ) | + | [acscpi](@ref kyosu::acscpi ) | [acsch](@ref kyosu::acsch ) | [asec](@ref kyosu::asec ) | [asecpi](@ref kyosu::asecpi ) | [asech](@ref kyosu::asech ) | + | [asin](@ref kyosu::asin ) | [asinpi](@ref kyosu::asinpi ) | [asinh](@ref kyosu::asinh ) | [atan](@ref kyosu::atan ) | [atanh](@ref kyosu::atanh ) | + | [average](@ref kyosu::average ) | [ceil](@ref kyosu::ceil ) | [conj](@ref kyosu::conj ) | [cos](@ref kyosu::cos ) | [cosh](@ref kyosu::cosh ) | + | [cospi](@ref kyosu::cospi ) | [cot](@ref kyosu::cot ) | [cotpi](@ref kyosu::cotpi ) | [coth](@ref kyosu::coth ) | [convert](@ref kyosu::convert ) | + | [csc](@ref kyosu::csc ) | [cscpi](@ref kyosu::cscpi ) | [csch](@ref kyosu::csch ) | [dec](@ref kyosu::dec ) | [dist](@ref kyosu::dist ) | + | [dot](@ref kyosu::dot ) | [exp](@ref kyosu::exp ) | [exp10](@ref kyosu::exp10 ) | [exp2](@ref kyosu::exp2 ) | [exp_i](@ref kyosu::exp_i ) | + | [exp_ipi](@ref kyosu::exp_ipi ) | [expm1](@ref kyosu::expm1 ) | [expmx2](@ref kyosu::expmx2 ) | [expx2](@ref kyosu::expx2 ) | [floor](@ref kyosu::floor ) | + | [frac](@ref kyosu::frac ) | [from_polar](@ref kyosu::from_polar ) | [hypot](@ref kyosu::hypot ) | [if_else](@ref kyosu::if_else )| [inc](@ref kyosu::inc ) | + | [ipart](@ref kyosu::ipart ) | [is_denormal](@ref kyosu::is_denormal ) | [is_equal](@ref kyosu::is_equal ) | [is_eqz](@ref kyosu::is_eqz ) | [is_finite](@ref kyosu::is_finite ) | + | [is_infinite](@ref kyosu::is_infinite ) | [is_imag](@ref kyosu::is_imag ) | [is_nan](@ref kyosu::is_nan ) | [is_nez](@ref kyosu::is_nez ) | [is_not_denormal](@ref kyosu::is_not_denormal ) | + | [is_not_equal](@ref kyosu::is_not_equal ) | [is_not_finite](@ref kyosu::is_not_finite ) | [is_not_infinite](@ref kyosu::is_not_finite ) | [is_not_nan](@ref kyosu::is_not_nan ) | [is_not_real](@ref kyosu::is_not_real ) | + | [is_pure](@ref kyosu::is_pure ) | [is_real](@ref kyosu::is_real ) | [is_unitary](@ref kyosu::is_unitary ) | [jpart](@ref kyosu::jpart ) | [kpart](@ref kyosu::kpart ) | + | [ldiv](@ref kyosu::ldiv ) | [lerp](@ref kyosu::lerp ) | [log](@ref kyosu::log ) | [log10](@ref kyosu::log10 ) | [log1p](@ref kyosu::log1p ) | + | [log_abs](@ref kyosu::log_abs ) | [log2](@ref kyosu::log2 ) | [lpnorm](@ref kyosu::lpnorm ) | [manhattan](@ref kyosu::manhattan ) | [minus](@ref kyosu::minus ) | + | [lpart](@ref kyosu::lpart ) | [lipart](@ref kyosu::lipart ) | [ljpart](@ref kyosu::ljpart ) | [lkpart](@ref kyosu::lkpart ) | | + | [nearest](@ref kyosu::nearest ) | [oneminus](@ref kyosu::oneminus ) | [pow](@ref kyosu::pow ) | [pow1p](@ref kyosu::pow1p ) | [pow_abs](@ref kyosu::pow_abs ) | + | [powm1](@ref kyosu::powm1 ) | [proj](@ref kyosu::proj ) | [pure](@ref kyosu::imag ) | [radinpi](@ref kyosu::radinpi )| [real](@ref kyosu::real ) | + | [rec](@ref kyosu::rec ) | [reldist](@ref kyosu::reldist ) | [sec](@ref kyosu::sec ) | [secpi](@ref kyosu::secpi ) | [sech](@ref kyosu::sech ) | + | [sign](@ref kyosu::sign ) | [sin](@ref kyosu::sin ) | [sinc](@ref kyosu::sinc ) | [sincos](@ref kyosu::sincos ) | [sinpi](@ref kyosu::sinpi ) | + | [sinpicospi](@ref kyosu::sinpicospi ) | [sinh](@ref kyosu::sinh ) | [sinhcosh](@ref kyosu::sinhcosh ) | [slerp](@ref kyosu::slerp ) | [sqr](@ref kyosu::sqr ) | + | [sqr_abs](@ref kyosu::sqr_abs ) | [sqrt](@ref kyosu::sqrt ) | [tan](@ref kyosu::tan ) | [tanpi](@ref kyosu::tanpi ) | [tanh](@ref kyosu::tanh ) | + | [to_polar](@ref kyosu::to_polar ) | [trunc](@ref kyosu::trunc ) | | | | + + * callables usable with complex or real only. These are mainly implementation of some classical meromorphic functions. + + | | | | | | + |------------------|------------------|--------------------|------------------|---------------| + | [beta](@ref kyosu::beta ) | [deta](@ref kyosu::deta ) | [digamma](@ref kyosu::digamma ) | [erf](@ref kyosu::erf ) | [erfcx](@ref kyosu::erfcx ) | + | [erfi](@ref kyosu::erfi ) | [eta](@ref kyosu::eta ) | [faddeeva](@ref kyosu::faddeeva ) | [lambda](@ref kyosu::lambda ) | [lbeta](@ref kyosu::lbeta ) | + | [log_abs_gamma](@ref kyosu::log_abs_gamma ) | [log_gamma](@ref kyosu::log_gamma ) | [lrising_factorial](@ref kyosu::lrising_factorial ) | [rising_factorial](@ref kyosu::rising_factorial ) | [tgamma](@ref kyosu::tgamma ) | + | [zeta](@ref kyosu::zeta ) | | | | | + + * callables usable with quaternion complex and real only + + These functions are related to \f$\mathbb{R}^3\f$ rotations + + | | | | + |-----------|------------|------------| + | [rot_angle](@ref kyosu::rot_angle) | [rot_axis](@ref kyosu::rot_axis) | [rotate_vec](@ref kyosu::rotate_vec) | diff --git a/include/kyosu/complex/beta.hpp b/include/kyosu/complex/beta.hpp index 523163ee..34818d2a 100644 --- a/include/kyosu/complex/beta.hpp +++ b/include/kyosu/complex/beta.hpp @@ -23,7 +23,8 @@ namespace kyosu::tags 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)) + 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); } @@ -40,7 +41,8 @@ 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$. +//! @brief Computes the beta function: \f$\displaystyle \mathbf{B}(x, y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$ +//! for real or complex entries. //! //! **Defined in Header** //! @@ -53,28 +55,18 @@ namespace kyosu //! @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 +//! auto beta(auto x, auto y) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `x`,`y` : Values to process. +//! * `x`,`y` : Values to process. Can be a mix of complex and real floating values and complex values. //! //! **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. +//! 1. If x and y are real typed values returns \f$\displaystyle \mathbf{B}(x,y) = \int_0^1 t^{x-1}(1-t)^{y-1}\mbox{d}t\f$ +//! 2. The complex value \f$\displaystyle \mathbb{B}(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\f$ is returned. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/deta.hpp b/include/kyosu/complex/deta.hpp index 35d1576e..4768962f 100644 --- a/include/kyosu/complex/deta.hpp +++ b/include/kyosu/complex/deta.hpp @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var deta -//! @brief Computes the Dirichlet sums \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(kn+1)^z}\f$. +//! @brief Computes the Dirichlet sums \f$ \displaystyle \sum_{n = 0}^\infty \frac{(-1)^n}{(kn+1)^z}\f$. //! //! **Defined in Header** //! @@ -56,19 +56,19 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto deta(K, k, T z) noexcept; //1 -//! template constexpr auto deta(K, k, T z) noexcept; //2 +//! 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. +//! * `z` : complex or real value to process. //! //! **Return value** //! -//! Returns the Dirichlet sum \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(kn+1)^z}\f$ +//! Returns the Dirichlet sum \f$ \displaystyle \sum_{n = 0}^\infty \frac{(-1)^n}{(kn+1)^z}\f$ //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/digamma.hpp b/include/kyosu/complex/digamma.hpp index 2ba2798e..eea3ecd6 100644 --- a/include/kyosu/complex/digamma.hpp +++ b/include/kyosu/complex/digamma.hpp @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var digamma -//! @brief Computes the Digamma function i.e. the logarithmic derivative of the \f$\Gamma\f$ +//! @brief Computes the Digamma function i.e. the logarithmic derivative of the \f$\Gamma\f$ function //! //! **Defined in Header** //! @@ -53,13 +53,13 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T digamma(T z) noexcept; -//! template constexpr T digamma(T z) noexcept; +//! template constexpr T digamma(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Value to process. +//! * `z` : real or complex value to process. //! //! **Return value** //! diff --git a/include/kyosu/complex/erf.hpp b/include/kyosu/complex/erf.hpp index cd1e58d0..fd88ff58 100644 --- a/include/kyosu/complex/erf.hpp +++ b/include/kyosu/complex/erf.hpp @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z returns eve::erf(z). //! //! 2. The value of the error function in the complex plane is returned //! diff --git a/include/kyosu/complex/erfcx.hpp b/include/kyosu/complex/erfcx.hpp index db5a0e4a..abdd8f01 100644 --- a/include/kyosu/complex/erfcx.hpp +++ b/include/kyosu/complex/erfcx.hpp @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z return eve::erfcx(z). //! //! 2. The value of the normalized complementary error function is returned. //! diff --git a/include/kyosu/complex/erfi.hpp b/include/kyosu/complex/erfi.hpp index 7b69a037..5390a945 100644 --- a/include/kyosu/complex/erfi.hpp +++ b/include/kyosu/complex/erfi.hpp @@ -65,7 +65,7 @@ namespace kyosu //! //! **Parameters** //! -//! * `z` : Vcomplex or real value to process. +//! * `z` : complex or real value to process. //! //! **Return value** //! diff --git a/include/kyosu/complex/eta.hpp b/include/kyosu/complex/eta.hpp index 0f64ba4d..1ddff424 100644 --- a/include/kyosu/complex/eta.hpp +++ b/include/kyosu/complex/eta.hpp @@ -64,11 +64,11 @@ namespace kyosu //! //! **Parameters** //! -//! * `z` : Vcomplex or real value to process. +//! * `z` : complex 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$ +//! Returns the Dirichlet alternating zeta function: \f$ \displaystyle \sum_0^\infty \frac{(-1)^n}{(n+1)^z}\f$ //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/lambda.hpp b/include/kyosu/complex/lambda.hpp index b0aa70c4..ce0dd606 100644 --- a/include/kyosu/complex/lambda.hpp +++ b/include/kyosu/complex/lambda.hpp @@ -67,7 +67,7 @@ namespace kyosu //! //! **Parameters** //! -//! * `z` : Vcomplex or real value to process. +//! * `z` : complex or real value to process. //! //! **Return value** //! diff --git a/include/kyosu/complex/log_abs_gamma.hpp b/include/kyosu/complex/log_abs_gamma.hpp index ae38ffad..269f3eca 100644 --- a/include/kyosu/complex/log_abs_gamma.hpp +++ b/include/kyosu/complex/log_abs_gamma.hpp @@ -56,7 +56,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T log_abs_gamma(T z) noexcept; -//! template constexpr T log_abs_gamma(T z) noexcept; +//! template constexpr T log_abs_gamma(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/complex/log_gamma.hpp b/include/kyosu/complex/log_gamma.hpp index 757fc8c0..e7f00c14 100644 --- a/include/kyosu/complex/log_gamma.hpp +++ b/include/kyosu/complex/log_gamma.hpp @@ -54,7 +54,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T log_gamma(T z) noexcept; -//! template constexpr T log_gamma(T z) noexcept; +//! template constexpr T log_gamma(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/complex/lrising_factorial.hpp b/include/kyosu/complex/lrising_factorial.hpp index 5d1f19f7..287beec5 100644 --- a/include/kyosu/complex/lrising_factorial.hpp +++ b/include/kyosu/complex/lrising_factorial.hpp @@ -73,7 +73,7 @@ namespace kyosu //! //! **Return value** //! -//! @brief Computes the Rising Factorial function i.e. \f$\log\frac{\Gamma(x+y)}{\Gamma(x)}\f$. +//! @brief Computes the logarithm Rising Factorial function i.e. \f$\log\frac{\Gamma(x+y)}{\Gamma(x)}\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/tgamma.hpp b/include/kyosu/complex/tgamma.hpp index 86219211..79d4944a 100644 --- a/include/kyosu/complex/tgamma.hpp +++ b/include/kyosu/complex/tgamma.hpp @@ -55,7 +55,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T tgamma(T z) noexcept; -//! template constexpr T tgamma(T z) noexcept; +//! template constexpr T tgamma(T z) noexcept; //! } //! @endcode //! @@ -65,7 +65,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns \f$\Gamma(z)\f$. If z is floating the result is as if complex(z) was used in the call. +//! Returns \f$\Gamma(z)\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/complex/zeta.hpp b/include/kyosu/complex/zeta.hpp index ea909afc..2115450f 100644 --- a/include/kyosu/complex/zeta.hpp +++ b/include/kyosu/complex/zeta.hpp @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var zeta -//! @brief Computes the Riemann \f$\zeta\f$ \f$ \displaystyle \sum_0^\infty \frac{1}{(n+1)^z}\f$. +//! @brief Computes the Riemann \f$ \displaystyle\zeta(z)=\sum_0^\infty \frac{1}{(n+1)^z}\f$. //! //! **Defined in Header** //! @@ -56,19 +56,18 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto zeta(K, k, T z) noexcept; //1 -//! template constexpr auto zeta(K, k, T z) noexcept; //2 +//! template constexpr auto zeta(T z) noexcept; +//! template constexpr auto zeta(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `k` : scalar unsigned value, parameter of the sum. -//! * `z` : Vcomplex or real value to process. +//! * `z` : complex 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$ +//! Returns the Dirichlet zeta function: \f$ \displaystyle \sum_0^\infty \frac{1}{(n+1)^z}\f$ //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions.hpp b/include/kyosu/functions.hpp index 2d8e23b7..2be2f76e 100644 --- a/include/kyosu/functions.hpp +++ b/include/kyosu/functions.hpp @@ -29,10 +29,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -88,6 +90,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -164,6 +170,7 @@ #include #include #include +#include #include #include #include diff --git a/include/kyosu/functions/abs.hpp b/include/kyosu/functions/abs.hpp index 80966659..be9b4b0b 100644 --- a/include/kyosu/functions/abs.hpp +++ b/include/kyosu/functions/abs.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(abs_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::abs(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr as_real_t abs(T z) noexcept; -//! template constexpr T abs(T z) noexcept; +//! template constexpr T abs(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! **Return value** //! //! * Returns the modulus of its argument which always is a floating ordered value. -//! The modulus is the square root of the square of the absolute values of the components. +//! The modulus is the square root of the sum of the square of the absolute value of each component. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acos.hpp b/include/kyosu/functions/acos.hpp index 4aaba088..c2c7c900 100644 --- a/include/kyosu/functions/acos.hpp +++ b/include/kyosu/functions/acos.hpp @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acos(T z) noexcept; //1 +//! template constexpr auto acos(T z) noexcept; //1 //! template constexpr auto atan(T z) noexcept; //2 //! template constexpr auto acos(T z) noexcept; //3 //! } @@ -68,13 +68,12 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns elementwise the complex principal value -//! of the arc cosine of the input. +//! 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. //! -//! * for every z: eve::acos(eve::conj(z)) == eve::conj(std::acos(z)) +//! * for every z: kyosu::acos( [kyosu::conj](@ref kyosu::conj)(z) ) == kyosu::conj([kyosu::acos](@ref kyosu::acos)(z)) //! * If z is \f$\pm0\f$, the result is \f$\pi/2\f$ //! * If z is \f$i NaN\f$, the result is \f$\pi/2+ i NaN\f$ //! * If z is \f$x+i\infty\f$ (for any finite x), the result is \f$\pi/2-i\infty\f$ @@ -90,7 +89,9 @@ namespace kyosu //! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ //! //! 3. Returns \f$I_z \mathrm{acosh}(z)\f$ where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and -//! \f$\underline{z}\f$ is the pure part of \f$z\f$. +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. +//! template constexpr T cosh(T z) noexcept; +//! } //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acosh.hpp b/include/kyosu/functions/acosh.hpp index f19c5c3e..85c96256 100644 --- a/include/kyosu/functions/acosh.hpp +++ b/include/kyosu/functions/acosh.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acosh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acosh{}; @@ -57,7 +57,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acosh(T z) noexcept; //1 +//! template constexpr auto acosh(T z) noexcept; //1 //! template constexpr auto acosh(T z) noexcept; //2 //! template constexpr auto acosh(T z) noexcept; //3 //! } @@ -69,25 +69,24 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::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 -//! the imaginary axis. +//! 2. Returns the complex inverse hyperbolic cosine of z, in the range of a +//! strip unbounded along the imaginary axis and +//! in the interval \f$[0,\pi]\f$ along the real axis. //! -//! * for every z: eve::acosh(eve::conj(z)) == eve::conj(std::acosh(z)) -//! * for every z: eve::acosh(-z) == -eve::acosh(z) -//! * If z is \f$+0\f$, the result is \f$+0\f$ -//! * If z is \f$NaN\f$, the result is \f$NaN\f$ -//! * If z is \f$+1\f$, the result is \f$+\infty\f$ -//! * If z is \f$x+i \infty\f$ (for any finite positive x), the result is \f$+0,\pi/2\f$ -//! * If z is \f$x+i NaN\f$ (for any finite nonzero x), the result is \f$NaN+i NaN\f$ -//! * If z is \f$+\infty+i y\f$ (for any finite positive y), the result is \f$i \pi/2\f$ -//! * If z is \f$+\infty+i \infty\f$, the result is \f$i \pi/2\f$ -//! * If z is \f$+\infty+i NaN\f$, the result is \f$i NaN\f$ -//! * If z is \f$NaN+i y\f$ (for any finite y), the result is \f$NaN+i NaN\f$ -//! * If z is \f$NaN+i \infty\f$, the result is \f$i \pi/2\f$ (the sign of the real part is unspecified) -//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ +//! * for every z: kyosu::acosh( [kyosu::conj](@ref kyosu::conj)(z)) == kyosu::conj([kyosu::acosh](@ref kyosu::acosh)(z) +//! * If z is \f$\pm0\f$, the result is \f$+0,\pi/2\f$ +//! * If z is \f$x+i\infty\f$ (for any finite x), the result is \f$\infty+i\pi/2\f$ +//! * If z is \f$x+i NaN\f$ (for any finite non zero x), the result is \f$NaN+i NaN\f$. +//! * If z is \f$i NaN\f$ the result is \f$NaN+i\pi/2\f$. +//! * If z is \f$-\infty,y\f$ (for any positive finite y), the result is \f$+\infty,\pi\f$ +//! * If z is \f$+\infty,y\f$ (for any positive finite y), the result is \f$+\infty+i 0\f$ +//! * If z is \f$-\infty+i \infty\f$, the result is \f$+\infty,3\pi/4\f$ +//! * If z is \f$\pm\infty+i NaN\f$, the result is \f$+\infty+i NaN\f$ +//! * If z is \f$NaN,y\f$ (for any finite y), the result is \f$NaN+i NaN\f$. +//! * If z is \f$NaN+i \infty\f$, the result is \f$+\infty+i NaN\f$ +//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ //! //! 3. Returns \f$\log(z+\sqrt{z+1}\sqrt{z-1})\f$. //! diff --git a/include/kyosu/functions/acospi.hpp b/include/kyosu/functions/acospi.hpp index dae7d1af..e6bed903 100644 --- a/include/kyosu/functions/acospi.hpp +++ b/include/kyosu/functions/acospi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acospi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acospi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var acospi -//! @brief Computes the arc cosine of the argument times \f$\pi\f$. +//! @brief Computes the arc cosine of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acospi(T z) noexcept; //1 +//! template constexpr auto acospi(T z) noexcept; //1 //! template constexpr auto acospi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns `invpi(as(z))*acos(z)` +//! 2. Returns kyosu::radinpi([kyosu::acos](@ref kyosu::acos)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acot.hpp b/include/kyosu/functions/acot.hpp index 364207c8..12d81282 100644 --- a/include/kyosu/functions/acot.hpp +++ b/include/kyosu/functions/acot.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acot_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::acot(v); @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acot(T z) noexcept; //1 +//! template constexpr auto acot(T z) noexcept; //1 //! template constexpr auto acot(T z) noexcept; //2 //! template constexpr auto acot(T z) noexcept; //3 //! } @@ -68,13 +68,13 @@ namespace kyosu //! //! **Return value** //! -//! 1. A real type input z calls eve::acot(z); and so returns the same type as input. +//! 1. A real type input z calls eve::acot(z); and so returns the same type as the input. //! //! 2. Returns elementwise the complex principal value //! of the arc cotangent of the input as the arc tangent of the inverse of the input. //! //! 3. Returns \f$I_z \mathrm{acoth}(z I_z)\f$ where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and -//! \f$\underline{z}\f$ is the pure part of \f$z\f$. +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acoth.hpp b/include/kyosu/functions/acoth.hpp index 73fc65fa..3d16ddc3 100644 --- a/include/kyosu/functions/acoth.hpp +++ b/include/kyosu/functions/acoth.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acoth_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acoth{}; @@ -57,7 +57,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acoth(T z) noexcept; //1 +//! template constexpr auto acoth(T z) noexcept; //1 //! template constexpr auto acoth(T z) noexcept; //2 //! template constexpr auto acoth(T z) noexcept; //3 //! } @@ -69,7 +69,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 2. Returns the complex inverse hyperbolic cotangent of z, computed as \f$\mathop{\mathrm{atanh}}(1/z)\f$. //! diff --git a/include/kyosu/functions/acotpi.hpp b/include/kyosu/functions/acotpi.hpp index 9fa52a1b..dc0bbb6a 100644 --- a/include/kyosu/functions/acotpi.hpp +++ b/include/kyosu/functions/acotpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acotpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acotpi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var acotpi -//! @brief Computes the arc cotangent of the argument times \f$\pi\f$. +//! @brief Computes the arc cotangent of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acotpi(T z) noexcept; //1 +//! template constexpr auto acotpi(T z) noexcept; //1 //! template constexpr auto acotpi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns `invpi(as(z))*acot(z)` +//! 2. Returns kyosu::radinpi([kyosu::acot](@ref kyosu::acot)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acsc.hpp b/include/kyosu/functions/acsc.hpp index 37653ff1..5bab3e21 100644 --- a/include/kyosu/functions/acsc.hpp +++ b/include/kyosu/functions/acsc.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acsc_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acsc{}; return fn(complex(v)); @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acsc(T z) noexcept; //1 +//! template constexpr auto acsc(T z) noexcept; //1 //! template constexpr auto acsc(T z) noexcept; //2 //! } //! @endcode @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 2. Returns elementwise \f$\mathop{\mathrm{asin}}(1/z)\f$. //! diff --git a/include/kyosu/functions/acsch.hpp b/include/kyosu/functions/acsch.hpp index aff78fc3..39ad4a3e 100644 --- a/include/kyosu/functions/acsch.hpp +++ b/include/kyosu/functions/acsch.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acsch_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acsch{}; @@ -57,7 +57,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acsch(T z) noexcept; //1 +//! template constexpr auto acsch(T z) noexcept; //1 //! template constexpr auto acsch(T z) noexcept; //2 //! } //! @endcode @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 2. Returns elementwise \f$\mathop{\mathrm{asinh}}(1/z)\f$. //! diff --git a/include/kyosu/functions/acscpi.hpp b/include/kyosu/functions/acscpi.hpp index b958bd74..f6360f32 100644 --- a/include/kyosu/functions/acscpi.hpp +++ b/include/kyosu/functions/acscpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acscpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acscpi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var acscpi -//! @brief Computes the arc cosecant of the argument times \f$\pi\f$. +//! @brief Computes the arc cosecant of the argume!nt in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acscpi(T z) noexcept; //1 +//! template constexpr auto acscpi(T z) noexcept; //1 //! template constexpr auto acscpi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns `invpi(as(z))*acsc(z)` +//! 2. Returns Returns kyosu::radinpi([kyosu::csc](@ref kyosu::acsc)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/acsh.hpp b/include/kyosu/functions/acsh.hpp index cb42992c..f205f121 100644 --- a/include/kyosu/functions/acsh.hpp +++ b/include/kyosu/functions/acsh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(acsch_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_acsch{}; @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto acsch(T z) noexcept; //1 +//! template constexpr auto acsch(T z) noexcept; //1 //! template constexpr auto acsch(T z) noexcept; //2 //! } //! @endcode @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if kyosu::complex(z) was entered. //! //! 2. Returns elementwise asinh(1/z). //! diff --git a/include/kyosu/functions/arg.hpp b/include/kyosu/functions/arg.hpp index 0ea7e4b7..c92d96fb 100644 --- a/include/kyosu/functions/arg.hpp +++ b/include/kyosu/functions/arg.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(arg_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::if_else(eve::is_positive(v), eve::zero, eve::pi(eve::as(v))); } @@ -40,7 +40,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var arg -//! @brief complex number argument. +//! @brief argument. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto arg(T z) noexcept; //1 +//! template constexpr auto arg(T z) noexcept; //1 //! template constexpr auto arg(T z) noexcept; //2 //! template constexpr auto arg(T z) noexcept; //3 //! } @@ -66,10 +66,9 @@ namespace kyosu //! **Return value** //! //! 1. Returns 0 or pi acording to the non negativity of z. -//! 2. Returns elementwise the argument of the complex number i.e. `atan2(imag(z), real(z))`. -//! 3. Returns \f$\mathrm{atan2}(|\underline{z}|, z_0)\f$ where \f$z_0\f$ is the real part of \f$z\f$ and -//! \f$\underline{z}\f$ is the pure part of \f$z\f$. - +//! 2. Returns elementwise the argument of the complex number i.e. eve::atan2([kyosu::imag(z)](@ref kyosu::imag )(z), [kyosu::real(z)](@ref kyosu::real )(z)). +//! 3. Returns \f$\mathrm{atan2}(\mathrm{sign}(z_1)|\underline{z}|, z_0)\f$ where \f$z_0\f$ is the real part of \f$z\f$, \f$z_1\f$ is the ipart of \f$z\f$ and +//! \f$\underline{z}\f$ the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/asec.hpp b/include/kyosu/functions/asec.hpp index 3c9ac812..7dc0f78e 100644 --- a/include/kyosu/functions/asec.hpp +++ b/include/kyosu/functions/asec.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asec_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asec{}; return fn(complex(v)); @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto asec(T z) noexcept; //1 +//! template constexpr auto asec(T z) noexcept; //1 //! template constexpr auto asec(T z) noexcept; //2 //! } //! @endcode @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 2. Returns elementwise \f$\mathop{\mathrm{acos}}(1/z)\f$. //! diff --git a/include/kyosu/functions/asech.hpp b/include/kyosu/functions/asech.hpp index 2c3c0b43..7a507173 100644 --- a/include/kyosu/functions/asech.hpp +++ b/include/kyosu/functions/asech.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asech_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asech{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var asech -//! @brief Computes the hyperbolic arcsecant of the argument. +//! @brief Computes the inverse hyperbolic secant of the argument. //! //! **Defined in Header** //! @@ -56,8 +56,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto asech(T z) noexcept; //1 -//! template constexpr auto asech(T z) noexcept; //2 +//! template constexpr auto asech(T z) noexcept; //1 +//! template constexpr auto asech(T z) noexcept; //2 //! } //! @endcode //! @@ -67,7 +67,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 2. Returns elementwise \f$\mathop{\mathrm{acosh}}(1/z)\f$. //! diff --git a/include/kyosu/functions/asecpi.hpp b/include/kyosu/functions/asecpi.hpp index b016f2d2..805218ef 100644 --- a/include/kyosu/functions/asecpi.hpp +++ b/include/kyosu/functions/asecpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asecpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asecpi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var asecpi -//! @brief Computes the arc secant of the argument times \f$\pi\f$. +//! @brief Computes the arc secant of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto asecpi(T z) noexcept; //1 +//! template constexpr auto asecpi(T z) noexcept; //1 //! template constexpr auto asecpi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if kyosu::complex(z) was entered. //! -//! 2. Returns `invpi(as(z))*asec(z)` +//! 2. Returns kyosu::radinpi([kyosu::asec](@ref kyosu::asec)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/asin.hpp b/include/kyosu/functions/asin.hpp index 2cb68dfe..9f930f5e 100644 --- a/include/kyosu/functions/asin.hpp +++ b/include/kyosu/functions/asin.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asin_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asin{}; @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto asin(T z) noexcept; //1 +//! template constexpr auto asin(T z) noexcept; //1 //! template constexpr auto asin(T z) noexcept; //2 //! template constexpr auto acos(T z) noexcept; //3 //! } @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 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 @@ -77,7 +77,7 @@ namespace kyosu //! special cases are handled as if the operation was implemented by \f$-i\; \mathrm{asinh}(z\; i)\f$ //! //! 3. Returns \f$-I_z \mathrm{asinh}(z I_z)\f$ where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and -//! \f$\underline{z}\f$ is the pure part of \f$z\f$. +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/asinh.hpp b/include/kyosu/functions/asinh.hpp index 696f3834..3fe2e72a 100644 --- a/include/kyosu/functions/asinh.hpp +++ b/include/kyosu/functions/asinh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asinh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::asinh(v); @@ -42,7 +42,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var asinh -//! @brief Computes the asinhine of the argument. +//! @brief Computes the inverse hyperbolic sine of the argument. //! //! **Defined in Header** //! @@ -69,11 +69,11 @@ namespace kyosu //! //! 1. A real type input z calls eve::asinh(z); and so returns the same type as input. //! -//! 2. Returns the complex arc hyperbolic sine of z, with branch cuts outside the interval +//! 2. Returns the complex inverse hyperbolic sine of z, with branch cuts outside the interval //! \f$i\times[-\pi/2, \pi/2]\f$ along the imaginary axis. //! -//! * for every z: eve::asinh(eve::conj(z)) == eve::conj(std::asinh(z)) -//! * for every z: eve::asinh(-z) == -eve::asinh(z) +//! * for every z: kyosu::asinh( [kyosu::conj](@ref kyosu::conj)(z)) == kyosu::conj([kyosu::asinh](@ref kyosu::asinh)(z) +//! * for every z: kyosu::asinh(-z) == -[kyosu::asinh](@ref kyosu::asinh)(z) //! * If z is \f$+0\f$, the result is \f$+0\f$ //! * If z is \f$x+i \infty\f$ (for any positive finite x), the result is \f$+\infty+i \pi/2\f$ //! * If z is \f$x,NaN\f$ (for any finite x), the result is \f$NaN+ iNaN\f$ diff --git a/include/kyosu/functions/asinpi.hpp b/include/kyosu/functions/asinpi.hpp index 56432daf..6461a273 100644 --- a/include/kyosu/functions/asinpi.hpp +++ b/include/kyosu/functions/asinpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(asinpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_asinpi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var asinpi -//! @brief Computes the arc sine of the argument times \f$\pi\f$. +//! @brief Computes the arc sine of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto asinpi(T z) noexcept; //1 +//! template constexpr auto asinpi(T z) noexcept; //1 //! template constexpr auto asinpi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns `invpi(as(z))*asin(z)` +//! 2. Returns kyosu::radinpi([kyosu::asin](@ref kyosu::asin)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/associator.hpp b/include/kyosu/functions/associator.hpp new file mode 100644 index 00000000..dee7660b --- /dev/null +++ b/include/kyosu/functions/associator.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_associator : eve::elementwise + { + using callable_tag_type = callable_associator; + + KYOSU_DEFERS_CALLABLE(associator_); + + static KYOSU_FORCEINLINE auto deferred_call(auto + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1 + , eve::floating_ordered_value auto const& v2) noexcept + { + return eve::zero(eve::as(v0+v1+v2)); + } + + KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1, auto const& target2) const noexcept + -> decltype(eve::tag_invoke(*this, target0, target1, target2)) + { + return eve::tag_invoke(*this, target0, 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 associator +//! @brief Computes the associator of the three parameters. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! constexpr auto associator(auto z0, auto, z1, auto, z2) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z0`, `z1`, z2`: Values to process. Can be a mix of complex and real floating values and complex values. +//! +//! **Return value** +//! +//! Returns the difference z0*(z1*z2)-(z0*z1)*z2. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/associator.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_associator associator = {}; +} diff --git a/include/kyosu/functions/atan.hpp b/include/kyosu/functions/atan.hpp index 0b3d365e..77c514a3 100644 --- a/include/kyosu/functions/atan.hpp +++ b/include/kyosu/functions/atan.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(atan_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atan{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var atan -//! @brief Computes the inverse hyperbolic tangent of the argument. +//! @brief Computes the arctangent of the argument. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto atan(T z) noexcept; //1 +//! template constexpr auto atan(T z) noexcept; //1 //! template constexpr auto atan(T z) noexcept; //2 //! template constexpr auto atan(T z) noexcept; //3 //! } @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! //! 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 @@ -76,7 +76,7 @@ namespace kyosu //! Special cases are handled as if the operation was implemented by \f$-i\; \mathrm{atanh}(z\; i)\f$. //! //! 3. Returns \f$ -I_z \mathrm{atanh}(z I_z)\f$ where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and -//! \f$\underline{z}\f$ is the pure part of \f$z\f$. +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/atanh.hpp b/include/kyosu/functions/atanh.hpp index ce0d576c..2db9b46a 100644 --- a/include/kyosu/functions/atanh.hpp +++ b/include/kyosu/functions/atanh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(atanh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atanh{}; @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto atanh(T z) noexcept; //1 +//! template constexpr auto atanh(T z) noexcept; //1 //! template constexpr auto atanh(T z) noexcept; //2 //! template constexpr auto atanh(T z) noexcept; //3 //! } @@ -68,14 +68,14 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if kyosu::complex(z) was entered. //! -//! 2. Returns the complex arc hyperbolic sine of z, in the range of a half-strip mathematically +//! 2. Returns the complex inverse hyperbolic tangent 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 //! the imaginary axis. //! -//! * for every z: eve::atanh(eve::conj(z)) == eve::conj(std::atanh(z)) -//! * for every z: eve::atanh(-z) == -eve::atanh(z) +//! * for every z: kyosu::atanh( [kyosu::conj](@ref kyosu::conj)(z)) == kyosu::conj([kyosu::atanh](@ref kyosu::atanh)(z) +//! * for every z: kyosu::atanh(-z) == -[kyosu::atanh](@ref kyosu::atanh)(z) //! * If z is \f$+0\f$, the result is \f$+0\f$ //! * If z is \f$NaN\f$, the result is \f$NaN\f$ //! * If z is \f$+1\f$, the result is \f$+\infty\f$ diff --git a/include/kyosu/functions/atanpi.hpp b/include/kyosu/functions/atanpi.hpp index 1744d34b..2e779242 100644 --- a/include/kyosu/functions/atanpi.hpp +++ b/include/kyosu/functions/atanpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(atanpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_atanpi{}; @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var atanpi -//! @brief Computes the arc tangent of the argument times \f$\pi\f$. +//! @brief Computes the arc tangent of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -56,7 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto atanpi(T z) noexcept; //1 +//! template constexpr auto atanpi(T z) noexcept; //1 //! template constexpr auto atanpi(T z) noexcept; //2 //! } //! @endcode @@ -67,9 +67,9 @@ namespace kyosu //! //! **Return value** //! -//! 1. a real input z is treated as if complex(z) was entered. +//! 1. a real input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. //! -//! 2. Returns `invpi(as(z))*atan(z)` +//! 2. Returns kyosu::radinpi([kyosu::atan](@ref kyosu::atan)(z)) //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/average.hpp b/include/kyosu/functions/average.hpp index d8f85591..b59b70e5 100644 --- a/include/kyosu/functions/average.hpp +++ b/include/kyosu/functions/average.hpp @@ -17,8 +17,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(average_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::average(v0, v1); } @@ -54,20 +54,17 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto average(T0 z0, T1, z1) noexcept; -//! template > constexpr auto average(T0 z0, T1, z1) noexcept; -//! template constexpr auto average(T0 z0, T1, z1) noexcept; -//! template > constexpr auto average(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto average(auto z0, auto, z1) noexcept; +//! } //! @endcode //! //! **Parameters** //! -//! * `z0, z1` : Value to process. +//! * `z0, z1` : Value to process. Can be a mix of complex and real floating values and complex values. //! //! **Return value** //! -//! Returns the average of the two arguments . +//! Returns the arithmetic mean of the two arguments. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/ceil.hpp b/include/kyosu/functions/ceil.hpp index 7c97a6ce..0829dba5 100644 --- a/include/kyosu/functions/ceil.hpp +++ b/include/kyosu/functions/ceil.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(ceil_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::ceil(v); } template @@ -52,13 +52,13 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T ceil(T z) noexcept; -//! template constexpr T ceil(T z) noexcept; +//! template constexpr T ceil(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Value to for which ceil is computed. +//! * `z` : Value for which ceil is computed. //! //! **Return value** //! diff --git a/include/kyosu/functions/commutator.hpp b/include/kyosu/functions/commutator.hpp new file mode 100644 index 00000000..1662c63f --- /dev/null +++ b/include/kyosu/functions/commutator.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_commutator : eve::elementwise + { + using callable_tag_type = callable_commutator; + + KYOSU_DEFERS_CALLABLE(commutator_); + + static KYOSU_FORCEINLINE auto deferred_call(auto + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept + { + return eve::zero(eve::as(v0+v1)); + } + + 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 commutator +//! @brief Computes the commutator of the two parameters. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! constexpr auto commutator(auto z0, auto, z1) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z0`, `z1` : Values to process. Can be a mix of complex and real floating values and complex values. +//! +//! **Return value** +//! +//! Returns the difference z0*z1-z1*z0. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/commutator.cpp} +//! @} +//====================================================================================================================== +inline constexpr tags::callable_commutator commutator = {}; +} diff --git a/include/kyosu/functions/conj.hpp b/include/kyosu/functions/conj.hpp index ef36e566..e4e42dec 100644 --- a/include/kyosu/functions/conj.hpp +++ b/include/kyosu/functions/conj.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(conj_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return v; } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T conj(T z) noexcept; -//! template constexpr T conj(T z) noexcept; +//! template constexpr T conj(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! **Return value** //! //! Returns the conjugate of its argument. i.e. the value with the same real part -//! and the opposite pure part. +//! and the opposite [pure](@ref kyosu::imag ) part. //! //! For real inputs the call reduces to identity. //! diff --git a/include/kyosu/functions/convert.hpp b/include/kyosu/functions/convert.hpp index 2fc80022..28561ea8 100644 --- a/include/kyosu/functions/convert.hpp +++ b/include/kyosu/functions/convert.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(convert_); template - static KYOSU_FORCEINLINE auto deferred_call(auto, eve::ordered_value auto const& v, eve::as const& tgt) noexcept + static KYOSU_FORCEINLINE auto deferred_call(auto, eve::floating_ordered_value auto const& v, eve::as const& tgt) noexcept { return eve::convert(v,tgt); } @@ -55,18 +55,18 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template -//! constexpr auto convert(T x, eve::as ) noexcept; +//! template constexpr auto convert(auto x, eve::as ) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `x` : Value to process. -//! * `U``: target scalar type to convert to. +//! * `x`: floating or Cayley Dickinson value to process. +//! * `U`: target type to convert to. //! //! **Return value** //! +//! a value resulting of the conversion of each of its elements to type U. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/cos.hpp b/include/kyosu/functions/cos.hpp index c0dba1df..64581095 100644 --- a/include/kyosu/functions/cos.hpp +++ b/include/kyosu/functions/cos.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cos_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cos(v); } template @@ -52,8 +52,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T cos(T z) noexcept; -//! template constexpr T cos(T z) noexcept; +//! template constexpr T cos(T z) noexcept; //1 +//! template constexpr T cos(T z) noexcept; //2 +//! template constexpr T cos(T z) noexcept; //3 //! } //! @endcode //! @@ -63,7 +64,12 @@ namespace kyosu //! //! **Return value** //! -//! Returns the cosine of the argument. +//! 1. Returns the cosine of the argument. +//! +//! 2. The behavior of this function is equivalent to `eve::cosh(i*z)`. +//! +//! 3 Returns \f$\cosh(I_z\; z)\f$ if \f$z\f$ is not zero else \f$\cos(z_0)\f$, where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/cosh.hpp b/include/kyosu/functions/cosh.hpp index 5771216f..b1d5b6ac 100644 --- a/include/kyosu/functions/cosh.hpp +++ b/include/kyosu/functions/cosh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cosh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cosh(v); } template @@ -52,8 +52,10 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T cosh(T z) noexcept; -//! template constexpr T cosh(T z) noexcept; +//! template constexpr T cosh(T z) noexcept; //1 +//! template constexpr T cosh(T z) noexcept; //2 +//! template constexpr T cosh(T z) noexcept; //3 +//! } //! } //! @endcode //! @@ -63,7 +65,26 @@ namespace kyosu //! //! **Return value** //! -//! Returns the hyperbolic cosine of the argument. +//! 2. Returns elementwise the complex value +//! of the hyperbolic cosine of the input. +//! +//! * for every z: `kyosu::cosh(kyosu::conj(z)) == kyosu::conj(std::cosh(z))` +//! * for every z: `kyosu::cosh(-z) == kyosu::cosh(z)` +//! * If z is \f$0\f$, the result is \f$1\f$ +//! * If z is \f$i \infty\f$, the result is \f$NaN\f$ +//! * If z is \f$i NaN\f$, the result is \f$NaN\f$ +//! * If z is \f$x+i \infty\f$ (for any finite non-zero x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$x+i NaN\f$ (for any finite non-zero x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$\infty+i 0\f$, the result is \f$\infty+i 0\f$ +//! * If z is \f$\infty,y\f$ (for any finite non-zero y), the result is \f$\infty e^{iy}\f$ +//! * If z is \f$\infty+i \infty\f$, the result is \f$\pm \infty+i NaN\f$ (the sign of the real part is unspecified) +//! * If z is \f$\infty+i NaN\f$, the result is \f$\infty+i NaN\f$ +//! * If z is \f$NaN\f$, the result is \f$NaN\f$ +//! * If z is \f$NaN+i y\f$ (for any finite non-zero y), the result is \f$NaN+i NaN\f$ +//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ +//! +//! 3. Is semantically equivalent to (exp(z)+exp(-z))/2. + //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/cospi.hpp b/include/kyosu/functions/cospi.hpp index 40ab425e..f8d137f1 100644 --- a/include/kyosu/functions/cospi.hpp +++ b/include/kyosu/functions/cospi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cospi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cospi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var cospi -//! @brief Computes the cosine of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the cosine from the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T cospi(T z) noexcept; -//! template constexpr T cospi(T z) noexcept; +//! template constexpr T cospi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the cosine of the argument in \f$\pi\f$ mutiples. +//! Returns the cosine from the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/cot.hpp b/include/kyosu/functions/cot.hpp index fad74592..ca9bb5a8 100644 --- a/include/kyosu/functions/cot.hpp +++ b/include/kyosu/functions/cot.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cot_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cot(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T cot(T z) noexcept; -//! template constexpr T cot(T z) noexcept; +//! template constexpr T cot(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/coth.hpp b/include/kyosu/functions/coth.hpp index 70b3099a..37d0091b 100644 --- a/include/kyosu/functions/coth.hpp +++ b/include/kyosu/functions/coth.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(coth_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::coth(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T coth(T z) noexcept; -//! template constexpr T coth(T z) noexcept; +//! template constexpr T coth(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/cotpi.hpp b/include/kyosu/functions/cotpi.hpp index 44609705..b8d5c9a0 100644 --- a/include/kyosu/functions/cotpi.hpp +++ b/include/kyosu/functions/cotpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cotpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cotpi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var cotpi -//! @brief Computes the cotangent of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the cotangent from the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T cotpi(T z) noexcept; -//! template constexpr T cotpi(T z) noexcept; +//! template constexpr T cotpi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the cotangent of the argument in \f$\pi\f$ mutiples. +//! Returns the cotangent from the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/csc.hpp b/include/kyosu/functions/csc.hpp index 3d5378fd..b3762171 100644 --- a/include/kyosu/functions/csc.hpp +++ b/include/kyosu/functions/csc.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(csc_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::csc(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T csc(T z) noexcept; -//! template constexpr T csc(T z) noexcept; +//! template constexpr T csc(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/csch.hpp b/include/kyosu/functions/csch.hpp index 9ccb225f..09664df9 100644 --- a/include/kyosu/functions/csch.hpp +++ b/include/kyosu/functions/csch.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(csch_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::csch(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var csch -//! @brief Computes the hyperbolic cscant of the argument. +//! @brief Computes the hyperbolic cosecant of the argument. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T csch(T z) noexcept; -//! template constexpr T csch(T z) noexcept; +//! template constexpr T csch(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the hyperbolic cscant of the argument. +//! Returns the hyperbolic cosecant of the argument. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/cscpi.hpp b/include/kyosu/functions/cscpi.hpp index 7d3b55b2..bf1cc947 100644 --- a/include/kyosu/functions/cscpi.hpp +++ b/include/kyosu/functions/cscpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(cscpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::cscpi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var cscpi -//! @brief Computes the cosecant of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the cosecant from the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T cscpi(T z) noexcept; -//! template constexpr T cscpi(T z) noexcept; +//! template constexpr T cscpi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the cosecant of the argument in \f$\pi\f$ mutiples. +//! Returns the cosecant from the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/dec.hpp b/include/kyosu/functions/dec.hpp index a64259f8..009f877d 100644 --- a/include/kyosu/functions/dec.hpp +++ b/include/kyosu/functions/dec.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(dec_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::dec(v); } template @@ -43,7 +43,7 @@ namespace kyosu //! **Defined in Header** //! //! @code -//! #declude +//! #include //! @endcode //! //! @groupheader{Callable Signatures} @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T dec(T z) noexcept; -//! template constexpr T dec(T z) noexcept; +//! template constexpr T dec(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/dist.hpp b/include/kyosu/functions/dist.hpp index b1d4bf25..f6f61661 100644 --- a/include/kyosu/functions/dist.hpp +++ b/include/kyosu/functions/dist.hpp @@ -18,8 +18,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(dist_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::dist(v0, v1); } @@ -55,20 +55,18 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto dist(T0 z0, T1, z1) noexcept; -//! template > constexpr auto dist(T0 z0, T1, z1) noexcept; -//! template constexpr auto dist(T0 z0, T1, z1) noexcept; -//! template > constexpr auto dist(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto dist(auto z0, auto z1) noexcept; +//! } //! @endcode //! //! **Parameters** //! -//! * `z0, z1` : Value to process. +//! * `z0, z1` : Values to process. //! //! **Return value** //! //! Returns the distance between the two arguments computed as the absolute value of the arguments difference. +//! Arguments can be a mix of floting or Cayley-Dicson values. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/dot.hpp b/include/kyosu/functions/dot.hpp index 40d57f83..dbdae74b 100644 --- a/include/kyosu/functions/dot.hpp +++ b/include/kyosu/functions/dot.hpp @@ -18,8 +18,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(dot_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::dot(v0, v1); } @@ -55,20 +55,18 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto dot(T0 z0, T1, z1) noexcept; -//! template > constexpr auto dot(T0 z0, T1, z1) noexcept; -//! template constexpr auto dot(T0 z0, T1, z1) noexcept; -//! template > constexpr auto dot(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto dot(auto z0, auto z1) noexcept; +//! } //! @endcode //! //! **Parameters** //! -//! * `z0, z1` : Value to process. +//! * `z0, z1` : Values to process. //! //! **Return value** //! //! Returns the dot product of z0 and z1. If z0 and z1 are floating point this is equivalent to z0*z1. +//! Arguments can be a mix of floting or Cayley-Dicson values. //! //! `dot(z0, z0)` is always semantically equivalent to `sqr_abs(z0)`. //! diff --git a/include/kyosu/functions/exp.hpp b/include/kyosu/functions/exp.hpp index 0f47895b..3fcb71f1 100644 --- a/include/kyosu/functions/exp.hpp +++ b/include/kyosu/functions/exp.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(exp_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::exp(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T exp(T z) noexcept; -//! template constexpr T exp(T z) noexcept; +//! template constexpr T exp(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/exp10.hpp b/include/kyosu/functions/exp10.hpp index 250d8f36..e209ccb0 100644 --- a/include/kyosu/functions/exp10.hpp +++ b/include/kyosu/functions/exp10.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(exp10_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::exp10(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexp10r T exp10(T z) noexcept; -//! template constexp10r T exp10(T z) noexcept; +//! template constexpr T exp10(T z) noexcept; +//! template constexpr T exp10(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/exp2.hpp b/include/kyosu/functions/exp2.hpp index d837edaa..236c45fd 100644 --- a/include/kyosu/functions/exp2.hpp +++ b/include/kyosu/functions/exp2.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(exp2_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::exp2(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexp2r T exp2(T z) noexcept; -//! template constexp2r T exp2(T z) noexcept; +//! template constexpr T exp2(T z) noexcept; +//! template constexpr T exp2(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/exp_i.hpp b/include/kyosu/functions/exp_i.hpp index 73668dee..9050d649 100644 --- a/include/kyosu/functions/exp_i.hpp +++ b/include/kyosu/functions/exp_i.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(exp_i_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { const auto ii = kyosu::complex(T(0), T(1)); @@ -44,7 +44,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var exp_i -//! @brief Computes the exponential of the argument times i. +//! @brief Computes the exponential of i times the argument //! //! **Defined in Header** //! @@ -58,7 +58,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexp_ir T exp_i(T z) noexcept; -//! template constexp_ir T exp_i(T z) noexcept; +//! template constexp_ir T exp_i(T z) noexcept; //! } //! @endcode //! @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `exp(i*z)`. +//! Returns `exp(i*z)`. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/exp_ipi.hpp b/include/kyosu/functions/exp_ipi.hpp index 257590bf..7814ceb2 100644 --- a/include/kyosu/functions/exp_ipi.hpp +++ b/include/kyosu/functions/exp_ipi.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(exp_ipi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { const auto ii = kyosu::complex(T(0), T(1))*eve::pi(eve::as()); @@ -44,7 +44,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var exp_ipi -//! @brief Computes the exponential of the argument times i. +//! @brief Computes the exponential of \f$i\pi\f$ times the argument. //! //! **Defined in Header** //! @@ -58,7 +58,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexp_ipir T exp_ipi(T z) noexcept; -//! template constexp_ipir T exp_ipi(T z) noexcept; +//! template constexp_ipir T exp_ipi(T z) noexcept; //! } //! @endcode //! @@ -68,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `exp(i*z)`. +//! Returns `exp(i*pi(as(z))*z)`. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/expm1.hpp b/include/kyosu/functions/expm1.hpp index 202a3ffa..79f6d3c9 100644 --- a/include/kyosu/functions/expm1.hpp +++ b/include/kyosu/functions/expm1.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(expm1_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::expm1(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var expm1 -//! @brief Computes the expm1onential of the argument minus 1. +//! @brief Computes the exponential of the argument minus 1. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpm1r T expm1(T z) noexcept; -//! template constexpm1r T expm1(T z) noexcept; +//! template constexpm1r T expm1(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the expm1onential of the argument minus &. +//! Returns the expm1onential of the argument minus 1. //! for real and complex typed inputs, provisions are made to ensure good precision near zero. //! //! @groupheader{Example} diff --git a/include/kyosu/functions/expmx2.hpp b/include/kyosu/functions/expmx2.hpp index 5c39cd5d..5234853d 100644 --- a/include/kyosu/functions/expmx2.hpp +++ b/include/kyosu/functions/expmx2.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(expmx2_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::expmx2(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpmx2r T expmx2(T z) noexcept; -//! template constexpmx2r T expmx2(T z) noexcept; +//! template constexpr T expmx2(T z) noexcept; +//! template constexpr T expmx2(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/expx2.hpp b/include/kyosu/functions/expx2.hpp index fda5f947..8de316c5 100644 --- a/include/kyosu/functions/expx2.hpp +++ b/include/kyosu/functions/expx2.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(expx2_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::expx2(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpx2r T expx2(T z) noexcept; -//! template constexpx2r T expx2(T z) noexcept; +//! template constexpr T expx2(T z) noexcept; +//! template constexpr T expx2(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/floor.hpp b/include/kyosu/functions/floor.hpp index ff53d877..e35b328f 100644 --- a/include/kyosu/functions/floor.hpp +++ b/include/kyosu/functions/floor.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(floor_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::floor(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T floor(T z) noexcept; -//! template constexpr T floor(T z) noexcept; +//! template constexpr T floor(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the floor of its argument. i.e. the value with parts are the floor of the original ones. +//! Returns the floor of its argument. i.e. the value whose parts are the floor of the original ones. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/frac.hpp b/include/kyosu/functions/frac.hpp index d74e2c5a..7a902c8c 100644 --- a/include/kyosu/functions/frac.hpp +++ b/include/kyosu/functions/frac.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(frac_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::frac(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T frac(T z) noexcept; -//! template constexpr T frac(T z) noexcept; +//! template constexpr T frac(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! **Return value** //! //! Returns the frac of its argument. i.e. the value with parts are the fractionnal -//! part of the original ones. +//! parts of the original ones. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/from_angle_axis.hpp b/include/kyosu/functions/from_angle_axis.hpp index 04eeade9..9d376123 100644 --- a/include/kyosu/functions/from_angle_axis.hpp +++ b/include/kyosu/functions/from_angle_axis.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_angle_axis_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V angle , U axis) noexcept @@ -48,7 +48,7 @@ namespace kyosu::tags namespace kyosu { //================================================================================================ - //! @addtogroup quaternion + //! @addtogroup functions //! @{ //! @var from_angle_axis //! diff --git a/include/kyosu/functions/from_cylindrical.hpp b/include/kyosu/functions/from_cylindrical.hpp index 1e03a822..7cc6c864 100644 --- a/include/kyosu/functions/from_cylindrical.hpp +++ b/include/kyosu/functions/from_cylindrical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_cylindrical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & r , U const & angle diff --git a/include/kyosu/functions/from_cylindricospherical.hpp b/include/kyosu/functions/from_cylindricospherical.hpp index 900ed386..1b204278 100644 --- a/include/kyosu/functions/from_cylindricospherical.hpp +++ b/include/kyosu/functions/from_cylindricospherical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_cylindrospherical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & t , U const & radius diff --git a/include/kyosu/functions/from_cylindrospherical.hpp b/include/kyosu/functions/from_cylindrospherical.hpp index 900ed386..1b204278 100644 --- a/include/kyosu/functions/from_cylindrospherical.hpp +++ b/include/kyosu/functions/from_cylindrospherical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_cylindrospherical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & t , U const & radius diff --git a/include/kyosu/functions/from_multipolar.hpp b/include/kyosu/functions/from_multipolar.hpp index 983df8be..9eed28b2 100644 --- a/include/kyosu/functions/from_multipolar.hpp +++ b/include/kyosu/functions/from_multipolar.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_multipolar_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & rho1 , U const & theta1 diff --git a/include/kyosu/functions/from_polar.hpp b/include/kyosu/functions/from_polar.hpp index ed8c89e5..3c9c409f 100644 --- a/include/kyosu/functions/from_polar.hpp +++ b/include/kyosu/functions/from_polar.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_polar_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v , U const & u) noexcept @@ -58,7 +58,7 @@ namespace kyosu //! @{ //! @var from_polar //! - //! @brief Callable object computing a complex from its polar coordinates. + //! @brief Callable object computing a complex or a general Cayley-Dickson from a polar representation. //! //! This function is the reciprocal of from_polar //! @@ -73,9 +73,9 @@ namespace kyosu //! @code //! namespace eve //! { - //! template, + //! template, //! auto from_polar( T0 rho, T1 theta) const noexcept; // 1 - //! template, + //! template, //! auto from_polar( T0 rho, T1 theta, C iz) const noexcept; // 2 //! } //! @endcode @@ -83,7 +83,9 @@ namespace kyosu //! **Parameters** //! //! `rho` : modulus. + //! //! `theta` : argument. + //! //! `iz' : unitary cayley dickson value. //! //! **Return value** @@ -91,6 +93,8 @@ namespace kyosu //! 1. the complex number `rho*exp(i*theta)`. //! 2. the cayley_dickson value `rho*exp(iz*theta)`. //! + //! @note the entries constitue a proper polar representation if rho is non-negative and if iz present + //! it must be pure unitary with non-negative jpart. However the formula is taken anyway. //! //! //! #### Example diff --git a/include/kyosu/functions/from_semipolar.hpp b/include/kyosu/functions/from_semipolar.hpp index e061c11e..036cf575 100644 --- a/include/kyosu/functions/from_semipolar.hpp +++ b/include/kyosu/functions/from_semipolar.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_semipolar_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & rho , U const & alpha diff --git a/include/kyosu/functions/from_spherical.hpp b/include/kyosu/functions/from_spherical.hpp index 9f0dae5b..7ed43029 100644 --- a/include/kyosu/functions/from_spherical.hpp +++ b/include/kyosu/functions/from_spherical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(from_spherical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & rho , U const & theta diff --git a/include/kyosu/functions/hypot.hpp b/include/kyosu/functions/hypot.hpp index 730f91ae..35d0f3ea 100644 --- a/include/kyosu/functions/hypot.hpp +++ b/include/kyosu/functions/hypot.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(hypot_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const&... vs) noexcept + , eve::floating_ordered_value auto const&... vs) noexcept { return eve::hypot(vs...); } @@ -29,9 +29,9 @@ namespace kyosu::tags return eve::tag_invoke(*this, targets...); } -// template -// eve::unsupported_call operator()(T&&... x) const -// requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; }; } @@ -54,18 +54,17 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template< floating_value P, typename ... Ts> -//! auto operator()(Ts ... zi ) const noexcept +//! template< f typename ... Ts> auto hypot(Ts ... zi ) const noexcept ///! } //! @endcode //! //! **Parameters** //! -//! * ` zi...` : Values to process. +//! * ` zi...` : Values to process: mix of floating and Cayley-Dickson. //! //! **Return value** //! -//! Returns \f$ \sqrt\sum_{i = 0}^n//! |z_i|^2} \f$. +//! * Returns \f$ \sqrt{\sum_{i = 0}^{n-1} |z_i|^2} \f$ where \f$n\f$ is the number of arguments. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/if_else.hpp b/include/kyosu/functions/if_else.hpp index eba57444..4ca6cafb 100644 --- a/include/kyosu/functions/if_else.hpp +++ b/include/kyosu/functions/if_else.hpp @@ -21,9 +21,9 @@ namespace kyosu::tags return eve::tag_invoke(*this, m, t, f); } -// template -// eve::unsupported_call operator()(T&&... x) const -// requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; }; } @@ -46,8 +46,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template -//! constexpr auto if_else(T x, U, y, V z ) noexcept; +//! template constexpr auto if_else(T x, U, y, V z ) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/inc.hpp b/include/kyosu/functions/inc.hpp index b493af8b..155b254a 100644 --- a/include/kyosu/functions/inc.hpp +++ b/include/kyosu/functions/inc.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(inc_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::inc(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T inc(T z) noexcept; -//! template constexpr T inc(T z) noexcept; +//! template constexpr T inc(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/ipart.hpp b/include/kyosu/functions/ipart.hpp index d2989626..42500eea 100644 --- a/include/kyosu/functions/ipart.hpp +++ b/include/kyosu/functions/ipart.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(ipart_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } template @@ -43,7 +43,7 @@ namespace kyosu //====================================================================================================================== //! @addtogroup functions //! @{ -//! @var imag +//! @var ipart //! @brief Extracts the imaginary part of a value. //! //! **Defined in Header** @@ -59,7 +59,7 @@ namespace kyosu //! { //! template constexpr auto& ipart(T& z) noexcept; //! template constexpr auto ipart(T const& z) noexcept; -//! template constexpr T ipart(T const& z) noexcept; +//! template constexpr T ipart(T const& z) noexcept; //! } //! @endcode //! @@ -69,15 +69,19 @@ namespace kyosu //! //! **Return value** //! -//! Returns the imaginary part of its argument. For real inputs, the call returns 0. It is an alias of `imag`. +//! Returns the second part of its argument. +//! +//! For real inputs, the call returns 0. +//! +//! For complex inputs it is the imaginary part. //! //! @groupheader{Example} //! -//! @godbolt{doc/imag.cpp} +//! @godbolt{doc/ipart.cpp} //====================================================================================================================== inline constexpr tags::callable_ipart ipart = {}; -/// Alias for ipart +//! Alias for [ipart](@ref kyosu::ipart) inline constexpr tags::callable_ipart imag = {}; //====================================================================================================================== diff --git a/include/kyosu/functions/is_denormal.hpp b/include/kyosu/functions/is_denormal.hpp index 8bcee6c7..15dcf60f 100644 --- a/include/kyosu/functions/is_denormal.hpp +++ b/include/kyosu/functions/is_denormal.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_denormal_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_denormal(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_denormal(T z) noexcept; -//! template constexpr auto is_denormal(T z) noexcept; +//! template constexpr auto is_denormal(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is denormal . +//! Returns elementwise true is at least one component of the element is denormal. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_equal.hpp b/include/kyosu/functions/is_equal.hpp index e9db50f1..92f323b3 100644 --- a/include/kyosu/functions/is_equal.hpp +++ b/include/kyosu/functions/is_equal.hpp @@ -56,16 +56,13 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto is_equal(T0 z0, T1, z1) noexcept; -//! template > constexpr auto is_equal(T0 z0, T1, z1) noexcept; -//! template constexpr auto is_equal(T0 z0, T1, z1) noexcept; -//! template > constexpr auto is_equal(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto is_equal(auto z0, auto z1) noexcept; +//! } //! @endcode //! //! **Parameters** //! -//! * `z0, z1` : Value to process. +//! * `z0, z1` : Values to process. //! //! **Return value** //! diff --git a/include/kyosu/functions/is_eqz.hpp b/include/kyosu/functions/is_eqz.hpp index e8417abc..0088e85e 100644 --- a/include/kyosu/functions/is_eqz.hpp +++ b/include/kyosu/functions/is_eqz.hpp @@ -38,7 +38,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var is_eqz -//! @brief test the parameter for zero equality. +//! @brief test the parameter for equality to zero. //! //! **Defined in Header** //! @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_eqz(T z) noexcept; -//! template constexpr auto is_eqz(T z) noexcept; +//! template constexpr auto is_eqz(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/is_finite.hpp b/include/kyosu/functions/is_finite.hpp index a52347a7..ef762865 100644 --- a/include/kyosu/functions/is_finite.hpp +++ b/include/kyosu/functions/is_finite.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_finite_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_finite(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_finite(T z) noexcept; -//! template constexpr auto is_finite(T z) noexcept; +//! template constexpr auto is_finite(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/is_imag.hpp b/include/kyosu/functions/is_imag.hpp index 97f779e9..2d5b53d6 100644 --- a/include/kyosu/functions/is_imag.hpp +++ b/include/kyosu/functions/is_imag.hpp @@ -29,7 +29,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_imag(T z) noexcept; -//! template constexpr auto is_imag(T z) noexcept; +//! template constexpr auto is_imag(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/is_infinite.hpp b/include/kyosu/functions/is_infinite.hpp index d46115d3..c8494d98 100644 --- a/include/kyosu/functions/is_infinite.hpp +++ b/include/kyosu/functions/is_infinite.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_infinite_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_infinite(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_infinite(T z) noexcept; -//! template constexpr auto is_infinite(T z) noexcept; +//! template constexpr auto is_infinite(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is infinite . +//! Returns elementwise true is any component of the element is infinite . //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_nan.hpp b/include/kyosu/functions/is_nan.hpp index 4644bdde..edf2e7c1 100644 --- a/include/kyosu/functions/is_nan.hpp +++ b/include/kyosu/functions/is_nan.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_nan_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_nan(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_nan(T z) noexcept; -//! template constexpr auto is_nan(T z) noexcept; +//! template constexpr auto is_nan(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is nan . +//! Returns elementwise true is any component of the element is nan . //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_nez.hpp b/include/kyosu/functions/is_nez.hpp index 87f5fd9c..9eca7d96 100644 --- a/include/kyosu/functions/is_nez.hpp +++ b/include/kyosu/functions/is_nez.hpp @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_nez(T z) noexcept; -//! template constexpr auto is_nez(T z) noexcept; +//! template constexpr auto is_nez(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the value of z != 0. +//! Returns elementwise true is any component of the element is not zero. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_not_denormal.hpp b/include/kyosu/functions/is_not_denormal.hpp index f343bdcb..92c446a7 100644 --- a/include/kyosu/functions/is_not_denormal.hpp +++ b/include/kyosu/functions/is_not_denormal.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_not_denormal_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_not_denormal(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_not_denormal(T z) noexcept; -//! template constexpr auto is_not_denormal(T z) noexcept; +//! template constexpr auto is_not_denormal(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/is_not_equal.hpp b/include/kyosu/functions/is_not_equal.hpp index 08aea0b6..93461292 100644 --- a/include/kyosu/functions/is_not_equal.hpp +++ b/include/kyosu/functions/is_not_equal.hpp @@ -43,7 +43,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var is_not_equal -//! @brief retuen true if and only if the two parameters are equal. +//! @brief return true if and only if the two parameters are not equal. //! //! **Defined in Header** //! @@ -56,16 +56,13 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto is_not_equal(T0 z0, T1, z1) noexcept; -//! template > constexpr auto is_not_equal(T0 z0, T1, z1) noexcept; -//! template constexpr auto is_not_equal(T0 z0, T1, z1) noexcept; -//! template > constexpr auto is_not_equal(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto is_equal(auto z0, auto z1) noexcept; +//! } //! @endcode //! //! **Parameters** //! -//! * `z0, z1` : Value to process. +//! * `z0, z1` : Values to process. //! //! **Return value** //! diff --git a/include/kyosu/functions/is_not_finite.hpp b/include/kyosu/functions/is_not_finite.hpp index 0e399509..059f3b41 100644 --- a/include/kyosu/functions/is_not_finite.hpp +++ b/include/kyosu/functions/is_not_finite.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_not_finite_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_not_finite(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_not_finite(T z) noexcept; -//! template constexpr auto is_not_finite(T z) noexcept; +//! template constexpr auto is_not_finite(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is not finite . +//! Returns elementwise true is any component of the element is not finite . //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_not_infinite.hpp b/include/kyosu/functions/is_not_infinite.hpp index dbc5feb1..88ac4f0e 100644 --- a/include/kyosu/functions/is_not_infinite.hpp +++ b/include/kyosu/functions/is_not_infinite.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_not_infinite_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_not_infinite(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_not_infinite(T z) noexcept; -//! template constexpr auto is_not_infinite(T z) noexcept; +//! template constexpr auto is_not_infinite(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is not infinite . +//! Returns elementwise false is any component of the element is infinite . //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_not_nan.hpp b/include/kyosu/functions/is_not_nan.hpp index 53a04654..df430b20 100644 --- a/include/kyosu/functions/is_not_nan.hpp +++ b/include/kyosu/functions/is_not_nan.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_not_nan_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_not_nan(v); } template @@ -38,7 +38,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var is_not_nan -//! @brief test if the parameter is not_nan. +//! @brief test if the parameter is not a Nan. //! //! **Defined in Header** //! @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_not_nan(T z) noexcept; -//! template constexpr auto is_not_nan(T z) noexcept; +//! template constexpr auto is_not_nan(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is a component of the element is not_nan . +//! Returns elementwise false is any component of the element is a Nan. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_not_real.hpp b/include/kyosu/functions/is_not_real.hpp index 54a4dc07..26bf451b 100644 --- a/include/kyosu/functions/is_not_real.hpp +++ b/include/kyosu/functions/is_not_real.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_not_real_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::false_(eve::as(v)); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_not_real(T z) noexcept; -//! template constexpr auto is_not_real(T z) noexcept; +//! template constexpr auto is_not_real(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is any of the non real parts of the argument is not zero. +//! Returns elementwise true if the [pure](@ref kyosu::pure) part is not zero. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_pure.hpp b/include/kyosu/functions/is_pure.hpp index 3eff780b..ad07490a 100644 --- a/include/kyosu/functions/is_pure.hpp +++ b/include/kyosu/functions/is_pure.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_pure_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::is_eqz(v); } template @@ -51,8 +51,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto is_pure(T z) noexcept; -//! template constexpr auto is_pure(T z) noexcept; +//! template constexpr auto is_pure(T z) noexcept; +//! template constexpr auto is_pure(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true if the real part of the argument is zero. +//! Returns elementwise true if the [real](@ref kyosu::real) part of the argument is zero. //! //! @groupheader{Example} //! @@ -70,5 +70,7 @@ namespace kyosu //! @} //====================================================================================================================== inline constexpr tags::callable_is_pure is_pure = {}; + +/// alias of is_pure inline constexpr tags::callable_is_pure is_imag = {}; } diff --git a/include/kyosu/functions/is_real.hpp b/include/kyosu/functions/is_real.hpp index 8891ed52..2cc1faf7 100644 --- a/include/kyosu/functions/is_real.hpp +++ b/include/kyosu/functions/is_real.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_real_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::true_(eve::as(v)); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_real(T z) noexcept; -//! template constexpr auto is_real(T z) noexcept; +//! template constexpr auto is_real(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true is all the non real parts of the argument are zero. +//! Returns elementwise true if its [pure](@ref kyosu::pure) part is zero. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/is_unitary.hpp b/include/kyosu/functions/is_unitary.hpp index 3c8b26b3..f732ad29 100644 --- a/include/kyosu/functions/is_unitary.hpp +++ b/include/kyosu/functions/is_unitary.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(is_unitary_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::abs(v) == eve::one(eve::as(v)); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto is_unitary(T z) noexcept; -//! template constexpr auto is_unitary(T z) noexcept; +//! template constexpr auto is_unitary(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns elementwise true if an element is of absolute value one. +//! Returns elementwise true if the element is of absolute value one. //! //! @note As for now is_unitary accepts almost equality (will change when decorators will be at hand in kyosu) //! diff --git a/include/kyosu/functions/jpart.hpp b/include/kyosu/functions/jpart.hpp index 0c6d4cd0..bcccd008 100644 --- a/include/kyosu/functions/jpart.hpp +++ b/include/kyosu/functions/jpart.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(jpart_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } template @@ -53,7 +53,7 @@ namespace kyosu //! { //! template constexpr auto& jpart(T& z) noexcept; //! template constexpr auto jpart(T const& z) noexcept; -//! template constexpr T jpart(T const& z) noexcept; +//! template constexpr T jpart(T const& z) noexcept; //! } //! @endcode //! @@ -64,6 +64,7 @@ namespace kyosu //! **Return value** //! //! Returns the \f$j\f$ part of its argument. For real and complex inputs, the call returns 0. +//! Its the third coefficient in the z representation and so is 0 for complex and floating. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/kpart.hpp b/include/kyosu/functions/kpart.hpp index 6db12e65..7d26e289 100644 --- a/include/kyosu/functions/kpart.hpp +++ b/include/kyosu/functions/kpart.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(kpart_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } template @@ -59,7 +59,7 @@ namespace kyosu //! { //! template constexpr auto& kpart(T& z) noexcept; //! template constexpr auto kpart(T const& z) noexcept; -//! template constexpr T kpart(T const& z) noexcept; +//! template constexpr T kpart(T const& z) noexcept; //! } //! @endcode //! @@ -70,6 +70,8 @@ namespace kyosu //! **Return value** //! //! Returns the \f$k\f$ part of its argument. For real and complex inputs, the call returns 0. +//! Its the fourth coefficient in the z representation and so is 0 for complex and floating. +//! //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/ldiv.hpp b/include/kyosu/functions/ldiv.hpp index f5c3890e..1a40c59b 100644 --- a/include/kyosu/functions/ldiv.hpp +++ b/include/kyosu/functions/ldiv.hpp @@ -17,8 +17,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(ldiv_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return v1/v0; } @@ -54,11 +54,8 @@ namespace kyosu //! @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; -///! } +//! constexpr auto ldiv(auto z0, auto, z1) noexcept; +//! } //! @endcode //! //! **Parameters** @@ -68,7 +65,7 @@ namespace kyosu //! **Return value** //! //! Returns the left division of the two arguments. This function not equivalent to z1/z0 as soon as multiplication -//! is not commutative. +//! is not commutative (i.e. for general Cayley-Dickson values with dimensionality strictly above 2). //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/lerp.hpp b/include/kyosu/functions/lerp.hpp index db3fdb35..528b733b 100644 --- a/include/kyosu/functions/lerp.hpp +++ b/include/kyosu/functions/lerp.hpp @@ -18,9 +18,9 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(lerp_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1 - , eve::ordered_value auto const& t) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1 + , eve::floating_ordered_value auto const& t) noexcept { return eve::lerp(v0, v1, t); } @@ -56,11 +56,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto lerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template > constexpr auto lerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template constexpr auto lerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template > constexpr auto lerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -///! } +//! constexpr auto lerp(auto z0, auto, z1, floating_ordered_value t) noexcept; +//! } //! @endcode //! //! **Parameters** @@ -73,6 +70,8 @@ namespace kyosu //! The value of the interpolation (or extrapolation) between `z0` and `z1` is returned. //! The call is semantically equivalent to `z0+t*(z1-z0)`. //! +//! @see slerp for better unitary quaternion (spheroidal) interpolation. +//! //! @groupheader{Example} //! //! @godbolt{doc/lerp.cpp} diff --git a/include/kyosu/functions/lipart.hpp b/include/kyosu/functions/lipart.hpp new file mode 100644 index 00000000..758d9b1c --- /dev/null +++ b/include/kyosu/functions/lipart.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_lipart : eve::elementwise, extractor<5> + { + using callable_tag_type = callable_lipart; + + KYOSU_DEFERS_CALLABLE(lipart_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + KYOSU_FORCEINLINE auto operator()(T& 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 lipart +//! @brief Extracts the li (sixth) part of a value. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto& lipart(T& z) noexcept; +//! template constexpr auto lipart(T const& z) noexcept; +//! template constexpr T lipart(T const& z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Original value. +//! +//! **Return value** +//! +//! Returns the sixth part of its argument. +//! +//! For up to quaternion inputs, the call always returns 0. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lipart.cpp} +//====================================================================================================================== +inline constexpr tags::callable_lipart lipart = {}; + +//====================================================================================================================== +//! @} +//====================================================================================================================== +} diff --git a/include/kyosu/functions/ljpart.hpp b/include/kyosu/functions/ljpart.hpp new file mode 100644 index 00000000..cbf6c382 --- /dev/null +++ b/include/kyosu/functions/ljpart.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_ljpart : eve::elementwise, extractor<6> + { + using callable_tag_type = callable_ljpart; + + KYOSU_DEFERS_CALLABLE(ljpart_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + KYOSU_FORCEINLINE auto operator()(T& 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 ljpart +//! @brief Extracts the lj (seventh) part of a value. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto& ljpart(T& z) noexcept; +//! template constexpr auto ljpart(T const& z) noexcept; +//! template constexpr T ljpart(T const& z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Original value. +//! +//! **Return value** +//! +//! Returns the seventh part of its argument. +//! +//! For up to quaterion inputs, the call always returns 0. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/ljpart.cpp} +//====================================================================================================================== +inline constexpr tags::callable_ljpart ljpart = {}; + +//====================================================================================================================== +//! @} +//====================================================================================================================== +} diff --git a/include/kyosu/functions/lkpart.hpp b/include/kyosu/functions/lkpart.hpp new file mode 100644 index 00000000..452d72a8 --- /dev/null +++ b/include/kyosu/functions/lkpart.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_lkpart : eve::elementwise, extractor<7> + { + using callable_tag_type = callable_lkpart; + + KYOSU_DEFERS_CALLABLE(lkpart_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + KYOSU_FORCEINLINE auto operator()(T& 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 lkpart +//! @brief Extracts the lk (eighth) part of a value. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto& lkpart(T& z) noexcept; +//! template constexpr auto lkpart(T const& z) noexcept; +//! template constexpr T lkpart(T const& z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Original value. +//! +//! **Return value** +//! +//! Returns the eighth part of its argument. +//! +//! For up to quaterion inputs, the call always returns 0. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lkpart.cpp} +//====================================================================================================================== +inline constexpr tags::callable_lkpart lkpart = {}; + +//====================================================================================================================== +//! @} +//====================================================================================================================== +} diff --git a/include/kyosu/functions/log.hpp b/include/kyosu/functions/log.hpp index e86727af..f74dee9c 100644 --- a/include/kyosu/functions/log.hpp +++ b/include/kyosu/functions/log.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(log_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log{}; @@ -57,8 +57,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constlogr T log(T z) noexcept; -//! template constlogr T log(T z) noexcept; +//! template constexpr T log(T z) noexcept; //1 +//! template constexpr T log(T z) noexcept; //2 +//! template constexpr T log(T z) noexcept; //2 //! } //! @endcode //! @@ -68,7 +69,29 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `log(z)`. If z is an ordered value log returns a complex typed value. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. +//! +//! 2. Returns elementwise the natural logarithm of the input +//! in the range of a strip in the interval \f$i\times[-\pi, \pi]\f$ along the imaginary axis +//! and mathematically unbounded along the real axis. . +//! +//! * The function is continuous onto the branch cut along the negative real axis, +//! taking into account the sign of imaginary part +//! * for every z: `kyosu::log(kyosu::conj(z)) == kyosu::conj(kyosu::log(z))` +//! * If z is \f$-0\f$, the result is \f$-\infty+i \pi \f$ +//! * If z is \f$+0\f$, the result is \f$-\infty\f$ +//! * If z is \f$x+i \infty\f$ (for any finite x), the result is \f$+\infty+i \pi/2\f$ +//! * If z is \f$x+i NaN\f$ (for any finite x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$-\infty+i y\f$ (for any finite positive y), the result is \f$+\infty+i \pi \f$ +//! * If z is \f$+\infty+i y\f$ (for any finite positive y), the result is \f$+\infty\f$ +//! * If z is \f$-\infty+i \infty\f$, the result is \f$+\infty+i 3\pi/4\f$ +//! * If z is \f$+\infty+i \infty\f$, the result is \f$+\infty+i \pi/4\f$ +//! * If z is \f$\pm\infty+i NaN\f$, the result is \f$+\infty+i NaN\f$ +//! * If z is \f$NaN+i y\f$ (for any finite y), the result is \f$NaN+i NaN\f$ +//! * If z is \f$NaN+i \infty\f$, the result is \f$+\infty+i NaN\f$ +//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ +//! +//! 3. `log(z)` is semantically equivalent to `log(abs(z))+sign(pure(z))*arg(z)` //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/log10.hpp b/include/kyosu/functions/log10.hpp index f124d6b1..680c4bfc 100644 --- a/include/kyosu/functions/log10.hpp +++ b/include/kyosu/functions/log10.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(log10_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log10{}; @@ -57,8 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T log10(T z) noexcept; -//! template constexpr complex_t log10(T z) noexcept; +//! template constexpr auto log10(T z) noexcept; //1 +//! template constexpr auto log10(T z) noexcept; //2 //! } //! @endcode //! @@ -68,7 +68,9 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `log10(z)`. If z is an ordered value log10 returns a complex typed value. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. +//! 2. returns [log](@ref kyosu::log)(z)/log_10(as(z)). +//! //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/log1p.hpp b/include/kyosu/functions/log1p.hpp index b821a6db..8c6140d0 100644 --- a/include/kyosu/functions/log1p.hpp +++ b/include/kyosu/functions/log1p.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(log1p_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log1p{}; @@ -57,8 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T log1p(T z) noexcept; -//! template constexpr complex_t log1p(T z) noexcept; +//! template constexpr complex_t log1p(T z) noexcept; //1 +//! template constexpr T log1p(T z) noexcept; //2 //! } //! @endcode //! @@ -68,7 +68,10 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `log1p(1+z)`. If z is an ordered value log1p returns a complex typed value. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered.\n +//! For real and complex entries provision are made to get better precision near z = 0. +//! +//! 2. returns [log](@ref kyosu::log)(1+z). //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/log2.hpp b/include/kyosu/functions/log2.hpp index 09902307..e7369d24 100644 --- a/include/kyosu/functions/log2.hpp +++ b/include/kyosu/functions/log2.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(log2_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log2{}; @@ -57,8 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { +//! template constexpr complex_t log2(T z) noexcept; //! template constexpr T log2(T z) noexcept; -//! template constexpr complex_t log2(T z) noexcept; //! } //! @endcode //! @@ -68,7 +68,8 @@ namespace kyosu //! //! **Return value** //! -//! Returns the `log2(z)`. If z is an ordered value log2 returns a complex typed value. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. +//! 2. returns [log](@ref kyosu::log)(z)/log_2(as(z)). //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/log_abs.hpp b/include/kyosu/functions/log_abs.hpp index 6246cd8e..f28c087b 100644 --- a/include/kyosu/functions/log_abs.hpp +++ b/include/kyosu/functions/log_abs.hpp @@ -19,7 +19,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(log_abs_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { auto fn = callable_log_abs{}; @@ -57,8 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constlog_absr T log_abs(T z) noexcept; -//! template constlog_absr T log_abs(T z) noexcept; +//! template constlog_absr auto log_abs(T z) noexcept; +//! template constlog_absr auto log_abs(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/lpart.hpp b/include/kyosu/functions/lpart.hpp new file mode 100644 index 00000000..73eb0c74 --- /dev/null +++ b/include/kyosu/functions/lpart.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_lpart : eve::elementwise, extractor<4> + { + using callable_tag_type = callable_lpart; + + KYOSU_DEFERS_CALLABLE(lpart_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto, T const&) noexcept { return T{0}; } + + template + KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target)) + { + return eve::tag_invoke(*this, target); + } + + template + KYOSU_FORCEINLINE auto operator()(T& 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 lpart +//! @brief Extracts the l (fifth) part of a value. +//! +//! **Defined in Header** +//! +//! @code +//! #include +//! @endcode +//! +//! @groupheader{Callable Signatures} +//! +//! @code +//! namespace kyosu +//! { +//! template constexpr auto& lpart(T& z) noexcept; +//! template constexpr auto lpart(T const& z) noexcept; +//! template constexpr T lpart(T const& z) noexcept; +//! } +//! @endcode +//! +//! **Parameters** +//! +//! * `z` : Original value. +//! +//! **Return value** +//! +//! Returns the fifth part of its argument. +//! +//! For up to quaterion inputs, the call always returns 0. +//! +//! @groupheader{Example} +//! +//! @godbolt{doc/lpart.cpp} +//====================================================================================================================== +inline constexpr tags::callable_lpart lpart = {}; + +//====================================================================================================================== +//! @} +//====================================================================================================================== +} diff --git a/include/kyosu/functions/lpnorm.hpp b/include/kyosu/functions/lpnorm.hpp index f180a46f..00fd6592 100644 --- a/include/kyosu/functions/lpnorm.hpp +++ b/include/kyosu/functions/lpnorm.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(lpnorm_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::floating_value auto const& p + , eve::floating_ordered_value auto const& p , eve::floating_ordered_value auto const&... vs) noexcept { return eve::lpnorm(p, vs...); @@ -56,18 +56,18 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template< floating_value P, typename T, typename ... Ts> -//! auto operator()(P p, T z,Ts ... zs ) const noexcept +//! template< floating_value P, typename T, typename ... Ts> auto lpnorm(P p, T z,Ts ... zs ) const noexcept ///! } //! @endcode //! //! **Parameters** //! -//! * `z, zs...` : Values to process. +//! * `p`: : positive floating ordered value +//! * `zs...` : Values to process. //! //! **Return value** //! -//! Returns \f$ \left(\sum_{i = 0}^n//! |x_i|^p\right)^{\frac1p} \f$. +//! Returns \f$ \left(\sum_{i = 0}^n |x_i|^p\right)^{\frac1p} \f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/manhattan.hpp b/include/kyosu/functions/manhattan.hpp index 940bbff7..ba2cad73 100644 --- a/include/kyosu/functions/manhattan.hpp +++ b/include/kyosu/functions/manhattan.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(manhattan_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const&... vs) noexcept + , eve::floating_ordered_value auto const&... vs) noexcept { return eve::manhattan(vs...); } @@ -29,9 +29,9 @@ namespace kyosu::tags return eve::tag_invoke(*this, targets...); } -// template -// eve::unsupported_call operator()(T&&... x) const -// requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; }; } @@ -54,8 +54,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template< floating_value P, typename ... Ts> -//! auto operator()(Ts ... zi ) const noexcept +//! template< floating_value P, typename ... Ts> auto manhattan(Ts ... zi ) const noexcept ///! } //! @endcode //! @@ -65,7 +64,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the sum of the absolute values of all elements of all zi. +//! Returns elementwise the sum of the absolute values of all elements of each zi. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/minus.hpp b/include/kyosu/functions/minus.hpp index bc728732..5e6e9b83 100644 --- a/include/kyosu/functions/minus.hpp +++ b/include/kyosu/functions/minus.hpp @@ -53,13 +53,13 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T minus(T z) noexcept; -//! template constexpr T minus(T z) noexcept; +//! template constexpr T minus(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Value to minusugate. +//! * `z` : Value to process. //! //! **Return value** //! diff --git a/include/kyosu/functions/nearest.hpp b/include/kyosu/functions/nearest.hpp index 09c985b4..de722120 100644 --- a/include/kyosu/functions/nearest.hpp +++ b/include/kyosu/functions/nearest.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(nearest_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::nearest(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T nearest(T z) noexcept; -//! template constexpr T nearest(T z) noexcept; +//! template constexpr T nearest(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/oneminus.hpp b/include/kyosu/functions/oneminus.hpp index 0e6ae8f3..100e9cd9 100644 --- a/include/kyosu/functions/oneminus.hpp +++ b/include/kyosu/functions/oneminus.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(oneminus_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::oneminus(v); } template @@ -38,7 +38,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var oneminus -//! @brief Computes the value 1 minus the argument. +//! @brief Computes the value one minus the argument. //! //! **Defined in Header** //! @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T oneminus(T z) noexcept; -//! template constexpr T oneminus(T z) noexcept; +//! template constexpr T oneminus(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns 1 minus the argument. +//! Returns one minus the argument. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/pow.hpp b/include/kyosu/functions/pow.hpp index ff96d63e..a040d9aa 100644 --- a/include/kyosu/functions/pow.hpp +++ b/include/kyosu/functions/pow.hpp @@ -16,11 +16,18 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(pow_); + template < eve::floating_ordered_value U, eve::ordered_value V> static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , U const& v0 + , V const& v1) noexcept { - return eve::pow(v0, v1); + if constexpr(eve::integral_value) + return eve::pow(v0, v1); + else + { + auto fn = callable_pow{}; + return fn(kyosu::complex(v0), v1); + } } KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1) const noexcept @@ -54,11 +61,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto pow(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow(T0 z0, T1, z1) noexcept; -//! template constexpr auto pow(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto pow(auto z0, auto, z1) noexcept; \\123 +//! constexpr auto pow(auto z0, eve::integral_value n) noexcept; \\4 +//! } //! @endcode //! //! **Parameters** @@ -66,8 +71,39 @@ namespace kyosu //! * `z0, z1` : Values to process. //! //! **Return value** +//! 1. if both parameters are floating the call will act as if they were converted to complex before call +//! 2. if both parameters are floating or complex. The ieee specification are taken:\n +//! In particular we have (IEC 60559): //! -//! the call is semantically equivalent to `eve::exp(z1*eve::log(z0))` +//! * pow(+0, y), where y is a negative odd integer, returns \f$+\infty\f$ +//! * pow(-0, y), where y is a negative odd integer, returns \f$-\infty\f$ +//! * pow(\f$\pm0\f$, y), where y is negative, finite, and is an even integer or a non-integer, +//! returns \f$+\infty\f$ +//! * pow(\f$\pm0\f$, \f$-\infty\f$) returns \f$+\infty\f$ +//! * pow(+0, y), where y is a positive odd integer, returns +0 +//! * pow(-0, y), where y is a positive odd integer, returns -0 +//! * pow(\f$\pm0\f$, y), where y is positive non-integer or a positive even integer, returns +0 +//! * pow(-1,\f$\pm\infty\f$) returns 1 +//! * pow(+1, y) returns 1 for any y, even when y is NaN +//! * pow(x, \f$\pm0\f$) returns 1 for any x, even when x is NaN +//! * pow(x, y) returns NaN if x is finite and less than 0 and y is finite and non-integer. +//! * pow(x, \f$-\infty\f$) returns \f$+\infty\f$ for any |x|<1 +//! * pow(x, \f$-\infty\f$) returns +0 for any |x|>1 +//! * pow(x, \f$+\infty\f$) returns +0 for any |x|<1 +//! * pow(x, \f$+\infty\f$) returns \f$+\infty\f$ for any |x|>1 +//! * pow(\f$-\infty\f$, y) returns -0 if y is a negative odd integer +//! * pow(\f$-\infty\f$, y) returns +0 if y is a negative non-integer or even integer +//! * pow(\f$-\infty\f$, y) returns \f$-\infty\f$ if y is a positive odd integer +//! * pow(\f$-\infty\f$, y) returns \f$+\infty\f$ if y is a positive non-integer or even integer +//! * pow(\f$+\infty\f$, y) returns +0 for any y less than 0 +//! * pow(\f$+\infty\f$, y) returns \f$+\infty\f$ for any y greater than 0 +//! * except where specified above, if any argument is NaN, NaN is returned +//! +//! 3. if any parameter as a dimensionnality greater yhan 2, the call is semantically equivalent +//! to `kyosu::exp(z1*eve::log(z0))` +//! +//! 4. pow can accept an integral typed second parameter, in this case it is the russian peasant algorithm +//! that is used. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/pow1p.hpp b/include/kyosu/functions/pow1p.hpp index 9bdf03bd..42f5eb44 100644 --- a/include/kyosu/functions/pow1p.hpp +++ b/include/kyosu/functions/pow1p.hpp @@ -17,8 +17,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(pow1p_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::pow1p(v0, v1); } @@ -54,11 +54,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto pow1p(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow1p(T0 z0, T1, z1) noexcept; -//! template constexpr auto pow1p(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow1p(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto average(auto z0, auto, z1) noexcept; +//! } //! @endcode //! //! **Parameters** @@ -67,7 +64,7 @@ namespace kyosu //! //! **Return value** //! -//! the call is semantically equivalent to `eve::exp(z1*eve::log1p(z0))` +//! the call is semantically equivalent to `pow(inc(z))` //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/pow_abs.hpp b/include/kyosu/functions/pow_abs.hpp index bdd661e9..e2b375d8 100644 --- a/include/kyosu/functions/pow_abs.hpp +++ b/include/kyosu/functions/pow_abs.hpp @@ -20,7 +20,7 @@ namespace kyosu::tags , eve::ordered_value auto const& v0 , eve::ordered_value auto const& v1) noexcept { - return eve::pow(eve::abs(v0), v1); + return eve::pow(kyosu::abs(v0), v1); } KYOSU_FORCEINLINE auto operator()(auto const& target0, auto const& target1) const noexcept @@ -54,11 +54,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto pow_abs(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow_abs(T0 z0, T1, z1) noexcept; -//! template constexpr auto pow_abs(T0 z0, T1, z1) noexcept; -//! template > constexpr auto pow_abs(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto pow_abs(auto z0, auto, z1) noexcept; +//! } //! @endcode //! //! **Parameters** @@ -67,7 +64,8 @@ namespace kyosu //! //! **Return value** //! -//! the call is semantically equivalent to `eve::exp(abs(z1)*log(z0))` +//! the call is semantically equivalent to `kyosu::exp(log_abs(z0)*z1)` In particular if z1 is floating typed the +//! result is floating_typed, which is not the case of kyosu::pow(abs(z0), z1); //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/powm1.hpp b/include/kyosu/functions/powm1.hpp index 4b0ce9e8..35320e75 100644 --- a/include/kyosu/functions/powm1.hpp +++ b/include/kyosu/functions/powm1.hpp @@ -18,8 +18,8 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(powm1_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::powm1(v0, v1); //dec(eve::pow(v0, v1)); } @@ -55,11 +55,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto powm1(T0 z0, T1, z1) noexcept; -//! template > constexpr auto powm1(T0 z0, T1, z1) noexcept; -//! template constexpr auto powm1(T0 z0, T1, z1) noexcept; -//! template > constexpr auto powm1(T0 z0, T1, z1) noexcept; -///! } +//! constexpr auto average(auto z0, auto, z1) noexcept; +//! } //! @endcode //! //! **Parameters** @@ -68,7 +65,7 @@ namespace kyosu //! //! **Return value** //! -//! the call is semantically equivalent to `eve::exp(z1*eve::log(z0))-1` +//! the call is semantically equivalent to `dec(eve::pow(z0, z1))` //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/proj.hpp b/include/kyosu/functions/proj.hpp index 6f9afc83..75450e3f 100644 --- a/include/kyosu/functions/proj.hpp +++ b/include/kyosu/functions/proj.hpp @@ -17,9 +17,9 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(proj_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { - return complex(v,eve::sign(v)*eve::zero(eve::as(v))); + return eve::if_else(eve::is_not_finite(v), eve::inf(eve::as(v)), v); } template @@ -40,7 +40,8 @@ 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 +//! @brief Callable object computing proj(x), the projection of the cayley_dickson number +//! z onto the (hyper) Riemann sphere //! //! **Defined in Header** //! @@ -54,21 +55,20 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T proj(T z) noexcept; -//! template constexpr T proj(T z) noexcept; +//! template constexpr T proj(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Value to projugate. +//! * `z` : Value to project. //! //! **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. +//! * For most z, proj(z)==z, but all infinities, even the numbers where one component +//! is infinite and the other is NaN, become positive real\n +//! infinity, (inf, 0.0...) or (inf, -0.0...).\n +//! The sign of the pure (zero) components are the signs of the components of pure(z). //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/pure.hpp b/include/kyosu/functions/pure.hpp index 5afe2ceb..b61bf59d 100644 --- a/include/kyosu/functions/pure.hpp +++ b/include/kyosu/functions/pure.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(pure_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::zero(eve::as(v)); } template @@ -43,7 +43,7 @@ namespace kyosu //====================================================================================================================== //! @addtogroup functions //! @{ -//! @var imag +//! @var pure //! @brief Extracts the imaginary part of a value. //! //! **Defined in Header** @@ -57,9 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto& pure(T& z) noexcept; //! template constexpr auto pure(T const& z) noexcept; -//! template constexpr T pure(T const& z) noexcept; +//! template constexpr T pure(T const& z) noexcept; //! } //! @endcode //! @@ -69,7 +68,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the imaginary part of its argument. For real inputs, the call returns 0. It is an alias of `imag`. +//! Returns the pure (also called imaginary) part of its argument. For real inputs, the call returns 0. It is an alias of `imag`. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/radinpi.hpp b/include/kyosu/functions/radinpi.hpp index 6e828357..189b19c0 100644 --- a/include/kyosu/functions/radinpi.hpp +++ b/include/kyosu/functions/radinpi.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(radinpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return T(0); }//eve::radinpi(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr as_real_t radinpi(T z) noexcept; -//! template constexpr T radinpi(T z) noexcept; +//! template constexpr T radinpi(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/real.hpp b/include/kyosu/functions/real.hpp index bd2c39b8..5ace6aac 100644 --- a/include/kyosu/functions/real.hpp +++ b/include/kyosu/functions/real.hpp @@ -17,10 +17,10 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(real_); - template + template static KYOSU_FORCEINLINE auto& deferred_call(auto, T& v) noexcept { return v; } - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return v; } template @@ -62,8 +62,8 @@ namespace kyosu //! { //! template constexpr auto& real(T& z) noexcept; //! template constexpr auto real(T const& z) noexcept; -//! template constexpr T& real(T& z) noexcept; -//! template constexpr T real(T const& z) noexcept; +//! template constexpr T& real(T& z) noexcept; +//! template constexpr T real(T const& z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/rec.hpp b/include/kyosu/functions/rec.hpp index f8b70397..12238a1c 100644 --- a/include/kyosu/functions/rec.hpp +++ b/include/kyosu/functions/rec.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(rec_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::rec(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T rec(T z) noexcept; -//! template constexpr T rec(T z) noexcept; +//! template constexpr T rec(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/reldist.hpp b/include/kyosu/functions/reldist.hpp index b0d8cfb6..e8617fa8 100644 --- a/include/kyosu/functions/reldist.hpp +++ b/include/kyosu/functions/reldist.hpp @@ -19,8 +19,8 @@ namespace kyosu::tags static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1) noexcept { return eve::reldist(v0, v1); } @@ -56,10 +56,7 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto reldist(T0 z0, T1, z1) noexcept; -//! template > constexpr auto reldist(T0 z0, T1, z1) noexcept; -//! template constexpr auto reldist(T0 z0, T1, z1) noexcept; -//! template > constexpr auto reldist(T0 z0, T1, z1) noexcept; +//! constexpr auto reldist(auto z0, auto, z1) noexcept; ///! } //! @endcode //! diff --git a/include/kyosu/functions/rot_angle.hpp b/include/kyosu/functions/rot_angle.hpp index 2918995f..04464fc8 100644 --- a/include/kyosu/functions/rot_angle.hpp +++ b/include/kyosu/functions/rot_angle.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(rot_angle_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { @@ -66,11 +66,11 @@ namespace kyosu //! //! **Parameters** //! - //! `q` : quaternion + //! `q` : quaternion, complex or floating //! //! **Return value** //! - //! the rotation angle in radian + //! the rotation angle in radian. This is two times the arg of the quaternion. //! //! --- //! diff --git a/include/kyosu/functions/rot_axis.hpp b/include/kyosu/functions/rot_axis.hpp index 42f6ff0d..bb189c5a 100644 --- a/include/kyosu/functions/rot_axis.hpp +++ b/include/kyosu/functions/rot_axis.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(rot_axis_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { @@ -66,7 +66,7 @@ namespace kyosu //! //! **Parameters** //! - //! `q` : quaternion + //! `q` : quaternion, complex or floating. //! //! **Return value** //! diff --git a/include/kyosu/functions/rotate_vec.hpp b/include/kyosu/functions/rotate_vec.hpp index 3ac1ffd6..07c3f1db 100644 --- a/include/kyosu/functions/rotate_vec.hpp +++ b/include/kyosu/functions/rotate_vec.hpp @@ -80,14 +80,15 @@ namespace kyosu //! @code //! namespace eve //! { - //! auto rotate_vec( auto q) const noexcept; + //! auto rotate_vec( auto q, auto v) const noexcept; //! } //! @endcode //! //! **Parameters** //! //! `q`: quaternion value defining the rotation. - //! `x`: span of 3 elements to rotate + //! + //! `v`: span of 3 elements to rotate. //! //! **Return value** //! diff --git a/include/kyosu/functions/sec.hpp b/include/kyosu/functions/sec.hpp index a0450308..7b193ff4 100644 --- a/include/kyosu/functions/sec.hpp +++ b/include/kyosu/functions/sec.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sec_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sec(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sec(T z) noexcept; -//! template constexpr T sec(T z) noexcept; +//! template constexpr auto sec(T z) noexcept; +//! template constexpr auto sec(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the secant of the argument. +//! Returns the secant of the argument. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sech.hpp b/include/kyosu/functions/sech.hpp index 15d48fa9..94c0f0ff 100644 --- a/include/kyosu/functions/sech.hpp +++ b/include/kyosu/functions/sech.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sech_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sech(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sech(T z) noexcept; -//! template constexpr T sech(T z) noexcept; +//! template constexpr auto sech(T z) noexcept; +//! template constexpr auto sech(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/secpi.hpp b/include/kyosu/functions/secpi.hpp index 6cdc661c..046ec24a 100644 --- a/include/kyosu/functions/secpi.hpp +++ b/include/kyosu/functions/secpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(secpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::secpi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var secpi -//! @brief Computes the secant of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the secant of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T secpi(T z) noexcept; -//! template constexpr T secpi(T z) noexcept; +//! template constexpr auto secpi(T z) noexcept; +//! template constexpr auto secpi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the secant of the argument in \f$\pi\f$ mutiples. +//! Returns the secant of the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sign.hpp b/include/kyosu/functions/sign.hpp index 9fdb17d0..e28d4c7e 100644 --- a/include/kyosu/functions/sign.hpp +++ b/include/kyosu/functions/sign.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sign_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sign(v); @@ -55,13 +55,13 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T sign(T z) noexcept; -//! template constexpr T sign(T z) noexcept; +//! template constexpr T sign(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! -//! * `z` : Value to for which square root is computed. +//! * `z` : Value to process. //! //! **Return value** //! diff --git a/include/kyosu/functions/sin.hpp b/include/kyosu/functions/sin.hpp index 0d43f0f2..35632931 100644 --- a/include/kyosu/functions/sin.hpp +++ b/include/kyosu/functions/sin.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sin_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sin(v); } template @@ -52,8 +52,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sin(T z) noexcept; -//! template constexpr T sin(T z) noexcept; +//! template constexpr auto sin(T z) noexcept; //1 +//! template constexpr auto sin(T z) noexcept; //2 +//! template constexpr auto sin(T z) noexcept; //3 //! } //! @endcode //! @@ -63,7 +64,13 @@ namespace kyosu //! //! **Return value** //! -//! Returns the sine of the argument. +//! 1. Returns the sine of the argument. +//! +//! 2. The behavior of this function is equivalent to \f$-i*\sinh(i*z)\f$. +//! +//! 3. Returns \f$-I_z\cosh(I_z\; z)\f$ if \f$z\f$ is not zero else \f$\sin(z_0)\f$, +//! where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sinc.hpp b/include/kyosu/functions/sinc.hpp index d3112d96..c1df71f9 100644 --- a/include/kyosu/functions/sinc.hpp +++ b/include/kyosu/functions/sinc.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sinc_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sinc(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sinc(T z) noexcept; -//! template constexpr T sinc(T z) noexcept; +//! template constexpr auto sinc(T z) noexcept; +//! template constexpr auto sinc(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/sincos.hpp b/include/kyosu/functions/sincos.hpp index ef8f09bd..d14ad61a 100644 --- a/include/kyosu/functions/sincos.hpp +++ b/include/kyosu/functions/sincos.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sincos_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sincos(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var sincos -//! @brief Computes simultaneously the sine and cosine of the argument. +//! @brief Computes simultaneously the sine and cosine of the argument. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto sincos(T z) noexcept; -//! template constexpr auto sincos(T z) noexcept; +//! template constexpr auto sincos(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/sinh.hpp b/include/kyosu/functions/sinh.hpp index aeea7dc3..94e117f9 100644 --- a/include/kyosu/functions/sinh.hpp +++ b/include/kyosu/functions/sinh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sinh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sinh(v); } template @@ -52,8 +52,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sinh(T z) noexcept; -//! template constexpr T sinh(T z) noexcept; +//! template constexpr auto sinh(T z) noexcept; //1 +//! template constexpr auto sinh(T z) noexcept; //2 //! } //! @endcode //! @@ -63,7 +63,26 @@ namespace kyosu //! //! **Return value** //! -//! Returns the hyperbolic sine of the argument. +//! 1. Returns the hyperbolic sine of the argument. +//! +//! 2. Returns elementwise the complex value +//! of the hyperbolic sine of the input. +//! +//! * for every z: `eve::sinh(kyosu::conj(z)) == kyosu::conj(std::sinh(z))` +//! * for every z: `kyosu::sinh(-z) == -kyosu::sinh(z)` +//! * If z is \f$+0\f$, the result is \f$+0\f$ +//! * If z is \f$i \infty\f$, the result is \f$i NaN\f$ (the sign of the real part is unspecified) +//! * If z is \f$i NaN\f$, the result is \f$NaN\f$ +//! * If z is \f$x+i \infty\f$ (for any positive finite x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$x+i NaN\f$ (for any positive finite x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$+\infty\f$, the result is \f$+\infty\f$ +//! * If z is \f$+\infty+i y\f$ (for any positive finite y), the result is \f$\infty\times e^{iy}\f$ +//! * If z is \f$+\infty+i \infty\f$, the result is \f$\pm \infty+i NaN\f$ (the sign of the real part is unspecified) +//! * If z is \f$+\infty+i NaN\f$, the result is \f$\pm \infty+i NaN\f$ (the sign of the real part is unspecified) +//! * If z is \f$NaN\f$, the result is \f$NaN\f$ +//! * If z is \f$NaN+i y\f$ (for any finite nonzero y), the result is \f$NaN+i NaN\f$ +//! +//! 3. Is semantically equivalent to (exp(z)-exp(-z))/2. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sinhcosh.hpp b/include/kyosu/functions/sinhcosh.hpp index 74cb60a1..c35f2c6f 100644 --- a/include/kyosu/functions/sinhcosh.hpp +++ b/include/kyosu/functions/sinhcosh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sinhcosh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sinhcosh(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto sinhcosh(T z) noexcept; -//! template constexpr auto sinhcosh(T z) noexcept; +//! template constexpr auto sinhcosh(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/sinpi.hpp b/include/kyosu/functions/sinpi.hpp index 01418569..a286302d 100644 --- a/include/kyosu/functions/sinpi.hpp +++ b/include/kyosu/functions/sinpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sinpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sinpi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var sinpi -//! @brief Computes the sine of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the sine of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T sinpi(T z) noexcept; -//! template constexpr T sinpi(T z) noexcept; +//! template constexpr T sinpi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the sine of the argument in \f$\pi\f$ mutiples. +//! Returns the sine of the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sinpicospi.hpp b/include/kyosu/functions/sinpicospi.hpp index 3f5d0559..68943ab5 100644 --- a/include/kyosu/functions/sinpicospi.hpp +++ b/include/kyosu/functions/sinpicospi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sinpicospi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sinpicospi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var sinpicospi -//! @brief Computes simultaneously the sine and cosine of the argument in \f$\pi\f$ mutiples. +//! @brief Computes simultaneously the sine and cosine of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr auto sinpicospi(T z) noexcept; -//! template constexpr auto sinpicospi(T z) noexcept; +//! template constexpr auto sinpicospi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns simultaneously the sine and cosine of the argument in \f$\pi\f$ mutiples. +//! Returns simultaneously the sine and cosine of the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/slerp.hpp b/include/kyosu/functions/slerp.hpp index 59562934..0c21f286 100644 --- a/include/kyosu/functions/slerp.hpp +++ b/include/kyosu/functions/slerp.hpp @@ -18,9 +18,9 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(slerp_); static KYOSU_FORCEINLINE auto deferred_call(auto - , eve::ordered_value auto const& v0 - , eve::ordered_value auto const& v1 - , eve::ordered_value auto const& t) noexcept + , eve::floating_ordered_value auto const& v0 + , eve::floating_ordered_value auto const& v1 + , eve::floating_ordered_value auto const& t) noexcept { EVE_ASSERT(eve::all(is_unitary(v0) && is_unitary(v1)), "quaternion parameters must be unitary"); return v0; @@ -57,11 +57,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto slerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template > constexpr auto slerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template constexpr auto slerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -//! template > constexpr auto slerp(T0 z0, T1, z1, auto eve::ordered_value t) noexcept; -///! } +//! constexpr auto lerp(auto z0, auto, z1, floating_ordered_value t) noexcept; +//! } //! @endcode //! //! **Parameters** diff --git a/include/kyosu/functions/sqr.hpp b/include/kyosu/functions/sqr.hpp index acdb742b..285b066e 100644 --- a/include/kyosu/functions/sqr.hpp +++ b/include/kyosu/functions/sqr.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sqr_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return v*v; } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T sqr(T z) noexcept; -//! template constexpr T sqr(T z) noexcept; +//! template constexpr T sqr(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/functions/sqr_abs.hpp b/include/kyosu/functions/sqr_abs.hpp index 284d1937..8e52711f 100644 --- a/include/kyosu/functions/sqr_abs.hpp +++ b/include/kyosu/functions/sqr_abs.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(sqr_abs_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sqr_abs(v); } template @@ -51,8 +51,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr as_real_t sqr_abs(T z) noexcept; -//! template constexpr T sqr_abs(T z) noexcept; +//! template constexpr auto sqr_abs(T z) noexcept; +//! template constexpr auto sqr_abs(T z) noexcept; //! } //! @endcode //! @@ -62,7 +62,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the squared modulus of its argument. +//! Returns the squared modulus of its argument, a floating value. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/sqrt.hpp b/include/kyosu/functions/sqrt.hpp index dec55303..a06f3071 100644 --- a/include/kyosu/functions/sqrt.hpp +++ b/include/kyosu/functions/sqrt.hpp @@ -57,8 +57,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T sqrt(T z) noexcept; -//! template constexpr T sqrt(T z) noexcept; +//! template constexpr T sqrt(T z) noexcept; //1 +//! template constexpr T sqrt(T z) noexcept; //2 +//! template constexpr T sqrt(T z) noexcept; //3 //! } //! @endcode //! @@ -68,7 +69,26 @@ namespace kyosu //! //! **Return value** //! -//! Returns a square root of its argument. +//! 1. a real typed input z is treated as if [kyosu::complex](@ref kyosu::complex)(z) was entered. +//! +//! 2. Returns the elementwise the square root of z, +//! in the range of the right half-plane, including the imaginary axis (\f$[0, +\infty]\f$ +//! along the real axis and \f$[-\infty, +\infty]\f$ along the imaginary axis.) +//! +//! * The function is continuous onto the branch cut taking into account +//! the sign of imaginary part +//! * eve::sqrt(kyosu::conj(z)) == kyosu::conj(kyosu::sqrt(z)) +//! * If z is \f$\pm0\f$, the result is \f$+0\f$ +//! * If z is \f$x+i \infty\f$, the result is \f$\infty+i \infty\f$ even if x is \f$NaN\f$ +//! * If z is \f$x,NaN\f$, the result is \f$NaN,NaN\f$ (unless x is \f$\pm\infty\f$) +//! * If z is \f$-\infty+i y\f$, the result is \f$+0+i \infty\f$ for finite positive y +//! * If z is \f$+\infty+i y\f$, the result is \f$+\infty+i 0\f$ for finite positive y +//! * If z is \f$-\infty+i NaN\f$, the result is \f$NaN \pm i \infty\f$ (sign of imaginary part unspecified) +//! * If z is \f$+\infty+i NaN\f$, the result is \f$+\infty+i NaN\f$ +//! * If z is \f$NaN+i y\f$, the result is \f$NaN+i NaN\f$ +//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ +//! +//! 2. Returns a square root of z. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/tan.hpp b/include/kyosu/functions/tan.hpp index e604dc7a..07ed7dc2 100644 --- a/include/kyosu/functions/tan.hpp +++ b/include/kyosu/functions/tan.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(tan_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::tan(v); } template @@ -52,8 +52,9 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr T tan(T z) noexcept; -//! template constexpr T tan(T z) noexcept; +//! template constexpr T tan(T z) noexcept; //1 +//! template constexpr T tan(T z) noexcept; //2 +//! template constexpr T tan(T z) noexcept; //3 //! } //! @endcode //! @@ -63,7 +64,12 @@ namespace kyosu //! //! **Return value** //! -//! Returns the tangent of the argument. +//! 1. Returns eve::tan(z) +//! +//! 2. The behavior of this function is equivalent to \f$-i\tanh(i\; z)\f$. +//! +//! 3. Returns \f$-I_z\,; \tanh(I_z\; z)\f$ if \f$z\f$ is not zero else \f$\tan(z_0)\f$, where \f$I_z = \frac{\underline{z}}{|\underline{z}|}\f$ and +//! \f$\underline{z}\f$ is the [pure](@ref kyosu::imag ) part of \f$z\f$. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/tanh.hpp b/include/kyosu/functions/tanh.hpp index 71d81642..fc20bd97 100644 --- a/include/kyosu/functions/tanh.hpp +++ b/include/kyosu/functions/tanh.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(tanh_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::tanh(v); } template @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T tanh(T z) noexcept; -//! template constexpr T tanh(T z) noexcept; +//! template constexpr T tanh(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,26 @@ namespace kyosu //! //! **Return value** //! -//! Returns the hyperbolic tangent of the argument. +//! 1. Returns eve::tanh(z). +//! +//! 2. Returns elementwise the complex value +//! of the hyperbolic tangent of the input. +//! +//! * for every z: `kyosu::tanh(kyosu::conj(z)) == kyosu::conj(std::tanh(z))` +//! * for every z: `kyosu::tanh(-z) == -kyosu::tanh(z)` +//! * If z is \f$+0\f$, the result is \f$+0\f$ +//! * If z is \f$x+i \infty\f$ (for any non zero finite x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$i \infty\f$ the result is \f$i NaN\f$ +//! * If z is \f$x,NaN\f$ (for any non zero finite x), the result is \f$NaN+i NaN\f$ +//! * If z is \f$i NaN\f$ the result is \f$i NaN\f$ +//! * If z is \f$+\infty,y\f$ (for any finite positive y), the result is \f$1\f$ +//! * If z is \f$+\infty+i \infty\f$, the result is \f$1,\pm 0\f$ (the sign of the imaginary part is unspecified) +//! * If z is \f$+\infty+i NaN\f$, the result is \f$1\f$ (the sign of the imaginary part is unspecified) +//! * If z is \f$NaN\f$, the result is \f$NaN\f$ +//! * If z is \f$NaN+i y\f$ (for any non-zero y), the result is \f$NaN+i NaN\f$ +//! * If z is \f$NaN+i NaN\f$, the result is \f$NaN+i NaN\f$ +//! +//! 3. The call is semantically equivalent to sinh(z)/cosh(z); //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/tanpi.hpp b/include/kyosu/functions/tanpi.hpp index 3bc90d17..fefc2d91 100644 --- a/include/kyosu/functions/tanpi.hpp +++ b/include/kyosu/functions/tanpi.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(tanpi_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::tanpi(v); } template @@ -39,7 +39,7 @@ namespace kyosu //! @addtogroup functions //! @{ //! @var tanpi -//! @brief Computes the tangent of the argument in \f$\pi\f$ mutiples. +//! @brief Computes the tangent of the argument in \f$\pi\f$ multiples. //! //! **Defined in Header** //! @@ -53,7 +53,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T tanpi(T z) noexcept; -//! template constexpr T tanpi(T z) noexcept; +//! template constexpr T tanpi(T z) noexcept; //! } //! @endcode //! @@ -63,7 +63,7 @@ namespace kyosu //! //! **Return value** //! -//! Returns the tangent of the argument in \f$\pi\f$ mutiples. +//! Returns the tangent of the argument in \f$\pi\f$ multiples. //! //! @groupheader{Example} //! diff --git a/include/kyosu/functions/to_angle_axis.hpp b/include/kyosu/functions/to_angle_axis.hpp index 62a11a66..d8af749b 100644 --- a/include/kyosu/functions/to_angle_axis.hpp +++ b/include/kyosu/functions/to_angle_axis.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(to_angle_axis_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { diff --git a/include/kyosu/functions/to_complex.hpp b/include/kyosu/functions/to_complex.hpp index 9347c111..cb29647a 100644 --- a/include/kyosu/functions/to_complex.hpp +++ b/include/kyosu/functions/to_complex.hpp @@ -48,15 +48,15 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! template constexpr auto complex(T r, T i = 0) noexcept; -//! template constexpr T complex(T z) noexcept; +//! template constexpr auto complex(T r, T i = 0) noexcept; +//! template constexpr T complex(T z) noexcept; //! } //! @endcode //! //! **Parameters** //! //! * `z` : Complex value. -//! * `r`, `i` : Real and imaginary part sued to construct a @ref kyosu::complex.. +//! * `r`, `i` : Real and imaginary part used to construct a @ref kyosu::complex.. //! //! **Return value** //! diff --git a/include/kyosu/functions/to_cylindrical.hpp b/include/kyosu/functions/to_cylindrical.hpp index 61492b65..68a9c42d 100644 --- a/include/kyosu/functions/to_cylindrical.hpp +++ b/include/kyosu/functions/to_cylindrical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(to_cylindrical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { diff --git a/include/kyosu/functions/to_cylindrospherical.hpp b/include/kyosu/functions/to_cylindrospherical.hpp new file mode 100644 index 00000000..1118c0dd --- /dev/null +++ b/include/kyosu/functions/to_cylindrospherical.hpp @@ -0,0 +1,87 @@ +//================================================================================================== +/* + KYOSU - Expressive Vector Engine + Copyright : KYOSU Project Contributors + SPDX-License-Identifier: BSL-1.0 +*/ +//================================================================================================== +#pragma once + +#include +#include + +namespace kyosu::tags +{ + struct callable_to_cylindrospherical : eve::elementwise + { + using callable_tag_type = callable_to_cylindrospherical; + + KYOSU_DEFERS_CALLABLE(to_cylindrospherical_); + + template + static KYOSU_FORCEINLINE auto deferred_call(auto + , V const & v) noexcept + { + auto z = eve::zero(eve::as(v)); + return kumi::tuple{v, z, z, z}; + } + + template + KYOSU_FORCEINLINE auto operator()(T0 const& target0 + ) const noexcept + -> decltype(eve::tag_invoke(*this, target0)) + { + return eve::tag_invoke(*this, target0); + } + + template + eve::unsupported_call operator()(T&&... x) const + requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete; + }; +} + +namespace kyosu +{ + //================================================================================================ + //! @addtogroup quaternion + //! @{ + //! @var to_cylindrospherical + //! + //! @brief Callable object computing the cylindrospherical coordinates from a quaternion. + //! + //! This function is the reciprocal of from_cylindrospherical. + //! + //! **Defined in header** + //! + //! @code + //! #include eve/module/quaternion.hpp>` + //! @endcode + //! + //! @groupheader{Callable Signatures} + //! + //! @code + //! namespace eve + //! { + //! auto to_cylindrospherical( auto q) const noexcept; + //! } + //! @endcode + //! + //! **Parameters** + //! + //! `q` : quaternion + //! + //! **Return value** + //! + //! a tuple containing in this order `t`, 'radius', `longitude` 'latitude': the components + //! of the cylindrospherical parametrisation of \f$\mathbb{R}^4\f$ coordinates + //! + //! --- + //! + //! #### Example + //! + //! @godbolt{doc/to_cylindrospherical.cpp} + //! + //! @} + //================================================================================================ + inline constexpr tags::callable_to_cylindrospherical to_cylindrospherical = {}; +} diff --git a/include/kyosu/functions/to_multipolar.hpp b/include/kyosu/functions/to_multipolar.hpp index 5ead8668..2fea07be 100644 --- a/include/kyosu/functions/to_multipolar.hpp +++ b/include/kyosu/functions/to_multipolar.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(to_multipolar_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { diff --git a/include/kyosu/functions/to_polar.hpp b/include/kyosu/functions/to_polar.hpp index 72b0b81d..60afd958 100644 --- a/include/kyosu/functions/to_polar.hpp +++ b/include/kyosu/functions/to_polar.hpp @@ -62,7 +62,7 @@ namespace kyosu //! @code //! namespace eve //! { - //! template constexpr auto arg(T z) noexcept; //1 + //! template constexpr auto arg(T z) noexcept; //1 //! template constexpr auto atan(T z) noexcept; //2 //! template constexpr auto argy(T z) noexcept; //3 //! } diff --git a/include/kyosu/functions/to_quaternion.hpp b/include/kyosu/functions/to_quaternion.hpp index e75bad75..b122936f 100644 --- a/include/kyosu/functions/to_quaternion.hpp +++ b/include/kyosu/functions/to_quaternion.hpp @@ -48,8 +48,8 @@ namespace kyosu //! @code //! namespace kyosu //! { -//! 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 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 diff --git a/include/kyosu/functions/to_semipolar.hpp b/include/kyosu/functions/to_semipolar.hpp index 2388f389..75a03cfa 100644 --- a/include/kyosu/functions/to_semipolar.hpp +++ b/include/kyosu/functions/to_semipolar.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(to_semipolar_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { diff --git a/include/kyosu/functions/to_spherical.hpp b/include/kyosu/functions/to_spherical.hpp index 46fb0999..88b59a8c 100644 --- a/include/kyosu/functions/to_spherical.hpp +++ b/include/kyosu/functions/to_spherical.hpp @@ -18,7 +18,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(to_spherical_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto , V const & v) noexcept { diff --git a/include/kyosu/functions/trunc.hpp b/include/kyosu/functions/trunc.hpp index 3e273f81..810ccbaa 100644 --- a/include/kyosu/functions/trunc.hpp +++ b/include/kyosu/functions/trunc.hpp @@ -17,7 +17,7 @@ namespace kyosu::tags KYOSU_DEFERS_CALLABLE(trunc_); - template + template static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::trunc(v); } template @@ -52,7 +52,7 @@ namespace kyosu //! namespace kyosu //! { //! template constexpr T trunc(T z) noexcept; -//! template constexpr T trunc(T z) noexcept; +//! template constexpr T trunc(T z) noexcept; //! } //! @endcode //! diff --git a/include/kyosu/types/cayley_dickson.hpp b/include/kyosu/types/cayley_dickson.hpp index 78f95cd7..c336d7a6 100644 --- a/include/kyosu/types/cayley_dickson.hpp +++ b/include/kyosu/types/cayley_dickson.hpp @@ -16,7 +16,6 @@ #include #include #include -//#include #include #include #include diff --git a/include/kyosu/types/impl/arithmetic.hpp b/include/kyosu/types/impl/arithmetic.hpp index 494b5651..8e494810 100644 --- a/include/kyosu/types/impl/arithmetic.hpp +++ b/include/kyosu/types/impl/arithmetic.hpp @@ -9,7 +9,7 @@ #include #include -#include + namespace kyosu::_ { template @@ -311,4 +311,37 @@ namespace kyosu::_ { return rho*kyosu::exp(theta*iz); } + + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const&, C0 const & c0, C1 const & c1) noexcept + { + constexpr size_t dC0 = dimension_v; + constexpr size_t dC1 = dimension_v; + if constexpr((dC0 < 4 && dC1 < 4) || (dC0 == 1 || dC1 == 1)) + { + return decltype(c0+c1){}; + } + else + { + return c0*c1 - c1*c0; + } + } + + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const&, C0 const & c0, C1 const & c1, C2 const & c2) noexcept + { + constexpr size_t dC0 = dimension_v; + constexpr size_t dC1 = dimension_v; + constexpr size_t dC2 = dimension_v; + if constexpr((dC0 < 8 && dC1 < 8 && dC1 < 8) || (dC0 == 1 || dC1 == 1 || dC1 == 1)) + { + return decltype(c0+c1+c2){}; + } + else + { + return (c0*c1)*c2 - c0*(c1*c2); + } + } } diff --git a/include/kyosu/types/impl/complex/special.hpp b/include/kyosu/types/impl/complex/special.hpp index bc86fc8e..ab51c7cc 100644 --- a/include/kyosu/types/impl/complex/special.hpp +++ b/include/kyosu/types/impl/complex/special.hpp @@ -117,7 +117,7 @@ namespace kyosu::_ auto z = if_else(negra0, -a0, a0); Z ss{}; for(int pp = N-1; pp >= 1; --pp){ - ss += c[pp]*rec(z+dec(pp)); + ss += c[pp]*rec(z+eve::dec(pp)); } auto zg = z+g-eve::half(eve::as(g)); auto lsq2pi = r_t(0.9189385332046727417803297); @@ -179,7 +179,7 @@ namespace kyosu::_ Z d{}; auto n = d; for(int pp = N-1; pp >= 1; --pp){ - auto dz = rec(z+dec(pp)); + auto dz = rec(z+eve::dec(pp)); auto dd = c[pp]*dz; d += dd; n -= dd*dz; diff --git a/include/kyosu/types/impl/io.hpp b/include/kyosu/types/impl/io.hpp index d6acf5e0..40ea0c67 100644 --- a/include/kyosu/types/impl/io.hpp +++ b/include/kyosu/types/impl/io.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include namespace kyosu { @@ -29,9 +30,8 @@ namespace kyosu auto basis = [&](auto i) { - constexpr const char* base[4] = {" ","i ","j ","k "}; - constexpr const char* obase[8] = {"e0 ","e1 ","e2 ","e3 ","e4 ","e5 ","e6 ","e7 "}; - if constexpr(CD::static_size < 8) return base[i]; else return obase[i]; + constexpr const char* base[8] = {" ","i ","j ","k ","l ","li ","lj ", "lk "}; + if constexpr(CD::static_size < 16) return base[i]; else return "z"+ std::to_string(i) + " "; }; kumi::for_each_index([&](auto i, auto v) { display_positive(os,v,i == 0) << basis(i);}, z); diff --git a/include/kyosu/types/impl/math.hpp b/include/kyosu/types/impl/math.hpp index ccdd7200..d519a7cb 100644 --- a/include/kyosu/types/impl/math.hpp +++ b/include/kyosu/types/impl/math.hpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace kyosu::_ { @@ -450,7 +449,10 @@ namespace kyosu::_ auto dispatch(eve::tag_of const&, C0 const & c0, C1 const & c1) noexcept { auto ac0 = kyosu::sqr_abs(c0); - return kyosu::pow(ac0, c1*eve::half(eve::as(kyosu::real(c0)))); + if constexpr(eve::ordered_value) + return eve::pow(ac0, c1*eve::half(eve::as(ac0))); + else + return kyosu::pow(ac0, c1*eve::half(eve::as(ac0))); } template diff --git a/include/kyosu/types/impl/quaternion/specific.hpp b/include/kyosu/types/impl/quaternion/specific.hpp index b71a3d65..74289854 100644 --- a/include/kyosu/types/impl/quaternion/specific.hpp +++ b/include/kyosu/types/impl/quaternion/specific.hpp @@ -218,6 +218,25 @@ namespace kyosu::_ } } + template + KYOSU_FORCEINLINE constexpr + auto dispatch(eve::tag_of const& + , Z const& q) noexcept + { + auto q0 = get<0>(q); + if constexpr(kyosu::concepts::complex) + { + auto z = eve::zero(eve::as(get<0>(q))); + return kumi::tuple{get<0>(q), eve::abs(get<1>(q)), z, z}; + } + else + { + auto lon = eve::pedantic(eve::atan2)(get<2>(q), get<1>(q)); + auto lat = eve::pedantic(eve::atan2)(get<3>(q)*eve::sin(lon),get<2>(q)); + return kumi::tuple{get<0>(q), abs(pure(q)), lon, lat}; + } + } + template KYOSU_FORCEINLINE constexpr auto dispatch(eve::tag_of const& diff --git a/test/doc/align.cpp b/test/doc/align.cpp new file mode 100644 index 00000000..8809e455 --- /dev/null +++ b/test/doc/align.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +int main() +{ + using kyosu::align; + auto norm = [](auto &v){ + auto n = eve::hypot(v[0], v[1], v[2]); + for(int i=0; i <= 2; ++i) v[i]/= n; + }; + + std::array v0{-1.0, 5.0, 4.0}; + std::array v1{ 1.5, 2.0, -3.0}; + norm(v0); + norm(v1); + auto q = kyosu::align(v0, v1); + std::cout << " v0 " << v0[0] << ", " << v0[1] << ", " << v0[2] << "\n"; + std::cout << " v1 " << v1[0] << ", " << v1[1] << ", " << v1[2] << "\n"; + std::cout << " q " << q << std::endl; + auto rv = kyosu::rotate_vec(q, v0); + std::cout << " rotate_vec(q, v0) " << rv[0] << ", " << rv[1] << ", " << rv[2] << "\n"; + + return 0; +} diff --git a/test/doc/associator.cpp b/test/doc/associator.cpp new file mode 100644 index 00000000..5f663af2 --- /dev/null +++ b/test/doc/associator.cpp @@ -0,0 +1,45 @@ +#include +#include +#include + +int main() +{ + using kyosu::associator; + 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 o_t = kyosu::octonion_t; + + std::cout << "Real: "<< "\n"; + e_t e0(1); + e_t e1(2); + e_t e2(3); + std::cout << e0 << ", " << e1 << ", " << e2<< " -> " << associator(e0, e1, e2) << "\n"; + + std::cout << "Complex: "<< "\n"; + c_t c0(1, 5); + c_t c1(5, 9); + c_t c2(-1, 4); + std::cout << c0 << ", " << c1 << ", " << c2 << " -> " << associator(c0, c1, c2) << "\n"; + + std::cout << "Quaternion: "<< "\n"; + q_t q0(1, 5, -2, 3); + q_t q1(5, 9, 6, 7); + q_t q2(-3, 6, -1, 0); + std::cout << q0 << ", " << q1 << ", " << q2 << " -> " << associator(q0, q1, q2) << "\n"; + + std::cout << "Octonion: "<< "\n"; + o_t o0(1, 5, -2, 3, 4, 8, 13, 1); + o_t o1(5, 9, 6, 7, 6, -4, -1, 2); + o_t o2(-3, 6, -1, 0, 4, 5, -8, 2); + + std::cout << o0 << ", " << o1 << ", " << o2 << " -> " << associator(o0, o1, o2) << "\n"; + std::cout << "Mixed: "<< "\n"; + std::cout << kyosu::associator(c0, o1, o2) << std::endl; + std::cout << kyosu::associator(o0, o1, e0) << std::endl; + + + return 0; +} diff --git a/test/doc/commutator.cpp b/test/doc/commutator.cpp new file mode 100644 index 00000000..736c6bb6 --- /dev/null +++ b/test/doc/commutator.cpp @@ -0,0 +1,51 @@ +#include +#include +#include + +int main() +{ + using kyosu::commutator; + 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, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; + + std::cout << "Real: "<< "\n"; + e_t e0(1); + e_t e1(2); + std::cout << e0 << ", " << e1 << " -> " << commutator(e0, e1) << "\n"; + std::cout << e0 << ", " << e0 << " -> " << commutator(e0, e0) << "\n"; + we_t we0(e0); + we_t we1(e1); + std::cout << we0 << ", " << we1 << " -> " << commutator(we0, we1) << "\n"; + + std::cout << "Complex: "<< "\n"; + c_t c0(1, 5); + c_t c1(5, 9); + std::cout << c0 << ", " << c1 << " -> " << commutator(c0, c1) << "\n"; + std::cout << c0 << ", " << c0 << " -> " << commutator(c0, c0) << "\n"; + wc_t wc0(c0, c1); + wc_t wc1(c1, c1); + std::cout << wc0 << ", " << wc1 << " -> " << commutator(wc0, wc1) << "\n"; + + std::cout << "Quaternion: "<< "\n"; + q_t q0(1, 5, 2, 3); + q_t q1(5, 9, 6, 7); + std::cout << q0 << ", " << q1 << " -> " << commutator(q0, q1) << "\n"; + std::cout << q0 << ", " << q0 << " -> " << commutator(q0, q0) << "\n"; + wq_t wq0(q0, q1); + wq_t wq1(q1, q1); + std::cout << wq0 << ", " << wq1 << " -> " << commutator(wq0, wq1) << "\n"; + + std::cout << "Mixed: "<< "\n"; + std::cout << kyosu::commutator(c0, q1) << std::endl; + std::cout << kyosu::commutator(e0, q1) << std::endl; + std::cout << kyosu::commutator(c0, wq1) << std::endl; + std::cout << kyosu::commutator(we0, q1) << std::endl; + + return 0; +} diff --git a/test/doc/convert.cpp b/test/doc/convert.cpp new file mode 100644 index 00000000..181ce648 --- /dev/null +++ b/test/doc/convert.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +int main() +{ + using kyosu::convert; + using kyosu::complex_t; + using kyosu::quaternion_t; + + double f = 72.987654321; + std::cout << "Real to complex of floats: "; + std::cout << std::setprecision(10) << f << " -> " << convert(f, eve::as>()) << "\n"; + std::cout << "Real to quaternion of double: " ; + std::cout << f << " -> " << convert(f, eve::as>()) << "\n"; + + std::cout << "Complex to quaternion ofdouble: "; + auto c = kyosu::complex(3.5f,-2.9f); + std::cout << c << " -> " << convert(c, eve::as>()) << "\n"; + + return 0; +} diff --git a/test/doc/lipart.cpp b/test/doc/lipart.cpp new file mode 100644 index 00000000..b754ba95 --- /dev/null +++ b/test/doc/lipart.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + using kyosu::lipart; + using kyosu::complex_t; + using kyosu::quaternion_t; + + std::cout << "Real: "; + float f = 72.9f; + std::cout << f << " -> " << lipart(f) << "\n"; + + std::cout << "Complex: "; + auto z = kyosu::complex_t(3.5f,-2.9f); + std::cout << z << " -> " << lipart(z) << "\n"; + + std::cout << "Quaternion: "; + auto q = kyosu::quaternion_t(1.,2.,3.,4.); + std::cout << q << " -> " << lipart(q) << " => "; + + std::cout << "octonion: "; + auto o = kyosu::octonion_t(1.,2.,3.,4.,11.,12.,13.,14.); + std::cout << o << " -> " << lipart(q) << " => "; + + + return 0; +} diff --git a/test/doc/ljpart.cpp b/test/doc/ljpart.cpp new file mode 100644 index 00000000..30b6cd4e --- /dev/null +++ b/test/doc/ljpart.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + using kyosu::ljpart; + using kyosu::complex_t; + using kyosu::quaternion_t; + + std::cout << "Real: "; + float f = 72.9f; + std::cout << f << " -> " << ljpart(f) << "\n"; + + std::cout << "Complex: "; + auto z = kyosu::complex_t(3.5f,-2.9f); + std::cout << z << " -> " << ljpart(z) << "\n"; + + std::cout << "Quaternion: "; + auto q = kyosu::quaternion_t(1.,2.,3.,4.); + std::cout << q << " -> " << ljpart(q) << " => "; + + std::cout << "octonion: "; + auto o = kyosu::octonion_t(1.,2.,3.,4.,11.,12.,13.,14.); + std::cout << o << " -> " << ljpart(o) << " => "; + + + return 0; +} diff --git a/test/doc/lkpart.cpp b/test/doc/lkpart.cpp new file mode 100644 index 00000000..e048a1fc --- /dev/null +++ b/test/doc/lkpart.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + using kyosu::lkpart; + using kyosu::complex_t; + using kyosu::quaternion_t; + + std::cout << "Real: "; + float f = 72.9f; + std::cout << f << " -> " << lkpart(f) << "\n"; + + std::cout << "Complex: "; + auto z = kyosu::complex_t(3.5f,-2.9f); + std::cout << z << " -> " << lkpart(z) << "\n"; + + std::cout << "Quaternion: "; + auto q = kyosu::quaternion_t(1.,2.,3.,4.); + std::cout << q << " -> " << lkpart(q) << " => "; + + std::cout << "octonion: "; + auto o = kyosu::octonion_t(1.,2.,3.,4.,11.,12.,13.,14.); + std::cout << o << " -> " << lkpart(o) << " => "; + + + return 0; +} diff --git a/test/doc/lpart.cpp b/test/doc/lpart.cpp new file mode 100644 index 00000000..b2a720d6 --- /dev/null +++ b/test/doc/lpart.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() +{ + using kyosu::lpart; + using kyosu::complex_t; + using kyosu::quaternion_t; + + std::cout << "Real: "; + float f = 72.9f; + std::cout << f << " -> " << lpart(f) << "\n"; + + std::cout << "Complex: "; + auto z = kyosu::complex_t(3.5f,-2.9f); + std::cout << z << " -> " << lpart(z) << "\n"; + + std::cout << "Quaternion: "; + auto q = kyosu::quaternion_t(1.,2.,3.,4.); + std::cout << q << " -> " << lpart(q) << " => "; + + std::cout << "octonion: "; + auto o = kyosu::octonion_t(1.,2.,3.,4.,11.,12.,13.,14.); + std::cout << o << " -> " << lpart(o) << " => "; + + + return 0; +} diff --git a/test/doc/to_complex.hpp b/test/doc/to_complex.hpp deleted file mode 100644 index 14606bf8..00000000 --- a/test/doc/to_complex.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#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_cylindrospherical.cpp b/test/doc/to_cylindrospherical.cpp new file mode 100644 index 00000000..7950934f --- /dev/null +++ b/test/doc/to_cylindrospherical.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +int main() +{ + using kyosu::to_cylindrospherical; + 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, eve::fixed<2>>; + using wq_t = eve::wide, eve::fixed<2>>; + + std::cout << "Real: "<< "\n"; + e_t e0(1); + std::cout << e0 << " -> " << to_cylindrospherical(e0) << "\n"; + we_t we0(e0); + std::cout << we0 << " -> " << to_cylindrospherical(we0) << "\n"; + + std::cout << "Complex: "<< "\n"; + c_t c0(1, 5); + std::cout << c0 << " -> " << to_cylindrospherical(c0) << "\n"; + wc_t wc0(c0); + std::cout << wc0 << " -> " << to_cylindrospherical(wc0) << "\n"; + + std::cout << "Quaternion: "<< "\n"; + q_t q0(1, 5, 2, 3); + std::cout << q0 << " -> " << to_cylindrospherical(q0) << "\n"; + wq_t wq0(q0); + std::cout << wq0 << " -> " << to_cylindrospherical(wq0) << "\n"; + + return 0; +} diff --git a/test/unit/complex/erfi.hpp b/test/unit/complex/erfi.hpp deleted file mode 100644 index 39d68545..00000000 --- a/test/unit/complex/erfi.hpp +++ /dev/null @@ -1,81 +0,0 @@ -//====================================================================================================================== -/* - 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/function/lipart.cpp b/test/unit/function/lipart.cpp new file mode 100644 index 00000000..c51d7b4e --- /dev/null +++ b/test/unit/function/lipart.cpp @@ -0,0 +1,52 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include + +TTS_CASE_WITH ( "Check kyosu::lipart over real" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10)) + ) +(auto data) +{ + TTS_EQUAL(kyosu::lipart(data), eve::zero(eve::as(data))); +}; + +TTS_CASE_WITH ( "Check kyosu::lipart over complex" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10), tts::randoms(-10,10)) + ) +(auto r, auto i) +{ + TTS_EQUAL(kyosu::lipart(kyosu::complex(r,i)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lipart over quaternion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + ) + ) + (T r, T i, T j, T k) +{ + using type = kyosu::quaternion_t; + TTS_EQUAL(kyosu::lipart(type(r,i,j,k)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lipart over octonion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) ) + ) + (T r, T i, T j, T k, T l, T li, T lj, T lk) +{ + using type = kyosu::octonion_t; + TTS_EQUAL(kyosu::lipart(type(r,i,j,k,l,li,lj,lk)), li ); +}; diff --git a/test/unit/function/ljpart.cpp b/test/unit/function/ljpart.cpp new file mode 100644 index 00000000..fe39d58a --- /dev/null +++ b/test/unit/function/ljpart.cpp @@ -0,0 +1,52 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include + +TTS_CASE_WITH ( "Check kyosu::ljpart over real" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10)) + ) +(auto data) +{ + TTS_EQUAL(kyosu::ljpart(data), eve::zero(eve::as(data))); +}; + +TTS_CASE_WITH ( "Check kyosu::ljpart over complex" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10), tts::randoms(-10,10)) + ) +(auto r, auto i) +{ + TTS_EQUAL(kyosu::ljpart(kyosu::complex(r,i)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::ljpart over quaternion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + ) + ) + (T r, T i, T j, T k) +{ + using type = kyosu::quaternion_t; + TTS_EQUAL(kyosu::ljpart(type(r,i,j,k)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::ljpart over octonion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) ) + ) + (T r, T i, T j, T k, T l, T li, T lj, T lk) +{ + using type = kyosu::octonion_t; + TTS_EQUAL(kyosu::ljpart(type(r,i,j,k,l,li,lj,lk)), lj ); +}; diff --git a/test/unit/function/lkpart.cpp b/test/unit/function/lkpart.cpp new file mode 100644 index 00000000..8c421034 --- /dev/null +++ b/test/unit/function/lkpart.cpp @@ -0,0 +1,52 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include + +TTS_CASE_WITH ( "Check kyosu::lkpart over real" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10)) + ) +(auto data) +{ + TTS_EQUAL(kyosu::lkpart(data), eve::zero(eve::as(data))); +}; + +TTS_CASE_WITH ( "Check kyosu::lkpart over complex" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10), tts::randoms(-10,10)) + ) +(auto r, auto i) +{ + TTS_EQUAL(kyosu::lkpart(kyosu::complex(r,i)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lkpart over quaternion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + ) + ) + (T r, T i, T j, T k) +{ + using type = kyosu::quaternion_t; + TTS_EQUAL(kyosu::lkpart(type(r,i,j,k)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lkpart over octonion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) ) + ) + (T r, T i, T j, T k, T l, T li, T lj, T lk) +{ + using type = kyosu::octonion_t; + TTS_EQUAL(kyosu::lkpart(type(r,i,j,k,l,li,lj,lk)), lk ); +}; diff --git a/test/unit/function/lpart.cpp b/test/unit/function/lpart.cpp new file mode 100644 index 00000000..00533fd7 --- /dev/null +++ b/test/unit/function/lpart.cpp @@ -0,0 +1,52 @@ +//====================================================================================================================== +/* + Kyosu - Complex Without Complexes + Copyright : KYOSU Contributors & Maintainers + SPDX-License-Identifier: BSL-1.0 +*/ +//====================================================================================================================== +#include +#include + +TTS_CASE_WITH ( "Check kyosu::lpart over real" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10)) + ) +(auto data) +{ + TTS_EQUAL(kyosu::lpart(data), eve::zero(eve::as(data))); +}; + +TTS_CASE_WITH ( "Check kyosu::lpart over complex" + , kyosu::real_types + , tts::generate(tts::randoms(-10,10), tts::randoms(-10,10)) + ) +(auto r, auto i) +{ + TTS_EQUAL(kyosu::lpart(kyosu::complex(r,i)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lpart over quaternion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + ) + ) + (T r, T i, T j, T k) +{ + using type = kyosu::quaternion_t; + TTS_EQUAL(kyosu::lpart(type(r,i,j,k)), eve::zero(eve::as(r))); +}; + +TTS_CASE_WITH ( "Check kyosu::lpart over octonion" + , kyosu::real_types + , tts::generate ( tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) + , tts::randoms(-10,10), tts::randoms(-10,10) ) + ) + (T r, T i, T j, T k, T l, T li, T lj, T lk) +{ + using type = kyosu::octonion_t; + TTS_EQUAL(kyosu::lpart(type(r,i,j,k,l,li,lj,lk)), l ); +}; diff --git a/test/unit/function/pow.cpp b/test/unit/function/pow.cpp index 39489095..87a26159 100644 --- a/test/unit/function/pow.cpp +++ b/test/unit/function/pow.cpp @@ -16,7 +16,7 @@ TTS_CASE_WITH ( "Check kyosu::pow over real" ) (auto r0, auto r1) { - TTS_EQUAL(kyosu::pow(r0, r1), eve::pow(r0, r1)); + TTS_RELATIVE_EQUAL(kyosu::pow(r0, r1), kyosu::exp(kyosu::log(r0)*r1), 1.0e-5); TTS_RELATIVE_EQUAL(kyosu::pow(r0, 4), kyosu::sqr(kyosu::sqr(r0)), 1.0e-5); }; diff --git a/test/unit/function/pow_abs.cpp b/test/unit/function/pow_abs.cpp index c7a0a044..71016ed0 100644 --- a/test/unit/function/pow_abs.cpp +++ b/test/unit/function/pow_abs.cpp @@ -32,7 +32,7 @@ TTS_CASE_WITH ( "Check kyosu::pow_abs over complex" 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, r1), eve::exp(r1*kyosu::log_abs(c0)), 2e-4); }; TTS_CASE_WITH ( "Check kyosu::pow_abs over quaternion" diff --git a/test/unit/quaternion/to_cylindrospherical.cpp b/test/unit/quaternion/to_cylindrospherical.cpp new file mode 100644 index 00000000..9e30d77c --- /dev/null +++ b/test/unit/quaternion/to_cylindrospherical.cpp @@ -0,0 +1,41 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright : EVE Project Contributors + SPDX-License-Identifier: BSL-1.0 +**/ +//================================================================================================== +#include "test.hpp" +#include + +TTS_CASE_WITH ( "Check behavior of to_cylindrospherical on wide" + , kyosu::real_types + , tts::generate( tts::randoms(0.5, +1.0) + , tts::randoms(0.5, +1.0) + , tts::randoms(0.5, +1.0) + , tts::randoms(0.5, +1.0) + ) + ) + (T const& a0, T const& a1, T const& a2, T const& a3 ) +{ + { + auto q = kyosu::quaternion(a0, a1, a2, a3); + auto [r1, t1, r2, t2] = kyosu::to_cylindrospherical(q); + auto q1 = kyosu::from_cylindrospherical(r1, t1, r2, t2); + TTS_RELATIVE_EQUAL(q, q1, 1.0e-5); + } + { + auto c = kyosu::complex(a0, a1); + auto [r1, t1, r2, t2] = kyosu::to_cylindrospherical(c); + auto c1 = kyosu::from_cylindrospherical(r1, t1, r2, t2); + TTS_RELATIVE_EQUAL(kyosu::quaternion(c), c1, 1.0e-5); + } + + { + auto [r1, t1, r2, t2] = kyosu::to_cylindrospherical(a0); + auto q1 = kyosu::from_cylindrospherical(r1, t1, r2, t2); + TTS_RELATIVE_EQUAL(kyosu::quaternion(a0), q1, 1.0e-5); + } + + +};