| 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 <eve/eve.hpp> | ||
| 11 | #include <polyfloat/details/callable.hpp> | ||
| 12 | #include <polyfloat/types/concepts.hpp> | ||
| 13 | #include <polyfloat/types/traits.hpp> | ||
| 14 | #include <polyfloat/module/core/constants/valmax.hpp> | ||
| 15 | #include <polyfloat/module/core/sqrt.hpp> | ||
| 16 | |||
| 17 | namespace plf | ||
| 18 | { | ||
| 19 | template<typename Options> | ||
| 20 | struct sqrtvalmax_t : plf::constant_callable<sqrtvalmax_t, eve::sqrtvalmax_t, Options, lower_option, upper_option> | ||
| 21 | { | ||
| 22 | 8 | template<typename T> POLYFLOAT_ABI static constexpr T value(eve::as<T> const&, auto const&) | |
| 23 | { | ||
| 24 | using u_t = eve::underlying_type_t<T>; | ||
| 25 | if constexpr (dimension_v<T> == 2) | ||
| 26 | { | ||
| 27 | 2 | if constexpr (sizeof(u_t) == 8) return plf::_::from_pair<u_t>(0x1p+512, -0x1p+405); | |
| 28 | 2 | else return plf::_::from_pair<u_t>(0x1p+64, -0x1p+15); | |
| 29 | } | ||
| 30 | else if constexpr (dimension_v<T> == 3) | ||
| 31 | { | ||
| 32 | 2 | if constexpr (sizeof(u_t) == 8) return plf::_::from_triple<u_t>(0x1p+512, -0x1p+352, -0x1p+191); | |
| 33 | 2 | else return plf::_::from_triple<u_t>(0x1p+64, -0x1p-9, -0x1p-83); | |
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | 8 | template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const | |
| 38 | { | ||
| 39 | 8 | return POLYFLOAT_CALL(v); | |
| 40 | } | ||
| 41 | |||
| 42 | POLYFLOAT_CALLABLE_OBJECT(sqrtvalmax_t, sqrtvalmax_); | ||
| 43 | }; | ||
| 44 | //====================================================================================================================== | ||
| 45 | //! @addtogroup constants | ||
| 46 | //! @{ | ||
| 47 | //! @var sqrtvalmax | ||
| 48 | //! @brief return the sqrt of the maximal representable value. | ||
| 49 | //! | ||
| 50 | //! @groupheader{Header file} | ||
| 51 | //! | ||
| 52 | //! @code | ||
| 53 | //! #include <polyfloat/core.hpp> | ||
| 54 | //! @endcode | ||
| 55 | //! | ||
| 56 | //! @groupheader{Callable Signatures} | ||
| 57 | //! | ||
| 58 | //! @code | ||
| 59 | //! namespace polyfloat | ||
| 60 | //! { | ||
| 61 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto sqrtvalmax(T z) noexcept; | ||
| 62 | //! } | ||
| 63 | //! @endcode | ||
| 64 | //! | ||
| 65 | //! **Parameters** | ||
| 66 | //! | ||
| 67 | //! * `z` : [Type wrapper](@ref eve::as) instance embedding the type of the constant. | ||
| 68 | //! | ||
| 69 | //! **Return value** | ||
| 70 | //! | ||
| 71 | //! Returns the sqrt of the maximal representable value. | ||
| 72 | //! | ||
| 73 | //! @groupheader{Example} | ||
| 74 | //! | ||
| 75 | //! @godbolt{doc/core/sqrtvalmax.cpp} | ||
| 76 | //====================================================================================================================== | ||
| 77 | |||
| 78 | inline constexpr auto sqrtvalmax = eve::functor<sqrtvalmax_t>; | ||
| 79 | //====================================================================================================================== | ||
| 80 | //! @} | ||
| 81 | //====================================================================================================================== | ||
| 82 | } | ||
| 83 |