GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/radindeg.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 radindeg_t : plf::elementwise_callable<radindeg_t, eve::radindeg_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(radindeg_t, radindeg_);
27 };
28 //======================================================================================================================
29 //! @addtogroup math
30 //! @{
31 //! @var radindeg
32 //! @brief `elementwise_callable` object multiplying the input by \f$180/\pi\f$.
33 //!
34 //! @groupheader{Header file}
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 radindeg(auto x) noexcept; // 1
47 //!
48 //! // Lanes masking
49 //! constexpr auto radindeg[conditional_expr auto c](auto x) noexcept; // 2
50 //! constexpr auto radindeg[logical_value auto m](auto x) noexcept; // 2
51 //! }
52 //! @endcode
53 //!
54 //! **Parameters**
55 //!
56 //! * `x`: [floating value](@ref eve::floating_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 radian input converted in degree.
63 //! 2. [The operation is performed conditionally](@ref conditional).
64 //!
65 //! @groupheader{Example}
66 //! @godbolt{doc/math/radindeg.cpp}
67 //================================================================================================
68 inline constexpr auto radindeg = eve::functor<radindeg_t>;
69 //================================================================================================
70 //! @}
71 //================================================================================================
72 }
73
74 namespace plf::_
75 {
76
77 16 template<typename T, eve::callable_options O> constexpr auto radindeg_(POLYFLOAT_DELAY(), O const&, T a) noexcept
78 {
79 32 auto [r2dh, r2dl] = plf::two_split(plf::rad2deg(eve::as<T>()));
80 16 return plf::fma(a, r2dh, a * r2dl);
81 }
82 }
83