GCC Code Coverage Report


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