GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/fnma.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 66 66 100.0%
Branches: 0 0 -%

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