◆ log1p()

IEEEValue boost::simd::log1p ( IEEEValue const &  x)

This function object computes \(\log(1+x)\) with good accuracy even for small \(x\) values.

Header <boost/simd/function/log1p.hpp>
Decorators
  • std_ for floating entries calls std::log1p
See also
log, exp, expm1
Example:
#include <boost/simd/exponential.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack<float, 4>;
int main() {
pack_ft pf = {1.0f, 2.0f, 1.0e-20f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::log1p(pf) = " << bs::log1p(pf) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::log1p(xf) = " << bs::log1p(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, 1e-20, 0.5)
-> bs::log1p(pf) = (0.693147, 1.09861, 1e-20, 0.405465)
---- scalar
<- xf = 2
-> bs::log1p(xf) = 1.09861