GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/asin.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 36 36 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/atan2.hpp>
15
16 namespace plf
17 {
18
19 template<typename Options>
20 struct asin_t : plf::elementwise_callable<asin_t,
21 eve::asin_t,
22 Options,
23 raw_option,
24 pedantic_option,
25 eve::rad_option,
26 eve::radpi_option,
27 eve::deg_option>
28 {
29 1680 template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept
30 {
31 1680 return POLYFLOAT_CALL(z);
32 }
33
34 1670 POLYFLOAT_CALLABLE_OBJECT(asin_t, asin_);
35 };
36 //======================================================================================================================
37 //! @addtogroup math
38 //! @{
39 //! @var asin
40 //! @brief return the arcsine 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 asin(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 sine of the
64 //! input in the range \f$[-\frac\pi2, \frac\pi2]\f$.
65 //! In particular:
66 //! * If the element is \f$\pm0\f$, \f$\pm0\f$ is returned unmodified.
67 //! * If the element \f$|x| > 1\f$, `NaN` is returned.
68 //! * If the element is a `NaN`, `NaN` is returned.
69 //!
70 //! @groupheader{Example}
71 //!
72 //! @godbolt{doc/math/asin.cpp}
73 //======================================================================================================================
74
75 inline constexpr auto asin = eve::functor<asin_t>;
76 //======================================================================================================================
77 //! @}
78 //======================================================================================================================
79 }
80
81 namespace plf::_
82 {
83 1670 template<typename T, eve::callable_options O> constexpr auto asin_(POLYFLOAT_DELAY(), O const& o, T a0) noexcept
84 {
85 1670 return plf::atan2[o](a0, plf::sqrt(oneminus(plf::sqr(a0))));
86 }
87
88 constexpr auto asind = plf::asin[eve::deg];
89 constexpr auto asinpi = plf::asin[eve::radpi];
90 }
91