| 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/log.hpp> | ||
| 15 | |||
| 16 | namespace plf | ||
| 17 | { | ||
| 18 | |||
| 19 | template<typename Options> | ||
| 20 | struct acoth_t : plf::elementwise_callable<acoth_t, eve::acoth_t, Options, raw_option, pedantic_option> | ||
| 21 | { | ||
| 22 | 84 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 23 | { | ||
| 24 | 84 | return POLYFLOAT_CALL(z); | |
| 25 | } | ||
| 26 | |||
| 27 | 74 | POLYFLOAT_CALLABLE_OBJECT(acoth_t, acoth_); | |
| 28 | }; | ||
| 29 | //====================================================================================================================== | ||
| 30 | //! @addtogroup math | ||
| 31 | //! @{ | ||
| 32 | //! @var acoth | ||
| 33 | //! @brief return the inverse hyperbolic cotangent value. | ||
| 34 | //! | ||
| 35 | //! @groupheader{Header file} | ||
| 36 | //! | ||
| 37 | //! @code | ||
| 38 | //! #include <polyfloat/core.hpp> | ||
| 39 | //! @endcode | ||
| 40 | //! | ||
| 41 | //! @groupheader{Callable Signatures} | ||
| 42 | //! | ||
| 43 | //! @code | ||
| 44 | //! namespace polyfloat | ||
| 45 | //! { | ||
| 46 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto acoth(T z) noexcept; | ||
| 47 | //! } | ||
| 48 | //! @endcode | ||
| 49 | //! | ||
| 50 | //! **Parameters** | ||
| 51 | //! | ||
| 52 | //! * `z`: Value to process. | ||
| 53 | //! | ||
| 54 | //! **Return value** | ||
| 55 | //! | ||
| 56 | //! Returns the inverse hyperbolic cotangent of z. | ||
| 57 | //! | ||
| 58 | //! @groupheader{Example} | ||
| 59 | //! | ||
| 60 | //! @godbolt{doc/math/acoth.cpp} | ||
| 61 | //====================================================================================================================== | ||
| 62 | |||
| 63 | inline constexpr auto acoth = eve::functor<acoth_t>; | ||
| 64 | //====================================================================================================================== | ||
| 65 | //! @} | ||
| 66 | //====================================================================================================================== | ||
| 67 | } | ||
| 68 | |||
| 69 | namespace plf::_ | ||
| 70 | { | ||
| 71 | |||
| 72 | 74 | template<typename T, eve::callable_options O> constexpr auto acoth_(POLYFLOAT_DELAY(), O const&, T a0) noexcept | |
| 73 | { | ||
| 74 | 74 | auto r = plf::half(eve::as(a0)) * plf::log(plf::inc(a0) / plf::dec(a0)); | |
| 75 | 74 | r = if_else(plf::is_unit(a0), plf::sign(a0) * plf::inf(eve::as(a0)), r); | |
| 76 | 74 | r = if_else(plf::is_infinite(a0), sign(a0) * plf::zero(as(a0)), r); | |
| 77 | 74 | return r; | |
| 78 | } | ||
| 79 | } | ||
| 80 |