◆ if_allbits_else_zero()

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

This function object returns a mask of bits.

All ones if the argument is non Zero else all zeros. This is an alias of genmask

Header <boost/simd/function/if_allbits_else_zero.hpp>
Example:
#include <boost/simd/boolean.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/valmax.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = { 3.0f, 0.0f, -3.0f, -0.0 };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " -> bs::if_allbits_else_zero(pf) = " << bs::if_allbits_else_zero(pf) << '\n';
std::int32_t xf = 3, yf = 0;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " -> bs::if_allbits_else_zero(xf) = " << bs::if_allbits_else_zero(xf) << '\n'
<< " -> bs::if_allbits_else_zero(yf) = " << bs::if_allbits_else_zero(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3, 0, -3, -0)
-> bs::if_allbits_else_zero(pf) = (-nan, 0, -nan, 0)
---- scalar
xf = 3
yf = 0