| 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 | |||
| 15 | namespace plf | ||
| 16 | { | ||
| 17 | |||
| 18 | template<typename Options> struct fsm_t : eve::strict_tuple_callable<fsm_t, Options, raw_option, pedantic_option> | ||
| 19 | { | ||
| 20 | template<typename... Ts> struct result : as_polyfloat_like<Ts...> | ||
| 21 | { | ||
| 22 | }; | ||
| 23 | |||
| 24 | template<concepts::polyfloat_like Z0, concepts::polyfloat_like Z1, concepts::polyfloat_like Z2> | ||
| 25 | 8 | POLYFLOAT_ABI typename result<Z0, Z1, Z2>::type constexpr operator()(Z0 z0, Z1 z1, Z2 z2) const noexcept | |
| 26 | { | ||
| 27 | 8 | return POLYFLOAT_CALL(z0, z1, z2); | |
| 28 | } | ||
| 29 | |||
| 30 | 8 | POLYFLOAT_CALLABLE_OBJECT(fsm_t, fsm_); | |
| 31 | }; | ||
| 32 | //====================================================================================================================== | ||
| 33 | //! @addtogroup core | ||
| 34 | //! @{ | ||
| 35 | //! @var fsm | ||
| 36 | //! @brief return the fused asubtract multiply of the parameters. | ||
| 37 | //! | ||
| 38 | //! @groupheader{Header file} | ||
| 39 | //! | ||
| 40 | //! @code | ||
| 41 | //! #include <polyfloat/core.hpp> | ||
| 42 | //! @endcode | ||
| 43 | //! | ||
| 44 | //! @groupheader{Callable Signatures} | ||
| 45 | //! | ||
| 46 | //! @code | ||
| 47 | //! namespace polyfloat | ||
| 48 | //! { | ||
| 49 | //! template<polyfloat::concepts::polyfloat_like Z1, polyfloat_like Z2, polyfloat_like Z3> constexpr auto fsm(Z1 z1, Z2 z2, Z3 z3) noexcept; | ||
| 50 | //! } | ||
| 51 | //! @endcode | ||
| 52 | //! | ||
| 53 | //! **Parameters** | ||
| 54 | //! | ||
| 55 | //! * `z1`, `z2`, `z3`: Values to process. | ||
| 56 | //! | ||
| 57 | //! **Return value** | ||
| 58 | //! | ||
| 59 | //! Returns the fused subtract multiply of the arguments. | ||
| 60 | //! | ||
| 61 | //! @note contrarily to `eve::fsm`, `plf::fsm` garanties the correct fused multiply add rounding behaviour, even if it has to be emulated. | ||
| 62 | //! | ||
| 63 | //! @groupheader{Example} | ||
| 64 | //! | ||
| 65 | //! @godbolt_todo{doc/core/fsm.cpp} | ||
| 66 | //====================================================================================================================== | ||
| 67 | |||
| 68 | inline constexpr auto fsm = eve::functor<fsm_t>; | ||
| 69 | //====================================================================================================================== | ||
| 70 | //! @} | ||
| 71 | //====================================================================================================================== | ||
| 72 | } | ||
| 73 | |||
| 74 | namespace plf::_ | ||
| 75 | { | ||
| 76 | template<typename Z1, typename Z2, typename Z3, eve::callable_options O> | ||
| 77 | 8 | constexpr auto fsm_(POLYFLOAT_DELAY(), O const&, Z1 const& x, Z2 const& y, Z3 const& z) noexcept | |
| 78 | { | ||
| 79 | 8 | return plf::fma(y, z, -x); | |
| 80 | } | ||
| 81 | } | ||
| 82 |