| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //====================================================================================================================== | ||
| 2 | /* | ||
| 3 | POLYFLOAT - Extended precision floating points | ||
| 4 | Copyright : POLYFLOAT Contributors & Maintainers | ||
| 5 | SPDX-License-Identifier: BSL-1.0 | ||
| 6 | */ | ||
| 7 | //====================================================================================================================== | ||
| 8 | #pragma once | ||
| 9 | |||
| 10 | #include <polyfloat/details/callable.hpp> | ||
| 11 | #include <polyfloat/types/concepts.hpp> | ||
| 12 | #include <polyfloat/types/traits.hpp> | ||
| 13 | #include <type_traits> | ||
| 14 | #include <polyfloat/module/core/abs.hpp> | ||
| 15 | #include <polyfloat/module/core/max.hpp> | ||
| 16 | |||
| 17 | namespace plf | ||
| 18 | { | ||
| 19 | |||
| 20 | template<typename Options> | ||
| 21 | struct negabsmin_t : eve::strict_tuple_callable<negabsmin_t, Options, raw_option, pedantic_option> | ||
| 22 | { | ||
| 23 | template<typename... Ts> struct result : as_polyfloat_like<Ts...> | ||
| 24 | { | ||
| 25 | }; | ||
| 26 | |||
| 27 | template<concepts::polyfloat_like... Ts> | ||
| 28 | requires(eve::same_lanes_or_scalar<Ts...>) | ||
| 29 | 48 | POLYFLOAT_ABI typename result<Ts...>::type constexpr operator()(Ts... ts) const noexcept | |
| 30 | { | ||
| 31 | 48 | return POLYFLOAT_CALL(ts...); | |
| 32 | } | ||
| 33 | |||
| 34 | template<eve::non_empty_product_type Tup> | ||
| 35 | requires(eve::same_lanes_or_scalar_tuple<Tup> && !concepts::polyfloat_like<Tup>) | ||
| 36 | POLYFLOAT_ABI constexpr kumi::apply_traits_t<result, Tup> operator()(Tup const& t) const noexcept | ||
| 37 | requires(kumi::size_v<Tup> >= 1) | ||
| 38 | { | ||
| 39 | return POLYFLOAT_CALL(t); | ||
| 40 | } | ||
| 41 | |||
| 42 | 48 | POLYFLOAT_CALLABLE_OBJECT(negabsmin_t, negabsmin_); | |
| 43 | }; | ||
| 44 | //====================================================================================================================== | ||
| 45 | //! @addtogroup core | ||
| 46 | //! @{ | ||
| 47 | //! @var negabsmin | ||
| 48 | //! @brief return the opposite of the absolute value of the minimum of the parameters. | ||
| 49 | //! | ||
| 50 | //! @groupheader{Header file} | ||
| 51 | //! | ||
| 52 | //! @code | ||
| 53 | //! #include <polyfloat/core.hpp> | ||
| 54 | //! @endcode | ||
| 55 | //! | ||
| 56 | //! @groupheader{Callable Signatures} | ||
| 57 | //! | ||
| 58 | //! @code | ||
| 59 | //! namespace polyfloat | ||
| 60 | //! { | ||
| 61 | //! template<polyfloat::concepts::polyfloat_like Z1, polyfloat_like Z2> constexpr auto negabsmin(Z1 z1, Z2 z2) noexcept; | ||
| 62 | //! } | ||
| 63 | //! @endcode | ||
| 64 | //! | ||
| 65 | //! **Parameters** | ||
| 66 | //! | ||
| 67 | //! * `z1`, `z2`: Values to process. | ||
| 68 | //! | ||
| 69 | //! **Return value** | ||
| 70 | //! | ||
| 71 | //! Returns the opposite of the absolute value of the minimum of the arguments. | ||
| 72 | //! | ||
| 73 | //! @groupheader{Example} | ||
| 74 | //! | ||
| 75 | //! @godbolt_todo{doc/core/negabsmin.cpp} | ||
| 76 | //====================================================================================================================== | ||
| 77 | |||
| 78 | inline constexpr auto negabsmin = eve::functor<negabsmin_t>; | ||
| 79 | //====================================================================================================================== | ||
| 80 | //! @} | ||
| 81 | //====================================================================================================================== | ||
| 82 | } | ||
| 83 | |||
| 84 | namespace plf::_ | ||
| 85 | { | ||
| 86 | |||
| 87 | template<eve::callable_options O, concepts::polyfloat_like T0, concepts::polyfloat_like... Ts> | ||
| 88 | 48 | constexpr auto negabsmin_(POLYFLOAT_DELAY(), O const& o, T0 const& t0, Ts const&... ts) noexcept | |
| 89 | { | ||
| 90 | 48 | return -plf::abs[o.drop(pedantic, numeric)](plf::min(t0, ts...)); | |
| 91 | } | ||
| 92 | |||
| 93 | } | ||
| 94 |