## ◆ if_else_zero()

 Value1 boost::simd::if_else_zero ( Value0 const & c, Value1 const & t )

This function object conditionally returns x (respectively Zero) if c is True (respectively False)

Example:
#include <boost/simd/boolean.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/nan.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 };
pack_ft qf = { 3.0f, 0.5f, -3.0f, 1.0f };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> bs::if_else_zero(pf, qf) = " << bs::if_else_zero(pf, qf) << '\n';
std::int32_t xf = 3, yf = 0, zf = 5;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " zf = " << zf << '\n'
<< " -> bs::if_else_zero(xf, zf) = " << bs::if_else_zero(xf, zf) << '\n'
<< " -> bs::if_else_zero(yf, zf) = " << bs::if_else_zero(yf, zf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3, 0, -3, -0)
<- qf = (3, 0.5, -3, 1)
-> bs::if_else_zero(pf, qf) = (3, 0, -3, 0)
---- scalar
xf = 3
yf = 0
zf = 5
-> bs::if_else_zero(xf, zf) = 5
-> bs::if_else_zero(yf, zf) = 0