◆ lookup()

Value boost::simd::lookup ( Value const &  x,
IntegerValue const &  n 
)

Function object implementing lookup capabilities.

shuffles the elements of x using indices in n

Header <boost/simd/function/lookup.hpp>
Semantic:

For every parameters of types respectively T, N:

T r = lookup(x,n);

is similar to:

T r;
for(size_t i=0; i < boost::simd::meta::cardinal_of<T>::value; i++)
r[i] = x[n[i]];
Example:
#include <boost/simd/swar.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.0f, 0.5f};
pack_it qi = {1, 2, -1, 3};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qi = " << qi << '\n'
<< "-> bs::lookup(pf, qi) = " << bs::lookup(pf, qi) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
<- qi = (1, 2, -1, 3)
-> bs::lookup(pf, qi) = (2, -1, 0, 0.5)