GCC Code Coverage Report


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