GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/constants/egamma.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 10 10 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
14 namespace plf
15 {
16 template<typename Options>
17 struct egamma_t : plf::constant_callable<egamma_t, eve::egamma_t, Options, lower_option, upper_option>
18 {
19 16 template<typename T> POLYFLOAT_ABI static constexpr auto 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 if constexpr (std::same_as<u_t, float>)
26 4 return plf::_::from_pair<u_t>(0x1.2788d00000000p-1, -0x1.c824f40000000p-28);
27 else if constexpr (std::same_as<u_t, double>)
28 4 return plf::_::from_pair<u_t>(0x1.2788cfc6fb619p-1, -0x1.6cb90701fbfabp-58);
29 }
30 else if constexpr (plf::dimension_v<T> == 3)
31 {
32 if constexpr (std::same_as<u_t, float>)
33 4 return plf::_::from_triple<u_t>(0x1.2788d00000000p-1, -0x1.c824f40000000p-28, 0x1.e934700000000p-54);
34 else if constexpr (std::same_as<u_t, double>)
35 4 return plf::_::from_triple<u_t>(0x1.2788cfc6fb619p-1, -0x1.6cb90701fbfabp-58, -0x1.34a95e3133c51p-112);
36 }
37 }
38
39 24 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
40 {
41 24 return POLYFLOAT_CALL(v);
42 }
43
44 POLYFLOAT_CALLABLE_OBJECT(egamma_t, egamma_);
45 };
46 //======================================================================================================================
47 //! @addtogroup constants
48 //! @{
49 //! @var egamma
50 //! @brief Callable object computing the Euler-Mascheroni constant : \f$\gamma =
51 //! \lim_{n\to\infty}\left( \sum_{k = 0}^n \frac1k - \log n\right )\f$.
52 //!
53 //! @groupheader{Header file}
54 //!
55 //! @code
56 //! #include <polyfloat/core.hpp>
57 //! @endcode
58 //!
59 //! @groupheader{Callable Signatures}
60 //!
61 //! @code
62 //! namespace polyfloat
63 //! {
64 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto egamma(T z) noexcept;
65 //! }
66 //! @endcode
67 //!
68 //! **Parameters**
69 //!
70 //! * `z`: Value to process.
71 //!
72 //! **Return value**
73 //!
74 //! The call `eve::egamma(as<T>())` returns \f$\gamma =
75 //! \lim_{n\to\infty}\left( \sum_{k = 0}^n \frac1k - \log n\right )\f$. γ is an alias.
76 //!
77 //! @groupheader{Example}
78 //!
79 //! @godbolt{doc/math/egamma.cpp}
80 //======================================================================================================================
81
82 inline constexpr auto egamma = eve::functor<egamma_t>;
83 inline constexpr auto γ = eve::functor<egamma_t>;
84 //======================================================================================================================
85 //! @}
86 //======================================================================================================================
87 }
88