E.V.E
v2022.03.00

◆ log1p

eve::log1p = {}
inlineconstexpr

Callable object computing the natural logarithm of \(1+x\): \(\log(1+x)\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T >
T log1p(T x) noexcept; //1
template< eve::floating_value T >
}
constexpr callable_log1p_ log1p
Callable object computing the natural logarithm of : .
Definition: log1p.hpp:81
Definition: all_of.hpp:22
SIMD-compatible representation of complex numbers.
Definition: complex.hpp:40

Parameters

Return value

  1. Returns the elementwise the natural logarithm of 1+x This function is more precise than the expression log(1+x) if x is close to zero. In particular:
    • If the element is \(\pm0\), \(-\infty\) is returned.
    • If the element is \(\pm0\), \(+0\) is returned.
    • If the element is \(\infty\), \(\infty\) is returned.
    • If the element is less than -1, NaN is returned.
  2. Returns elementwise the natural logarithm of 1+z. The behavior of this function is equivalent to eve::log(1+z), with better precision when z` is close to zero.

Example

Real version

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -0.0f, 0.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> log1p(pf) = " << eve::log1p(pf) << '\n'
;
float xf = 3.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> log1p(xf) = " << eve::log1p(xf) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Complex version

#include <eve/module/complex.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft ref = { 0.0f, 1.0f, -1.0f, 0.5f};
wide_ft imf = { 2.0f , -1.0, -5.0, 0.0};
auto z = eve::as_complex_t<wide_ft>(ref, imf);
std::cout
<< "---- simd" << std::endl
<< "<- z = " << z << std::endl
<< "-> log1p(z) = " << eve::log1p(z) << std::endl;
return 0;
}
  • Masked Call

    The call eve::log1p[mask](x) provides a masked version of eve::log1p which is equivalent to if_else (mask, log1p(x), x).

    Example

    #include <eve/module/math.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {-1.0f, 2.0f, -0.0f, 0.0f};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "-> log1p[pf > 1.0](pf) = " << eve::log1p[pf > 1.0](pf) << '\n';
    return 0;
    }