◆ bitwise_select()

Value1 boost::simd::bitwise_select ( Value0 const &  sel,
Value1 const &  x,
Value2 const &  y 
)

This function object returns the bitwise selection of bits from the second or third operand according to the setting of the bits of the first operand.

Header <boost/simd/function/bitwise_select.hpp>
Precondition
The operands must share the same bit size and number of elements.
Example:
#include <boost/simd/bitwise.hpp>
#include <boost/simd/constant/allbits.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using iT = std::uint32_t;
using pack_it = bs::pack<iT, 4>;
int main() {
pack_it pi = {3, -2, -10, 0};
pack_it qi = {4, -1, 0, 5};
pack_it si = {2, bs::Allbits<iT>(), 0, 4};
std::cout << "---- simd" << '\n'
<< " <- si = " << si << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> bs::bitwise_select(si, pi, qi) = "
<< bs::bitwise_select(si, pi, qi) << '\n';
iT ssi = 3, xi = 3, yi = 4;
std::cout << "---- scalar" << '\n'
<< " ssi = " << ssi << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> bs::bitwise_select(ssi, xi, yi) = "
<< bs::bitwise_select(ssi, xi, yi) << '\n';
return 0;
}
Possible output:
---- simd
<- si = (2, 4294967295, 0, 4)
<- pi = (3, 4294967294, 4294967286, 0)
<- qi = (4, 4294967295, 0, 5)
-> bs::bitwise_select(si, pi, qi) = (6, 4294967294, 0, 1)
---- scalar
ssi = 3
xi = 3
yi = 4
-> bs::bitwise_select(ssi, xi, yi) = 7