## ◆ rec()

 Value boost::simd::rec ( Value const & x )

This function object returns the inverse (reciprocal) of the entry.

Notes

The call to rec(x) is similar to One(as(x))/x

For integral typed entries the result is always in the set $$\{0, \pm1, Valmax \}$$

Decorators
• raw_ Many simd architectures provide an intrinsic that computes some bits of the inverse (at least 12) and don't care of denormals or limiting values. If it exists this is obtained by the raw_ decorator. If the intrinsic doesn't exist the regular rec is called.
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/inf.hpp>
#include <boost/simd/constant/minf.hpp>
#include <boost/simd/constant/nan.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 8>;
int main()
{
pack_ft pf = {-2.0f, 2.0f, 0.0f, -0.0f,
bs::Inf<float>(), bs::Minf<float>(), bs::Nan<float>(), 1.5f };
pack_it pi = {-3, -2, -1, 0, 1, 2, 3, 4};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::rec(pf) = " << bs::rec(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> bs::rec(pi) = " << bs::rec(pi) << '\n';
float xf = 5.0f;
std::int16_t xi = 0, yi = 2;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::rec(xf) = " << bs::rec(xf) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> bs::rec(xi) = " << bs::rec(xi) << '\n'
<< "<- yi = " << yi << '\n'
<< "-> bs::rec(yi) = " << bs::rec(yi) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (-2, 2, 0, -0, inf, -inf, -nan, 1.5)
-> bs::rec(pf) = (-0.5, 0.5, inf, -inf, 0, -0, -nan, 0.666667)
<- pi = (-3, -2, -1, 0, 1, 2, 3, 4)
-> bs::rec(pi) = (0, 0, -1, 32767, 1, 0, 0, 0)
---- scalar
<- xf = 5
-> bs::rec(xf) = 0.2
<- xi = 0
-> bs::rec(xi) = 32767
<- yi = 2
-> bs::rec(yi) = 0