| 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 <eve/module/math/constant/log_2.hpp> | ||
| 14 | |||
| 15 | namespace plf | ||
| 16 | { | ||
| 17 | |||
| 18 | template<typename Options> | ||
| 19 | struct log_2_t : plf::constant_callable<log_2_t, eve::log_2_t, Options, lower_option, upper_option> | ||
| 20 | { | ||
| 21 | 316 | template<typename T> POLYFLOAT_ABI static constexpr T value(eve::as<T> const&, auto const&) | |
| 22 | { | ||
| 23 | using u_t = plf::as_component_type_t<T>; | ||
| 24 | if constexpr (plf::dimension_v<T> == 2) | ||
| 25 | { | ||
| 26 | 84 | if constexpr (std::same_as<u_t, float>) return plf::_::from_pair<float>(0x1.62e43p-1, -0x1.05c61p-29); | |
| 27 | else if constexpr (std::same_as<u_t, double>) | ||
| 28 | 78 | return plf::_::from_pair<double>(0x1.62e42fefa39efp-1, 0x1.abc9e3b39803fp-56); | |
| 29 | } | ||
| 30 | else if constexpr (plf::dimension_v<T> == 3) | ||
| 31 | { | ||
| 32 | if constexpr (std::same_as<u_t, float>) | ||
| 33 | 78 | return plf::_::from_triple<float>(0x1.62e43p-1, -0x1.05c61p-29, -0x1.950d88p-54); | |
| 34 | else if constexpr (std::same_as<u_t, double>) | ||
| 35 | 76 | return plf::_::from_triple<double>(0x1.62e42fefa39efp-1, 0x1.abc9e3b39803fp-56, 0x1.7b57a079a1934p-111); | |
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | 316 | template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const | |
| 40 | { | ||
| 41 | 316 | return POLYFLOAT_CALL(v); | |
| 42 | } | ||
| 43 | |||
| 44 | POLYFLOAT_CALLABLE_OBJECT(log_2_t, log_2_); | ||
| 45 | }; | ||
| 46 | //====================================================================================================================== | ||
| 47 | //! @addtogroup constants | ||
| 48 | //! @{ | ||
| 49 | //! @var log_2 | ||
| 50 | //! @brief return the log(2) value. | ||
| 51 | //! | ||
| 52 | //! @groupheader{Header file} | ||
| 53 | //! | ||
| 54 | //! @code | ||
| 55 | //! #include <polyfloat/core.hpp> | ||
| 56 | //! @endcode | ||
| 57 | //! | ||
| 58 | //! @groupheader{Callable Signatures} | ||
| 59 | //! | ||
| 60 | //! @code | ||
| 61 | //! namespace polyfloat | ||
| 62 | //! { | ||
| 63 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto log_2(T z) noexcept; | ||
| 64 | //! } | ||
| 65 | //! @endcode | ||
| 66 | //! | ||
| 67 | //! | ||
| 68 | //! **Return value** | ||
| 69 | //! | ||
| 70 | //! Returns log(2). | ||
| 71 | //! | ||
| 72 | //! @groupheader{Example} | ||
| 73 | //! | ||
| 74 | //! @godbolt_todo{doc/log_2.cpp} | ||
| 75 | //====================================================================================================================== | ||
| 76 | |||
| 77 | inline constexpr auto log_2 = eve::functor<log_2_t>; | ||
| 78 | //====================================================================================================================== | ||
| 79 | //! @} | ||
| 80 | //====================================================================================================================== | ||
| 81 | } | ||
| 82 |