◆ genmask()

as_arithmetic_t<LogicalValue> boost::simd::genmask ( const LogicalValue a)

This function object returns a mask of bits.

This mask is full of ones if the input element is non Zero else full of zeros.

See also
genmaskc
Header <boost/simd/function/genmask.hpp>
Example:
#include <boost/simd/bitwise.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, -0.0f, 0.0f, 0.5f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::genmask(pf) = " << bs::genmask(pf) << '\n';
float xf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::genmask(xf) = " << bs::genmask(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, -0, 0, 0.5)
-> bs::genmask(pf) = (-nan, 0, 0, -nan)
---- scalar
<- xf = 2
-> bs::genmask(xf) = -nan
Alias:
if_allbits_else_zero
See also
if_allbits_else