| 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/atan2.hpp> | ||
| 15 | |||
| 16 | namespace plf | ||
| 17 | { | ||
| 18 | |||
| 19 | template<typename Options> | ||
| 20 | struct acos_t : plf::elementwise_callable<acos_t, | ||
| 21 | eve::acos_t, | ||
| 22 | Options, | ||
| 23 | raw_option, | ||
| 24 | pedantic_option, | ||
| 25 | eve::rad_option, | ||
| 26 | eve::radpi_option, | ||
| 27 | eve::deg_option> | ||
| 28 | { | ||
| 29 | 1684 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 30 | { | ||
| 31 | 1684 | return POLYFLOAT_CALL(z); | |
| 32 | } | ||
| 33 | |||
| 34 | 1674 | POLYFLOAT_CALLABLE_OBJECT(acos_t, acos_); | |
| 35 | }; | ||
| 36 | //====================================================================================================================== | ||
| 37 | //! @addtogroup math | ||
| 38 | //! @{ | ||
| 39 | //! @var acos | ||
| 40 | //! @brief return the arc cosine value. | ||
| 41 | //! | ||
| 42 | //! @groupheader{Header file} | ||
| 43 | //! | ||
| 44 | //! @code | ||
| 45 | //! #include <polyfloat/core.hpp> | ||
| 46 | //! @endcode | ||
| 47 | //! | ||
| 48 | //! @groupheader{Callable Signatures} | ||
| 49 | //! | ||
| 50 | //! @code | ||
| 51 | //! namespace polyfloat | ||
| 52 | //! { | ||
| 53 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto acos(T z) noexcept; | ||
| 54 | //! } | ||
| 55 | //! @endcode | ||
| 56 | //! | ||
| 57 | //! **Parameters** | ||
| 58 | //! | ||
| 59 | //! * `z`: Value to process. | ||
| 60 | //! | ||
| 61 | //! **Return value** | ||
| 62 | //! | ||
| 63 | //! Returns the [elementwise](@ref glossary_elementwise) arc cosine in radians of the | ||
| 64 | //! input in the range \f$[0 , \pi]\f$. | ||
| 65 | //! In particular: | ||
| 66 | //! * If `x` is \f$1\f$, \f$+0\f$ is returned. | ||
| 67 | //! * If \f$|x| > 1\f$, `NaN` is returned. | ||
| 68 | //! * If `x` is a `NaN`, `NaN` is returned. | ||
| 69 | //! | ||
| 70 | //! @groupheader{Example} | ||
| 71 | //! | ||
| 72 | //! @godbolt{doc/math/acos.cpp} | ||
| 73 | //====================================================================================================================== | ||
| 74 | |||
| 75 | inline constexpr auto acos = eve::functor<acos_t>; | ||
| 76 | //====================================================================================================================== | ||
| 77 | //! @} | ||
| 78 | //====================================================================================================================== | ||
| 79 | } | ||
| 80 | |||
| 81 | namespace plf::_ | ||
| 82 | { | ||
| 83 | 1674 | template<typename T, eve::callable_options O> constexpr auto acos_(POLYFLOAT_DELAY(), O const& o, T a0) noexcept | |
| 84 | { | ||
| 85 | 1674 | return plf::atan2[o](plf::sqrt(oneminus(plf::sqr(a0))), a0); | |
| 86 | } | ||
| 87 | |||
| 88 | constexpr auto acosd = plf::acos[eve::deg]; | ||
| 89 | constexpr auto acospi = plf::acos[eve::radpi]; | ||
| 90 | } | ||
| 91 |