◆ sqrt1pm1()

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

This function object returns \(\sqrt{1+x}-1\) and the result is accurate even for x with small modulus.

See also
log1p, expm1.
Header <boost/simd/function/sqrt1pm1.hpp>
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/eps.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = {-1.0f, 0.0f, 1.0f, bs::Eps<float>()};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::sqrt1pm1(pf) = " << bs::sqrt1pm1(pf) << '\n';
float xf = bs::Eps<float>();
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::sqrt1pm1(xf) = " << bs::sqrt1pm1(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (-1, 0, 1, 1.19209e-07)
-> bs::sqrt1pm1(pf) = (-1, 0, 0.414214, 5.96046e-08)
---- scalar
<- xf = 1.19209e-07
-> bs::sqrt1pm1(xf) = 5.96046e-08