◆ rsqrt()

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

This function object returns the inverse of the square root of the input.

Header <boost/simd/function/rsqrt.hpp>

Using rsqrt(x) is similar to One(as(x))/sqrt(x)

Decorators
  • raw_ if full accuracy is not needed gives access on some architectures to faster but less accurate version of the function.
See also
sqrt
Example:
#include <boost/simd/arithmetic.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, 4.0f, -1.0f, 0.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::rsqrt(pf) = " << bs::rsqrt(pf) << '\n';
float xf = 4.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::rsqrt(xf) = " << bs::rsqrt(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 4, -1, 0)
-> bs::rsqrt(pf) = (1, 0.5, -nan, inf)
---- scalar
<- xf = 4
-> bs::rsqrt(xf) = 0.5