GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/mul_pi.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 18 18 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
15 namespace plf
16 {
17
18 template<typename Options> struct mul_pi_t : eve::elementwise_callable<mul_pi_t, Options, raw_option, pedantic_option>
19 {
20 780 template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept
21 {
22 780 return POLYFLOAT_CALL(z);
23 }
24
25 780 POLYFLOAT_CALLABLE_OBJECT(mul_pi_t, mul_pi_);
26 };
27 //======================================================================================================================
28 //! @addtogroup math
29 //! @{
30 //! @var mul_pi
31 //!
32 //! @brief `elementwise_callable` object computing accurately the product of the input by \f$\pi\f$.
33 //!
34 //! @groupheader{Callable Signatures}
35 //!
36 //! @code
37 //! #include <eve/module/math.hpp>
38 //! @endcode
39 //!
40 //! @groupheader{Callable Signatures}
41 //!
42 //! @code
43 //! namespace eve
44 //! {
45 //! // Regular overload
46 //! constexpr auto mul_pi(auto x) noexcept; // 1
47 //!
48 //! // Lanes masking
49 //! constexpr auto mul_pi[conditional_expr auto c](auto x) noexcept; // 2
50 //! constexpr auto mul_pi[logical_floating_value auto m](auto x) noexcept; // 2
51 //! }
52 //! @endcode
53 //!
54 //! **Parameters**
55 //!
56 //! * `x`: [floating_value](@ref eve::value).
57 //! * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
58 //! * `m`: [Logical value](@ref eve::logical_value) masking the operation.
59 //!
60 //! **Return value**
61 //!
62 //! 1. Returns the [elementwise](@ref glossary_elementwise) the input divided by 180.
63 //! 2. [The operation is performed conditionally](@ref conditional).
64 //!
65 //! @groupheader{Example}
66 //! @godbolt{doc/math/mul_pi.cpp}
67 //================================================================================================
68 inline constexpr auto mul_pi = eve::functor<mul_pi_t>;
69 //================================================================================================
70 //! @}
71 //================================================================================================
72 }
73
74 namespace plf::_
75 {
76
77 780 template<typename T, eve::callable_options O> constexpr auto mul_pi_(POLYFLOAT_DELAY(), O const&, T a) noexcept
78 {
79 1560 auto [dh, dl] = plf::two_split(plf::pi(eve::as<T>()));
80 780 return plf::fma[plf::is_nez(a)](a, dh, a * dl);
81 }
82 }
83