◆ if_zero_else_one()

Value boost::simd::if_zero_else_one ( Value const &  c)

This function object conditionally returns 0 (respectively 1) if c is True (respectively False)

Header <boost/simd/function/if_zero_else_one.hpp>
Example:
#include <boost/simd/boolean.hpp>
#include <boost/simd/pack.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_zero_else_one(pf) = " << bs::if_zero_else_one(pf) << '\n';
std::int32_t xf = 3, yf = 0;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " -> bs::if_zero_else_one(xf) = " << bs::if_zero_else_one(xf) << '\n'
<< " -> bs::if_zero_else_one(yf) = " << bs::if_zero_else_one(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3, 0, -3, -0)
-> bs::if_zero_else_one(pf) = (0, 1, 0, 1)
---- scalar
xf = 3
yf = 0