GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/constants/pi.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 30 30 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 <eve/module/math/constant/pi.hpp>
14
15 namespace plf
16 {
17 template<typename Options> struct pi_t : plf::constant_callable<pi_t, eve::pi_t, Options, lower_option, upper_option>
18 {
19 23458 template<typename T> POLYFLOAT_ABI static constexpr T value(eve::as<T> const&, auto const&)
20 {
21 using u_t = eve::underlying_type_t<T>;
22
23 if constexpr (plf::dimension_v<T> == 2)
24 {
25 1984 if constexpr (std::same_as<u_t, float>) return plf::_::from_pair<u_t>(0x1.921fb6p+1, -0x1.777a5cp-24);
26 else if constexpr (std::same_as<u_t, double>)
27 1964 return plf::_::from_pair<u_t>(0x1.921fb54442d18p+1, 0x1.1a62633145c07p-53);
28 }
29 else if constexpr (plf::dimension_v<T> == 3)
30 {
31 if constexpr (std::same_as<u_t, float>)
32 9756 return plf::_::from_triple<u_t>(0x1.921fb6p+1, -0x1.777a5cp-24, -0x1.ee59dap-49);
33 else if constexpr (std::same_as<u_t, double>)
34 9754 return plf::_::from_triple<u_t>(0x1.921fb54442d18p+1, 0x1.1a62633145c07p-53, -0x1.f1976b7ed8fbcp-109);
35 }
36 }
37
38 23506 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
39 {
40 23506 return POLYFLOAT_CALL(v);
41 }
42
43 POLYFLOAT_CALLABLE_OBJECT(pi_t, pi_);
44 };
45 //======================================================================================================================
46 //! @addtogroup constants
47 //! @{
48 //! @var pi
49 //! @brief return the pi value.
50 //!
51 //! @groupheader{Header file}
52 //!
53 //! @code
54 //! #include <polyfloat/core.hpp>
55 //! @endcode
56 //!
57 //! @groupheader{Callable Signatures}
58 //!
59 //! @code
60 //! namespace polyfloat
61 //! {
62 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto pi(T z) noexcept;
63 //! }
64 //! @endcode
65 //!
66 //! **Parameters**
67 //!
68 //! * `z`: Value to process.
69 //!
70 //! **Return value**
71 //!
72 //! Returns the pi value of z.
73 //!
74 //! @groupheader{Example}
75 //!
76 //! @godbolt_todo{doc/pi.cpp}
77 //======================================================================================================================
78
79 inline constexpr auto pi = eve::functor<pi_t>;
80 //======================================================================================================================
81 //! @}
82 //======================================================================================================================
83 }
84