| 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/core/minus.hpp> | ||
| 15 | #include <polyfloat/module/core/is_negative.hpp> | ||
| 16 | #include <polyfloat/module/math/exp.hpp> | ||
| 17 | |||
| 18 | namespace plf | ||
| 19 | { | ||
| 20 | |||
| 21 | template<typename Options> | ||
| 22 | struct log1p_t : plf::elementwise_callable<log1p_t, eve::log1p_t, Options, raw_option, pedantic_option> | ||
| 23 | { | ||
| 24 | 94 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 25 | { | ||
| 26 | 94 | return POLYFLOAT_CALL(z); | |
| 27 | } | ||
| 28 | |||
| 29 | 84 | POLYFLOAT_CALLABLE_OBJECT(log1p_t, log1p_); | |
| 30 | }; | ||
| 31 | //====================================================================================================================== | ||
| 32 | //! @addtogroup math | ||
| 33 | //! @{ | ||
| 34 | //! @var log1p | ||
| 35 | //! @brief return the natural logarithm value of one plus the argument. | ||
| 36 | //! | ||
| 37 | //! @groupheader{Header file} | ||
| 38 | //! | ||
| 39 | //! @code | ||
| 40 | //! #include <polyfloat/core.hpp> | ||
| 41 | //! @endcode | ||
| 42 | //! | ||
| 43 | //! @groupheader{Callable Signatures} | ||
| 44 | //! | ||
| 45 | //! @code | ||
| 46 | //! namespace polyfloat | ||
| 47 | //! { | ||
| 48 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto log1p(T z) noexcept; | ||
| 49 | //! } | ||
| 50 | //! @endcode | ||
| 51 | //! | ||
| 52 | //! **Parameters** | ||
| 53 | //! | ||
| 54 | //! * `z`: Value to process. | ||
| 55 | //! | ||
| 56 | //! **Return value** | ||
| 57 | //! | ||
| 58 | //! Returns the expolute,natural log1parithm of of 1+z. | ||
| 59 | //! | ||
| 60 | //! @groupheader{Example} | ||
| 61 | //! | ||
| 62 | //! @godbolt{doc/math/log1p.cpp} | ||
| 63 | //====================================================================================================================== | ||
| 64 | |||
| 65 | inline constexpr auto log1p = eve::functor<log1p_t>; | ||
| 66 | //====================================================================================================================== | ||
| 67 | //! @} | ||
| 68 | //====================================================================================================================== | ||
| 69 | } | ||
| 70 | |||
| 71 | namespace plf::_ | ||
| 72 | { | ||
| 73 | |||
| 74 | 84 | template<typename T, eve::callable_options O> constexpr auto log1p_(POLYFLOAT_DELAY(), O const&, T x) noexcept | |
| 75 | { | ||
| 76 | 84 | return plf::log(inc(x)); | |
| 77 | // this seems to be good to use in eve TO DO | ||
| 78 | // auto [incx, e] = plf::two_add(plf::one(eve::as(x)), x); | ||
| 79 | // auto r = plf::log(incx); | ||
| 80 | // if constexpr(O::contains(eve::raw)) | ||
| 81 | // return r; | ||
| 82 | // else | ||
| 83 | // { | ||
| 84 | // return plf::if_else(plf::is_eqz(r), e, r); | ||
| 85 | // } | ||
| 86 | } | ||
| 87 | } | ||
| 88 |