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