From f994b4544039ae785162c50386eca7b8b51b8a44 Mon Sep 17 00:00:00 2001 From: jtlap Date: Fri, 5 Jul 2024 22:03:47 +0200 Subject: [PATCH 1/5] ns core --- include/eve/module/core/regular/ceil.hpp | 2 +- include/eve/module/core/regular/nb_values.hpp | 18 ++++-- include/eve/module/core/regular/nearest.hpp | 43 +++++++------- include/eve/module/core/regular/negabsmax.hpp | 58 ++++++++++--------- include/eve/module/core/regular/negabsmin.hpp | 54 ++++++++--------- include/eve/module/core/regular/negate.hpp | 31 +++++----- include/eve/module/core/regular/negatenz.hpp | 31 +++++----- include/eve/module/core/regular/negmaxabs.hpp | 51 ++++++++-------- include/eve/module/core/regular/negminabs.hpp | 50 ++++++++-------- include/eve/module/core/regular/next.hpp | 50 +++++++--------- include/eve/module/core/regular/nextafter.hpp | 42 ++++++-------- include/eve/module/core/regular/none.hpp | 2 +- 12 files changed, 213 insertions(+), 219 deletions(-) diff --git a/include/eve/module/core/regular/ceil.hpp b/include/eve/module/core/regular/ceil.hpp index 65ee344284..b32d26d593 100644 --- a/include/eve/module/core/regular/ceil.hpp +++ b/include/eve/module/core/regular/ceil.hpp @@ -37,7 +37,7 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var ceil -//! @brief `elementwise_callable` object computing the smallest integer not less than the input. +//! @brief `strict_elementwise_callable` object computing the smallest integer not less than the input. //! //! **Defined in Header** //! diff --git a/include/eve/module/core/regular/nb_values.hpp b/include/eve/module/core/regular/nb_values.hpp index 948308b0c6..ccbc36ae7e 100644 --- a/include/eve/module/core/regular/nb_values.hpp +++ b/include/eve/module/core/regular/nb_values.hpp @@ -33,7 +33,7 @@ namespace eve //! @addtogroup core_internal //! @{ //! @var nb_values -//! @brief Computes the number of values representable in the type between the +//! @brief `elementwise_callable` object computing the number of values representable in the type between the //! [arguments](@ref eve::value). //! //! **Defined in Header** @@ -47,21 +47,27 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value U > -//! as_integer_t, unsigned> nb_values(T x, T y) noexcept; +//! // Regular overloads +//! constexpr auto nb_values(eve::value auto x, eve::value auto y) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto nb_values[conditional_expr auto c](eve::value auto x, eve::value auto y) noexcept; // 2 +//! constexpr auto nb_values[logical_value auto m](eve::value auto x, eve::value auto y) noexcept; // 2 //! } //! @endcode //! //! **Parameters** //! -//! * `x`, `y`: [arguments](@ref eve::value). +//! * `x`, `y`: [values](@ref value). +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! Returns the number of values representable in the type in the interval `[x, y[` +//! 1. Returns the number of values representable in the type in the interval `[x, y[` +//! 2. [The operation is performed conditionnaly](@ref conditional). //! //! @groupheader{Example} -//! //! @godbolt{doc/core/nb_values.cpp} //================================================================================================ inline constexpr auto nb_values = functor; diff --git a/include/eve/module/core/regular/nearest.hpp b/include/eve/module/core/regular/nearest.hpp index aeb3a3abb5..182c6162cd 100644 --- a/include/eve/module/core/regular/nearest.hpp +++ b/include/eve/module/core/regular/nearest.hpp @@ -35,9 +35,9 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var nearest -//! @brief Computes the nearest integer to the input. +//! @brief `strict_elementwise_callable` object computing the nearest integer to the input. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -48,36 +48,33 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T > -//! T nearest(T x) noexcept; +//! // Regular overload +//! constexpr auto nearest(value auto x) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto nearest[conditional_expr auto c](value auto x) noexcept; // 2 +//! constexpr auto nearest[logical_value auto m](value auto x) noexcept; // 2 //! } //! @endcode //! -//! **Parameters** -//! -//! * `x` : [real](@ref eve::value) argument. -//! -//! **Return value** +//! * `x` :[value](@ref value) argument. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. +//! * `tol' [scalar_value](@ref value) tolerance. //! -//! Computes [elementwise](@ref glossary_elementwise) the integer nearest to `x`. +//! **Return value** //! -//! If `x` is an exact half-integer the rounding is made to the nearest even integer. -//! -//! The standard proposes 4 rounding modes namely: `FE_TONEAREST`, `FE_DOWNWARD`, `FE_UPWARD`, -//! `FE_TOWARDZERO`. This function object implements the `FE_TONEAREST` version. +//! 1. the integer nearest to `x`. If `x` is an exact half-integer the rounding is made to the +//! nearest even integer.The smallest integer not less than `x`. +//! The standard proposes 4 rounding modes namely: `FE_TONEAREST`, `FE_DOWNWARD`, `FE_UPWARD`, +//! `FE_TOWARDZERO`. This function object implements the `FE_TONEAREST` version. +//! 2. [The operation is performed conditionnaly](@ref conditional). //! +//! @groupheader{External references} +//! * [C++ standard reference](https://en.cppreference.com/w/cpp/numeric/math/round) //! //! @groupheader{Example} -//! //! @godbolt{doc/core/nearest.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve;::nearest[mask](x)` provides a masked version of `eve::nearest` which is -//! equivalent to `if_else (mask, nearest(x), x)`. -//! //! @} //================================================================================================ inline constexpr auto nearest = functor; diff --git a/include/eve/module/core/regular/negabsmax.hpp b/include/eve/module/core/regular/negabsmax.hpp index 9d2bea0f60..0f997fe40a 100644 --- a/include/eve/module/core/regular/negabsmax.hpp +++ b/include/eve/module/core/regular/negabsmax.hpp @@ -33,15 +33,14 @@ namespace eve EVE_CALLABLE_OBJECT(negabsmax_t, negabsmax_); }; + //================================================================================================ //! @addtogroup core_arithmetic //! @{ //! @var negabsmax -//! @brief Computes the negated absolute value of the maximal element -//! -//! This is equivalent to -eve::abs ( eve::max(...) ). but can be subject to optimizations. +//! @brief `tuple_callable` computing the absolute value of the maximal element. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -52,43 +51,46 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value... Ts> -//! eve::common_value_t negabsmax( T x, Ts ... xs ) noexcept; +//! // Regular overloads +//! constexpr auto negabsmax(eve::value auto x, eve::value auto ... xs) noexcept; // 1 +//! constexpr auto negabsmax(kumi::non_empty_product_type auto const& tup) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto negabsmax[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto negabsmax[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Semantic option +//! constexpr auto negabsmax[saturated](/* any of the above overloads */) noexcept; // 4 +//! +//! // Exclusive Semantic options - Only one of those can be set at once +//! constexpr auto negabsmax[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto negabsmax[numeric ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! +//! //! **Parameters** //! -//! * `x`, `...xs`: [arguments](@ref eve::value). +//! * `x`, `...xs`: [real](@ref value) arguments. +//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of arguments. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The negated absolute value of the maximal element -//! is returned. -//! -//! @note -//! If any element of the inputs is a NaN, -//! the corresponding output element is system-dependent. +//! The negated absolute value of the maximal element is returned. +//! 1. If any element of the inputs is a NaN the corresponding output element is system-dependent +//! 2. equivalent to the call on the elements of the tuple. +//! 3. [The operation is performed conditionnaly](@ref conditional) +//! 4. computation internally uses `abs[saturated]` instead of `abs` +//! 5. with `numeric` (resp. `pedantic`) `max[numeric]` (5.1) (resp. `max[pedantic]` (5.2)) +//! is used internally //! //! @groupheader{Example} -//! //! @godbolt{doc/core/negabsmax.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negabsmax[mask](x, ...)` provides a masked version of `eve::negabsmax` which -//! is equivalent to `eve::if_else (mask, negabsmax(x, ...), x)` -//! -//! * eve::pedantic, eve::numeric -//! -//! The call `d(eve::negabsmax)(...)`, where d is one of these two decorators, is equivalent to -//! `-eve::abs (d( eve::max )(...))`. -//! //! @} //================================================================================================ -inline constexpr auto negabsmax = functor; + inline constexpr auto negabsmax = functor; } #include diff --git a/include/eve/module/core/regular/negabsmin.hpp b/include/eve/module/core/regular/negabsmin.hpp index 56d6e9f579..957c5537b9 100644 --- a/include/eve/module/core/regular/negabsmin.hpp +++ b/include/eve/module/core/regular/negabsmin.hpp @@ -37,11 +37,9 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var negabsmin -//! @brief Computes the negated absolute value of the minimal element +//! @brief `tuple_callable` computing the absolute value of the minimal element. //! -//! This is equivalent to -eve::abs ( eve::min(...) ). but can be subject to optimizations. -//! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -52,43 +50,47 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value... Ts> -//! eve::common_value_t negabsmin( T x, Ts ... xs ) noexcept; +//! // Regular overloads +//! constexpr auto negabsmin(eve::value auto x, eve::value auto ... xs) noexcept; // 1 +//! constexpr auto negabsmin(kumi::non_empty_product_type auto const& tup) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto negabsmin[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto negabsmin[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Semantic options +//! constexpr auto negabsmin[saturated](/* any of the above overloads */) noexcept; // 4 +//! +//! // Exclusive Semantic options - Only one of those can be set at once +//! constexpr auto negabsmin[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto negabsmin[numeric ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! //! **Parameters** //! -//! * `x`, `...xs`: [arguments](@ref eve::value). +//! * `x`, `...xs`: [real](@ref value) arguments. +//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of arguments. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The negated absolute value of the minimal element -//! is returned. -//! -//! @note -//! If any element of the inputs is a NaN, -//! the corresponding output element is system-dependent. +//! The negated absolute value of the minimal element is returned. +//! 1. If any element of the inputs is a NaN the corresponding output element is system-dependent +//! 2. equivalent to the call on the elements of the tuple. +//! 3. [The operation is performed conditionnaly](@ref conditional) +//! 4. computation internally uses `abs[saturated]` instead of `abs` +//! 5. with `numeric` (resp. `pedantic`) `min[numeric]` (5.1) (resp. `min[pedantic]` (5.2)) +//! is used internally //! //! @groupheader{Example} //! //! @godbolt{doc/core/negabsmin.cpp} //! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negabsmin[mask](x, ...)` provides a masked version of `eve::negabsmin` which -//! is equivalent to `eve::if_else (mask, negabsmin(x, ...), x)` -//! -//! * eve::pedantic, eve::numeric -//! -//! The call `d(eve::negabsmin)(...)`, where d is one of these two decorators, is equivalent to -//! `-eve::abs (d( eve::min )(...))`. -//! //! @} //================================================================================================ -inline constexpr auto negabsmin = functor; + inline constexpr auto negabsmin = functor; } #include diff --git a/include/eve/module/core/regular/negate.hpp b/include/eve/module/core/regular/negate.hpp index 4c51eb068b..ba76adeef8 100644 --- a/include/eve/module/core/regular/negate.hpp +++ b/include/eve/module/core/regular/negate.hpp @@ -14,7 +14,7 @@ namespace eve { template - struct negate_t : elementwise_callable + struct negate_t : elementwise_callable { template requires(eve::same_lanes_or_scalar) @@ -28,10 +28,10 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var negate -//! @brief Computes the [elementwise](@ref glossary_elementwise) product of the first parameter +//! @brief `elementwise_callable` object computing the product of the first parameter //! by the sign of the second. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -42,31 +42,30 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value U > -//! eve::common_value_t negate(T x, U y) noexcept; +//! // Regular overload +//! constexpr auto negate(value auto x, value auto y) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto negate[conditional_expr auto c](value auto x, value auto y) noexcept; // 2 +//! constexpr auto negate[logical_value auto m](value auto , value auto yx) noexcept; // 2 //! } //! @endcode //! //! **Parameters** //! //! * `x`, `y`: [arguments](@ref eve::value). +//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of arguments. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The [elementwise](@ref glossary_elementwise) product of the first parameter -//! by the sign of the second is returned. +//! 1. The [elementwise](@ref glossary_elementwise) product of the first parameter +//! by the sign of the second is returned. +//! 2. [The operation is performed conditionnaly](@ref conditional) //! //! @groupheader{Example} -//! //! @godbolt{doc/core/negate.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negate[mask](x, ...)` provides a masked -//! version of `negate` which is equivalent to `if_else(mask, negate(x, ...), x)` -//! //! @} //================================================================================================ inline constexpr auto negate = functor; diff --git a/include/eve/module/core/regular/negatenz.hpp b/include/eve/module/core/regular/negatenz.hpp index 1b7557ef55..957d2b690c 100644 --- a/include/eve/module/core/regular/negatenz.hpp +++ b/include/eve/module/core/regular/negatenz.hpp @@ -16,7 +16,7 @@ namespace eve { template - struct negatenz_t : elementwise_callable + struct negatenz_t : elementwise_callable { template requires(eve::same_lanes_or_scalar) @@ -30,10 +30,10 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var negatenz -//! @brief Computes the [elementwise](@ref glossary_elementwise) product of the first parameter +//! @brief `elementwise_callable` object computing the product of the first parameter //! by the never zero sign of the second. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -44,32 +44,29 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value U > -//! eve::common_value_t negatenz(T x, U y) noexcept; +//! // Regular overload +//! constexpr auto negatenz(value auto x, value auto y) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto negatenz[conditional_expr auto c](value auto x, value auto y) noexcept; // 2 +//! constexpr auto negatenz[logical_value auto m](value auto , value auto yx) noexcept; // 2 //! } //! @endcode //! //! **Parameters** //! //! * `x`, `y`: [arguments](@ref eve::value). +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The [elementwise](@ref glossary_elementwise) product of the first parameter -//! by the never zero sign of the second is returned. +//! 1. The [elementwise](@ref glossary_elementwise) product of the first parameter +//! by the never zero sign of the second is returned. +//! 2. [The operation is performed conditionnaly](@ref conditional) //! //! @groupheader{Example} -//! //! @godbolt{doc/core/negatenz.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negatenz[mask](x, ...)` provides a masked -//! version of `negatenz` which is -//! equivalent to `if_else(mask, negatenz(x, ...), x)` -//! //! @} //================================================================================================ inline constexpr auto negatenz = functor; diff --git a/include/eve/module/core/regular/negmaxabs.hpp b/include/eve/module/core/regular/negmaxabs.hpp index b9bdc9144d..4a657d1d31 100644 --- a/include/eve/module/core/regular/negmaxabs.hpp +++ b/include/eve/module/core/regular/negmaxabs.hpp @@ -36,9 +36,9 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var negmaxabs -//! @brief Computes the negated value of the element of the maximal absolute value. +//! @brief `tuple_callable` object computing the negated value of the element of maximal absolute value. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -49,40 +49,41 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value... Ts> -//! eve::common_value_t negmaxabs( T x, Ts ... xs ) noexcept; +//! // Regular overloads +//! constexpr auto negmaxabs(eve::value auto x, eve::value auto ... xs) noexcept; // 1 +//! constexpr auto negmaxabs(kumi::non_empty_product_type auto const& tup) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto negmaxabs[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto negmaxabs[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Semantic option +//! constexpr auto negmaxabs[saturated](/* any of the above overloads */) noexcept; // 4 +//! +//! // Exclusive Semantic options - Only one of those can be set at once +//! constexpr auto negmaxabs[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto negmaxabs[numeric ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! //! **Parameters** //! //! * `x`, `...xs`: [arguments](@ref eve::value). +//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of arguments. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The negated negated value of the element of the maximal absolute value -//! is returned. -//! -//! @note -//! If any element of the inputs is a NaN, -//! the corresponding output element is system-dependent. -//! +//! The negated value of the element of maximal absolute value is returned. +//! 1. If any element of the inputs is a NaN the corresponding output element is system-dependent +//! 2. equivalent to the call on the elements of the tuple. +//! 3. [The operation is performed conditionnaly](@ref conditional) +//! 4. computation internally uses `abs[saturated]` instead of `abs` +//! 5. with `numeric` (resp. `pedantic`) `max[numeric]` (5.1) (resp. `max[pedantic]` (5.2)) +//! is used internally //! @groupheader{Example} -//! //! @godbolt{doc/core/negmaxabs.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negmaxabs[mask](x, ...)` provides a masked version of `eve::negmaxabs` which -//! is equivalent to `eve::if_else (mask, negmaxabs(x, ...), x)` -//! -//! * eve::pedantic, eve::numeric -//! -//! The call `d(eve::negmaxabs)(...)`, where d is one of these two decorators has the -//! same behaviour, but internally `d(eve::max)` is used. -//! //! @} //================================================================================================ inline constexpr auto negmaxabs = functor; diff --git a/include/eve/module/core/regular/negminabs.hpp b/include/eve/module/core/regular/negminabs.hpp index 429b562aac..6e615ef05b 100644 --- a/include/eve/module/core/regular/negminabs.hpp +++ b/include/eve/module/core/regular/negminabs.hpp @@ -35,9 +35,9 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var negminabs -//! @brief Computes the negated value of the element of the minimal absolute value. +//! @brief `tuple_callable` computing the negated value of the element of minimal absolute value. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -48,40 +48,42 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value... Ts> -//! eve::common_value_t negminabs( T x, Ts ... xs ) noexcept; +//! // Regular overloads +//! constexpr auto negminabs(eve::value auto x, eve::value auto ... xs) noexcept; // 1 +//! constexpr auto negminabs(kumi::non_empty_product_type auto const& tup) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto negminabs[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto negminabs[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Semantic option +//! constexpr auto negminabs[saturated](/* any of the above overloads */) noexcept; // 4 +//! +//! // Exclusive Semantic options - Only one of those can be set at once +//! constexpr auto negminabs[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto negminabs[numeric ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! //! **Parameters** //! //! * `x`, `...xs`: [arguments](@ref eve::value). +//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of arguments. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The negated negated value of the element of the minimal absolute value -//! is returned. -//! -//! @note -//! If any element of the inputs is a NaN, -//! the corresponding output element is system-dependent. +//! The negated value of the element of minimal absolute value is returned. +//! 1. If any element of the inputs is a NaN the corresponding output element is system-dependent +//! 2. equivalent to the call on the elements of the tuple. +//! 3. [The operation is performed conditionnaly](@ref conditional) +//! 4. computation internally uses `abs[saturated]` instead of `abs` +//! 5. with `numeric` (resp. `pedantic`) `max[numeric]` (5.1) (resp. `max[pedantic]` (5.2)) +//! is used internally //! //! @groupheader{Example} -//! //! @godbolt{doc/core/negminabs.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::negminabs[mask](x, ...)` provides a masked version of `eve::negminabs` which -//! is equivalent to `eve::if_else (mask, negminabs(x, ...), x)` -//! -//! * eve::pedantic, eve::numeric -//! -//! The call `d(eve::negminabs)(...)`, where d is one of these two decorators has the -//! same behaviour, but internally `d(eve::min)` is used. -//! //! @} //================================================================================================ inline constexpr auto negminabs = functor; diff --git a/include/eve/module/core/regular/next.hpp b/include/eve/module/core/regular/next.hpp index bf949609f2..60851ef4cf 100644 --- a/include/eve/module/core/regular/next.hpp +++ b/include/eve/module/core/regular/next.hpp @@ -46,9 +46,9 @@ namespace eve //! @addtogroup core_internal //! @{ //! @var next -//! @brief Computes the nth next representable element +//! @brief `strict_elementwise_callable` computing the nth next representable element //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -59,45 +59,37 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::integral_value N > -//! eve::common_value_t next(T x, N n = 1) noexcept; +//! // Regular overloads +//! constexpr auto next(value auto x) noexcept; noexcept; // 1 +//! constexpr auto next(value auto x, integral_value auto n) noexcept; noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto next[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto next[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Exclusive Semantic options - Only one of those can be set at once +//! constexpr auto negmaxabs[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto negmaxabs[saturated ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! //! **Parameters** //! //! * `x`: [floating argument](@ref eve::floating_value). -//! //! * `n` : [integral value argument](@ref eve::integral_value). -//! +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. +///! //! **Return value** //! -//! The value of the nth representable value greater than `x` is returned. -//! If `n` is zero returns `x`. +//! 1. the least representable value greater than `x` is returned. +//! 2. the nth representable value greater than `x` is returned. If `n` is zero returns `x`. +//! 3. [The operation is performed conditionnaly](@ref conditional) +//! 4. if `x` is floating the call with mzero returns zero +//! 5. ensures that the input is never greater than the result of the call. //! //! @groupheader{Example} -//! //! @godbolt{doc/core/next.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::next[mask](x, ...)` provides a masked -//! version of `next` which is -//! equivalent to `if_else(mask, next(x, ...), x)` -//! -//! * eve::pedantic -//! -//! The call `eve::next[eve::pedantic](x, ...)` provides a pedantic -//! version of `next` which ensures that the successor of eve::mzero is eve::zero -//! for floating points entries -//! -//! * eve::saturated -//! -//! The call `eve::next[eve::saturated](x, ...)` provides a saturated -//! version of `next` which ensures that x is never less than the result of the call. -//! //! @} //================================================================================================ inline constexpr auto next = functor; diff --git a/include/eve/module/core/regular/nextafter.hpp b/include/eve/module/core/regular/nextafter.hpp index 0a5e988f52..5fac5971d2 100644 --- a/include/eve/module/core/regular/nextafter.hpp +++ b/include/eve/module/core/regular/nextafter.hpp @@ -31,9 +31,10 @@ namespace eve //! @addtogroup core_internal //! @{ //! @var nextafter -//! @brief Computes the nth next representable element +//! @brief `elementwise_callable` object computing the next representable element element in +//! the second parameter direction. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -44,38 +45,33 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T, eve::value U > -//! eve::common_value_t nextafter(T x, U y) noexcept; +//! // Regular overloads +//! constexpr auto nextafter(eve::value auto x, eve::value auto ... xs) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto nextafter[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 +//! constexpr auto nextafter[logical_value auto m](/* any of the above overloads */) noexcept; // 3 +//! +//! // Semantic options +//! constexpr auto nextafter[pedantic](/* any of the above overloads */) noexcept; // 4 //! } //! @endcode //! //! **Parameters** //! -//! * `x`, `y`: [arguments](@ref eve::value). +//! * `x`, `y`: [arguments](@ref eve::value). +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The value of the next representable value greater than `x` in the `y` direction -//! is returned. -//! If `y == x` returns `x`. +//! 1. the next representable value after `x` in the `y` direction is returned. +//! If `y == x` returns `x`. +//! 2. [The operation is performed conditionnaly](@ref conditional) +//! 3. Provides a version of `nextafter` for which floating plus zero and minus zero are distinct. //! //! @groupheader{Example} -//! //! @godbolt{doc/core/nextafter.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * pedantic Call -//! -//! The call `eve::nextafter[pedantic](x, ...)` provides a -//! version of `nextafter` for which floating plus zero and minus zero are distinct -//! -//! * Masked Call -//! -//! The call `eve::nextafter[mask](x, ...)` provides a masked -//! version of `nextafter` which is -//! equivalent to `if_else(mask, nextafter(x, ...), x)` -//! //! @} //================================================================================================ inline constexpr auto nextafter = functor; diff --git a/include/eve/module/core/regular/none.hpp b/include/eve/module/core/regular/none.hpp index 0de1984e80..5d056496f6 100644 --- a/include/eve/module/core/regular/none.hpp +++ b/include/eve/module/core/regular/none.hpp @@ -18,7 +18,7 @@ namespace eve //! @var none //! @brief Computes a bool value which is true if and only if all elements of `x` are 0. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include From b4dff9f2579077aa4eef88b80cf3b93b3b4c6b5f Mon Sep 17 00:00:00 2001 From: jtlap Date: Sat, 6 Jul 2024 10:05:58 +0200 Subject: [PATCH 2/5] newton+horner --- include/eve/module/math/regular/horner.hpp | 33 ++++++------ include/eve/module/math/regular/newton.hpp | 60 +++++++++++----------- 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/include/eve/module/math/regular/horner.hpp b/include/eve/module/math/regular/horner.hpp index ad102c1293..0ed1e48146 100644 --- a/include/eve/module/math/regular/horner.hpp +++ b/include/eve/module/math/regular/horner.hpp @@ -38,6 +38,12 @@ namespace eve //! @var horner //! @brief Implement the horner scheme to evaluate polynomials //! +//! +//! If \f$(c_i)_{0\le i\le n-1}\f$ denotes the coefficients of the polynomial by decreasing +//! power order, the Horner scheme evaluates the polynom \f$p\f$ at \f$x\f$ by : +//! +//! \f$\qquad\displaystyle p(x) = (((c_0x+c_1)x+ ... )x + c_{n-1})\f$ +//! //! @groupheader{Header file} //! //! @code @@ -50,37 +56,32 @@ namespace eve //! namespace eve //! { //! // Regular overloads -//! constexpr auto horner(value auto x, value auto ... cs) noexcept; // 1 -//! constexpr auto horner(value auto x, kumi::non_empty_product_type auto tup) noexcept; // 2 +//! constexpr auto horner(value auto x, value auto ... ci) noexcept; // 1 +//! constexpr auto horner(value auto x, kumi::non_empty_product_type auto tci) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto horner[conditional_expr auto c](*any of the above overloads*/) noexcept; // 2 +//! constexpr auto horner[logical_value auto m](*any of the above overloads*/) noexcept; // 2 //! //! // Semantic options -//! constexpr auto horner[pedantic](/*any of the above overloads*/) noexcept; // 3 +//! constexpr auto horner[pedantic](/*any of the above overloads*/) noexcept; // 4 //! } //! @endcode //! -//! 1. Polynom is evaluated at x the other inputs are the polynomial coefficients. -//! 2. Polynom is evaluated at x the other input is a range or a kumi::tuple containing the coefficients -//! //! **Parameters** //! //! * `x`: [evaluation point floating value](@ref floating_value) arguments. -//! * `...cs`: [floating values](@ref floating_value) polynom coefficients in decreasing power order, -//! * `tup`: [non empty tuple](@ref kumi::non_empty_product_type) of floating values. +//! * `...ci`: [floating values](@ref floating_value) polynom coefficients in decreasing power order, +//! * `tci`: [non empty tuple](@ref kumi::non_empty_product_type) of floating values. //! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. //! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! If \f$(a_i)_{0\le i\le n-1}\f$ denotes the coefficients of the polynomial by decreasing -//! power order, the Horner scheme evaluates the polynom \f$p\f$ at \f$x\f$ by : -//! \f$\displaystyle p(x) = (((a_0x+a_1)x+ ... )x + a_{n-1})\f$ -//! -//! //! 1. The value of the polynom at `x` is returned. //! 2. same as the call with the elements of the tuple. -//! 3.`fma[pedantic]` instead of `fma` is used in internal computations. -//! This is intended to insure more accurate computations where needed. This has no cost (and is -//! automatically done) if the system has hard wired `fma` but is very expansive if it is not the case. +//! 3. [The operation is performed conditionnaly](@ref conditional). +//! 4. `fma[pedantic]` instead of `fma` is used in internal computations. //! //! @note If the coefficients are simd values of cardinal N, this means you simultaneously //! compute the values of N polynomials. diff --git a/include/eve/module/math/regular/newton.hpp b/include/eve/module/math/regular/newton.hpp index 243618789d..25d7ef36b2 100644 --- a/include/eve/module/math/regular/newton.hpp +++ b/include/eve/module/math/regular/newton.hpp @@ -39,13 +39,13 @@ namespace eve //! @var newton //! @brief Implement the Newton scheme to evaluate polynomials. //! -//! If \f$(a_i)_{0\le i\le n-1}\f$ denotes the coefficients of the polynomial by decreasing -//! power order, and \f$(c_i)_{0\le i\le n-2}\f$ the nodes, the Newton scheme evaluates +//! If \f$(c_i)_{0\le i\le n-1}\f$ denotes the coefficients of the polynomial by decreasing +//! power order, and \f$(m_i)_{0\le i\le n-2}\f$ the nodes, the Newton scheme evaluates //! the polynom \f$p\f$ at \f$x\f$ using the following formula : //! -//! \f$ \displaystyle p(x) = (((a_0(x-c_0)+a_1)(x-c_1)+ ... )(x-c_{n-2}) + a_{n-1})\f$ +//! \f$\qquad\displaystyle p(x) = (((c_0(x-m_0)+c_1)(x-m_1)+ ... )(x-m_{n-2}) + c_{n-1})\f$ //! -//! **Defined in header** +//! @groupheader{Header file} //! //! @code //! #include @@ -56,47 +56,45 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::floating_ordered_value T, kumi::tuple C, kumi::tuple N> -//! T newton(T x, C c, N n) noexcept; //1 -//! template< eve::floating_ordered_value T, value... CN> -//! T newton(T x, CN.. cn) noexcept; //2 - +//! // Regular overloads +//! constexpr auto horner(value auto x, value auto ... cmi) noexcept; // 1 +//! constexpr auto horner(value auto x, kumi::non_empty_product_type auto ci +//! kumi::non_empty_product_type auto mi) noexcept; // 2 +//! +//! // Lanes masking +//! constexpr auto newton[conditional_expr auto c](*any of the above overloads*/) noexcept; // 2 +//! constexpr auto newton[logical_value auto m](*any of the above overloads*/) noexcept; // 2 +//! +//! // Semantic options +//! constexpr auto horner[pedantic](/*any of the above overloads*/) noexcept; // 2 //! } //! @endcode //! //! **Parameters** //! -//! * `x` : [real floating argument](@ref eve::floating_ordered_value). -//! * `c` : tuple containing The coefficients by decreasing power order. -//! * `n` : tuple containing The nodes by decreasing power order. -//! * `cn`: coefficients followed by nodes. Unless empty the total number of values -//! is to be odd. If s is this number, the (s+1)/2 first are taken as the coefs -//! and the others are the nodes, both in decreasing power order -//! **Return value** +//! * `x`: [real floating argument](@ref eve::floating_ordered_value). +//! * `ci`: tuple containing the coefficients by decreasing power order. +//! * `cm`: tuple containing the nodes by decreasing power order. +//! * `cmi...`: all the coefficients followed by all the nodes, both in decreasing power order. +//! The total number of values is to be odd. If s is this number, the (s+1)/2 first +//! are taken as the coefs and the others are the nodes +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! -//! The value of the polynom at `x` is returned. +//! **Return value** //! -//! **Notes** +//! 1. The value of the polynom at `x` is returned. +//! 2. same as the call with the elements of the tuples. +//! 3. [The operation is performed conditionnaly](@ref conditional). +//! 4. `fma[pedantic]` instead of `fma` is used in internal computations. //! -//! If the coefficients or nodes are simd values of cardinal N, this means you simultaneously +//! @note If the coefficients or nodes are simd values of cardinal N, this means you simultaneously //! compute the values of N polynomials. //! * If x is scalar, the polynomials are all computed at the same point //! * If x is simd, the nth polynomial is computed on the nth value of x //! //! @groupheader{Example} -//! //! @godbolt{doc/math/newton.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * eve::pedantic -//! -//! the expression `eve::newton[pedantic](...)` -//! computes the result using `eve::fma[pedantic]` instead of `eve::fma` in -//! internal computation. -//! -//! This is intended to insure more accurate computations where needed. This has no cost (and is -//! automatically done) if the system has hard wired fma but is very expansive if it is not the case. //! @} //================================================================================================ inline constexpr auto newton = functor; From 4b67cf1a8707f2ec039fab69df2304938da7c66d Mon Sep 17 00:00:00 2001 From: jtlap Date: Sat, 6 Jul 2024 10:22:16 +0200 Subject: [PATCH 3/5] next nth_root --- include/eve/module/core/regular/next.hpp | 4 +-- include/eve/module/math/regular/nthroot.hpp | 29 +++++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/eve/module/core/regular/next.hpp b/include/eve/module/core/regular/next.hpp index 60851ef4cf..8df8ab25ad 100644 --- a/include/eve/module/core/regular/next.hpp +++ b/include/eve/module/core/regular/next.hpp @@ -68,8 +68,8 @@ namespace eve //! constexpr auto next[logical_value auto m](/* any of the above overloads */) noexcept; // 3 //! //! // Exclusive Semantic options - Only one of those can be set at once -//! constexpr auto negmaxabs[pedantic](/* any of the above overloads */) noexcept; // 5.1 -//! constexpr auto negmaxabs[saturated ](/* any of the above overloads */) noexcept; // 5.2 +//! constexpr auto next[pedantic](/* any of the above overloads */) noexcept; // 5.1 +//! constexpr auto next[saturated ](/* any of the above overloads */) noexcept; // 5.2 //! } //! @endcode //! diff --git a/include/eve/module/math/regular/nthroot.hpp b/include/eve/module/math/regular/nthroot.hpp index 9cb8345eda..306c3a8427 100644 --- a/include/eve/module/math/regular/nthroot.hpp +++ b/include/eve/module/math/regular/nthroot.hpp @@ -36,7 +36,7 @@ namespace eve //! //! @brief Callable object computing the nth root: \f$x^{1/n}\f$. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -47,24 +47,31 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::floating_value T, eve::floating_value U > -//! T nthroot(T x, U y) noexcept; +//! // Regular overload +//! constexpr auto nthroot(floating_value auto x, value auto n) noexcept; noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto nthroot[conditional_expr auto c](/* any of the above overloads */) noexcept; // 2 +//! constexpr auto nthroot[logical_value auto m](/* any of the above overloads */) noexcept; // 2 +//! +//! // Semantic options +//! constexpr auto nthroot[raw](/* any of the above overloads */) noexcept; // 3 //! } //! @endcode //! //! **Parameters** //! -//! * `x`: [floating real value](@ref eve::floating_ordered_value). -//! -//! * `n`: [integral_value](@ref eve::integral_value). Actually `n` can be a [flint](@ref -//! eve::is_flint). +//! * `x`: [floating value](@ref eve::floating_value). +//! * `n`: [integral_value](@ref eve::integral_value). Actually `n` can be a [flint](@ref is_flint). +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! Returns [elementwise](@ref glossary_elementwise) the value of \f$x^{1/n}\f$. -//! For negative `x` the value returned is a Nan as soon as `n` is not an odd integer. -//! -//! The result type is of the compatibility type of the parameters. +//! 1. Returns the value of \f$x^{1/n}\f$. For negative `x` the value returned is a Nan as soon as `n` +//! is not an odd integer. +//! 2. [The operation is performed conditionnaly](@ref conditional) +//! 3. Speedier but less accurate computation. //! //! @groupheader{Example} //! From f27c85f416e819be75929ee1c6feff701540b0f5 Mon Sep 17 00:00:00 2001 From: jtlap Date: Sat, 6 Jul 2024 15:13:18 +0200 Subject: [PATCH 4/5] next oneminus --- include/eve/module/core/regular/next.hpp | 10 +++--- include/eve/module/core/regular/oneminus.hpp | 38 +++++++++----------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/include/eve/module/core/regular/next.hpp b/include/eve/module/core/regular/next.hpp index 8df8ab25ad..6d32ce1239 100644 --- a/include/eve/module/core/regular/next.hpp +++ b/include/eve/module/core/regular/next.hpp @@ -60,8 +60,8 @@ namespace eve //! namespace eve //! { //! // Regular overloads -//! constexpr auto next(value auto x) noexcept; noexcept; // 1 -//! constexpr auto next(value auto x, integral_value auto n) noexcept; noexcept; // 2 +//! constexpr auto next(value auto x) noexcept; // 1 +//! constexpr auto next(value auto x, integral_value auto n) noexcept; // 2 //! //! // Lanes masking //! constexpr auto next[conditional_expr auto c](/* any of the above overloads */) noexcept; // 3 @@ -75,11 +75,11 @@ namespace eve //! //! **Parameters** //! -//! * `x`: [floating argument](@ref eve::floating_value). -//! * `n` : [integral value argument](@ref eve::integral_value). +//! * `x`: [floating argument](@ref eve::floating_value). +//! * `n`: [integral value argument](@ref eve::integral_value). //! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. //! * `m`: [Logical value](@ref logical) masking the operation. -///! +//! //! **Return value** //! //! 1. the least representable value greater than `x` is returned. diff --git a/include/eve/module/core/regular/oneminus.hpp b/include/eve/module/core/regular/oneminus.hpp index cc2ac1a793..8f7e122edc 100644 --- a/include/eve/module/core/regular/oneminus.hpp +++ b/include/eve/module/core/regular/oneminus.hpp @@ -31,9 +31,9 @@ namespace eve //! @addtogroup core_arithmetic //! @{ //! @var oneminus -//! @brief Computes the value of one minus the input. +//! @brief `elementwise_callable` computing the value of one minus the input. //! -//! **Defined in Header** +//! @groupheader{Header file} //! //! @code //! #include @@ -44,18 +44,29 @@ namespace eve //! @code //! namespace eve //! { -//! template< eve::value T > -//! T oneminus(T x) noexcept; +//! // Regular overloads +//! constexpr auto oneminus(value auto x) noexcept; // 1 +//! +//! // Lanes masking +//! constexpr auto oneminus[conditional_expr auto c](/* any of the above overloads */) noexcept; // 2 +//! constexpr auto oneminus[logical_value auto m](/* any of the above overloads */) noexcept; // 2 +//! +//! // Semantic option +//! constexpr auto oneminus[saturated ](/* any of the above overloads */) noexcept; // 3 //! } //! @endcode //! //! **Parameters** //! -//! * `x` : [real](@ref eve::value) argument. +//! * `x`: [real](@ref eve::value) argument. +//! * `c`: [Conditional expression](@ref conditional_expr) masking the operation. +//! * `m`: [Logical value](@ref logical) masking the operation. //! //! **Return value** //! -//! The value of `1-x` is returned. +//! 1. The value of `1-x` is returned. +//! 2. [The operation is performed conditionnaly](@ref conditional). +//! 3. saturated version. //! //! @note //! If an [element](@ref glossary_elementwise) of the expected result is not representable in @@ -63,22 +74,7 @@ namespace eve //! undefined. //! //! @groupheader{Example} -//! //! @godbolt{doc/core/oneminus.cpp} -//! -//! @groupheader{Semantic Modifiers} -//! -//! * Masked Call -//! -//! The call `eve::oneminus[mask](x, ...)` provides a masked -//! version of `oneminus` which is -//! equivalent to `if_else(mask, oneminus(x, ...), x)` -//! -//! * eve::saturated -//! -//! The call `saturated(oneminus)(x)` is semantically equivalent to `eve::saturated(eve::sub)( -//! eve::one (as(x)), x)` and is never undefined. -//! //! @} //================================================================================================ inline constexpr auto oneminus = functor; From d6a23afd3fd1391e514f74b5df2f2c387e0fb4d0 Mon Sep 17 00:00:00 2001 From: jtlap Date: Sun, 7 Jul 2024 09:34:47 +0200 Subject: [PATCH 5/5] newton --- include/eve/module/math/regular/newton.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/eve/module/math/regular/newton.hpp b/include/eve/module/math/regular/newton.hpp index 25d7ef36b2..6416afa60a 100644 --- a/include/eve/module/math/regular/newton.hpp +++ b/include/eve/module/math/regular/newton.hpp @@ -57,8 +57,8 @@ namespace eve //! namespace eve //! { //! // Regular overloads -//! constexpr auto horner(value auto x, value auto ... cmi) noexcept; // 1 -//! constexpr auto horner(value auto x, kumi::non_empty_product_type auto ci +//! constexpr auto newton(value auto x, value auto ... cmi) noexcept; // 1 +//! constexpr auto newton(value auto x, kumi::non_empty_product_type auto ci //! kumi::non_empty_product_type auto mi) noexcept; // 2 //! //! // Lanes masking @@ -66,7 +66,7 @@ namespace eve //! constexpr auto newton[logical_value auto m](*any of the above overloads*/) noexcept; // 2 //! //! // Semantic options -//! constexpr auto horner[pedantic](/*any of the above overloads*/) noexcept; // 2 +//! constexpr auto newton[pedantic](/*any of the above overloads*/) noexcept; // 2 //! } //! @endcode //!