GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/gd.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 28 28 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 #include <polyfloat/module/math/atan.hpp>
15 #include <polyfloat/module/math/tanh.hpp>
16
17 namespace plf
18 {
19
20 template<typename Options>
21 struct gd_t : plf::elementwise_callable<gd_t, eve::gd_t, Options, raw_option, pedantic_option>
22
23 {
24 28 template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept
25 {
26 28 return POLYFLOAT_CALL(z);
27 }
28
29 18 POLYFLOAT_CALLABLE_OBJECT(gd_t, gd_);
30 };
31 //======================================================================================================================
32 //! @addtogroup math
33 //! @{
34 //! @var gd
35 //! @brief return the gudermanian gd: \f$\int_0^\infty \frac1{\cosh(x)}\; dx\f$.
36 //!
37 //! @groupheader{Header file}
38 //!
39 //! @code
40 //! #include <polyfloat/core.hpp>
41 //! @endcode
42 //!
43 //! @groupheader{Callable Signatures}
44 //!
45 //! @code
46 //! namespace polyfloat
47 //! {
48 //! // Regular overload
49 //! constexpr auto gd(auto auto x) noexcept; // 1
50 //!
51 //! // Lanes masking
52 //! constexpr auto gd[conditional_expr auto c](auto auto x) noexcept; // 2
53 //! constexpr auto gd[logical_value auto m](auto auto x) noexcept; // 2
54 //! }
55 //! @endcode
56 //!
57 //! **Parameters**
58 //!
59 //! * `x`: polyfloat like value.
60 //! * `c`: [Conditional expression](@ref eve::conditional_expr) masking the operation.
61 //! * `m`: [Logical value](@ref eve::logical_value) masking the operation.
62 //!
63 //! **Return value**
64 //!
65 //! 1. Returns the [elementwise](@ref glossary_elementwise) gudermanian of the input.
66 //! In particular:
67 //! * If the element is \f$\pm0\f$, \f$0\f$ is returned.
68 //! * If the element is \f$\pm\infty\f$, \f$\pm\pi/2\f$ is returned.
69 //! * If the element is a `NaN`, `NaN` is returned.
70 //! 2. [The operation is performed conditionally](@ref conditional).
71 //!
72 //! @groupheader{External references}
73 //! * [Wolfram MathWorld: Gudermannian](https://mathworld.wolfram.com/Gudermannian.html)
74 //! * [Wikipedia: Gudermannian function](https://en.wikipedia.org/wiki/Gudermannian_function)
75 //! * [DLMF: gudermannian functions: gudermannian functions](https://dlmf.nist.gov/4.23#viii)
76 //!
77 //! @groupheader{External references}
78 //! * [C++ standard reference](https://en.cppreference.com/w/cpp/numeric/complex/gd)
79 //!
80 //! @godbolt_todo{doc/core/gd.cpp}
81 //======================================================================================================================
82
83 inline constexpr auto gd = eve::functor<gd_t>;
84
85 //======================================================================================================================
86 //! @}
87 //======================================================================================================================
88 }
89
90 namespace plf::_
91 {
92 18 template<typename T, eve::callable_options O> constexpr auto gd_(POLYFLOAT_DELAY(), O const& o, T x) noexcept
93 {
94 18 return 2 * plf::atan[o](plf::tanh[o](x * plf::half(eve::as(x))));
95 }
96 }
97