| 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/atanh.hpp> | ||
| 15 | #include <polyfloat/module/math/tan.hpp> | ||
| 16 | |||
| 17 | namespace plf | ||
| 18 | { | ||
| 19 | |||
| 20 | template<typename Options> | ||
| 21 | struct agd_t : plf::elementwise_callable<agd_t, eve::agd_t, Options, raw_option, pedantic_option> | ||
| 22 | |||
| 23 | { | ||
| 24 | 854 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 25 | { | ||
| 26 | 854 | return POLYFLOAT_CALL(z); | |
| 27 | } | ||
| 28 | |||
| 29 | 844 | POLYFLOAT_CALLABLE_OBJECT(agd_t, agd_); | |
| 30 | }; | ||
| 31 | //====================================================================================================================== | ||
| 32 | //! @addtogroup math | ||
| 33 | //! @{ | ||
| 34 | //! @var agd | ||
| 35 | //! @brief return the inverse gudermannian agd : \f$2\tanh(\tan(x/2))\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 agd(auto auto x) noexcept; // 1 | ||
| 50 | //! | ||
| 51 | //! // Lanes masking | ||
| 52 | //! constexpr auto agd[conditional_expr auto c](auto auto x) noexcept; // 2 | ||
| 53 | //! constexpr auto agd[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) inverse | ||
| 66 | //! [gudermannian](@ref plf::gd) of the input for x angle in the superior half circle. | ||
| 67 | //! In particular: | ||
| 68 | //! * If the element is \f$\pm0\f$, \f$0\f$ is returned. | ||
| 69 | //! * If the element is \f$\pm\pi/2\f$, \f$\infty\f$ is returned. | ||
| 70 | //! * If the element is not in \f$[-\pi/2, \pi/2] \f$, `NaN` is returned. | ||
| 71 | //! 2. [The operation is performed conditionally](@ref conditional). | ||
| 72 | //! | ||
| 73 | //! @groupheader{External references} | ||
| 74 | //! * [Wolfram MathWorld: Inverse Gudermannian](https://mathworld.wolfram.com/InverseGudermannian.html) | ||
| 75 | //! * [Wikipedia: Gudermannian function](https://en.wikipedia.org/wiki/Gudermannian_function) | ||
| 76 | //! * [DLMF: gudermannian functions](https://dlmf.nist.gov/4.23#viii) | ||
| 77 | //! | ||
| 78 | //! | ||
| 79 | //! @groupheader{Example} | ||
| 80 | //! | ||
| 81 | //! @groupheader{External references} | ||
| 82 | //! * [C++ standard reference](https://en.cppreference.com/w/cpp/numeric/complex/agd) | ||
| 83 | //! | ||
| 84 | //! @godbolt_todo{doc/core/agd.cpp} | ||
| 85 | //====================================================================================================================== | ||
| 86 | |||
| 87 | inline constexpr auto agd = eve::functor<agd_t>; | ||
| 88 | |||
| 89 | //====================================================================================================================== | ||
| 90 | //! @} | ||
| 91 | //====================================================================================================================== | ||
| 92 | } | ||
| 93 | |||
| 94 | namespace plf::_ | ||
| 95 | { | ||
| 96 | 844 | template<typename T, eve::callable_options O> constexpr auto agd_(POLYFLOAT_DELAY(), O const& o, T x) noexcept | |
| 97 | { | ||
| 98 | 844 | return 2 * plf::atanh[o](plf::tan[o][eve::quarter_circle](x * plf::half(eve::as(x)))); | |
| 99 | } | ||
| 100 | |||
| 101 | } | ||
| 102 |