| 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/is_equal.hpp> | ||
| 15 | #include <polyfloat/module/core/abs.hpp> | ||
| 16 | |||
| 17 | namespace plf | ||
| 18 | { | ||
| 19 | |||
| 20 | template<typename Options> | ||
| 21 | struct is_unit_t : eve::elementwise_callable<is_unit_t, Options, raw_option, pedantic_option> | ||
| 22 | { | ||
| 23 | template<concepts::polyfloat_like Z> | ||
| 24 | 1632 | POLYFLOAT_ABI constexpr eve::as_logical_t<plf::as_component_type_t<Z>> operator()(Z z) const noexcept | |
| 25 | { | ||
| 26 | 1632 | return POLYFLOAT_CALL(z); | |
| 27 | } | ||
| 28 | |||
| 29 | 1632 | POLYFLOAT_CALLABLE_OBJECT(is_unit_t, is_unit_); | |
| 30 | }; | ||
| 31 | //====================================================================================================================== | ||
| 32 | //! @addtogroup core | ||
| 33 | //! @{ | ||
| 34 | //! @var is_unit | ||
| 35 | //! @brief test the parameter for equality to is\f$\pm1\f$. | ||
| 36 | //! | ||
| 37 | //! @groupheader{Header file} | ||
| 38 | //! | ||
| 39 | //! @code | ||
| 40 | //! #include <polyfloat/core.hpp> | ||
| 41 | //! @endcode | ||
| 42 | //! | ||
| 43 | //! @groupheader{Callable Signatures} | ||
| 44 | //! | ||
| 45 | //! @code | ||
| 46 | //! namespace polyfloat | ||
| 47 | //! { | ||
| 48 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto is_unit(T z) noexcept; | ||
| 49 | //! } | ||
| 50 | //! @endcode | ||
| 51 | //! | ||
| 52 | //! **Parameters** | ||
| 53 | //! | ||
| 54 | //! * `z`: Value to process. | ||
| 55 | //! | ||
| 56 | //! **Return value** | ||
| 57 | //! | ||
| 58 | //! Returns true iff z is\f$\pm1\f$. | ||
| 59 | //! | ||
| 60 | //! @groupheader{Example} | ||
| 61 | //! | ||
| 62 | //! @godbolt{doc/core/is_unit.cpp} | ||
| 63 | //====================================================================================================================== | ||
| 64 | |||
| 65 | inline constexpr auto is_unit = eve::functor<is_unit_t>; | ||
| 66 | //====================================================================================================================== | ||
| 67 | //! @} | ||
| 68 | //====================================================================================================================== | ||
| 69 | } | ||
| 70 | |||
| 71 | namespace plf::_ | ||
| 72 | { | ||
| 73 | template<typename Z, eve::callable_options O> | ||
| 74 | 1632 | constexpr auto is_unit_(POLYFLOAT_DELAY(), O const&, Z const& z) noexcept | |
| 75 | { | ||
| 76 | 1632 | return plf::is_equal(plf::abs(z), Z(1)); | |
| 77 | } | ||
| 78 | } | ||
| 79 |