◆ if_else_nan()

Value1 boost::simd::if_else_nan ( Value0 const &  c,
Value1 const &  x 
)

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

This is an alias of if_else_allbits

Header <boost/simd/function/if_else_nan.hpp>
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_nan(pf, qf) = " << bs::if_else_nan(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_nan(xf, zf) = " << bs::if_else_nan(xf, zf) << '\n'
<< " -> bs::if_else_nan(yf, zf) = " << bs::if_else_nan(yf, zf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3, 0, -3, -0)
<- qf = (3, 0.5, -3, 1)
-> bs::if_else_nan(pf, qf) = (3, -nan, -3, -nan)
---- scalar
xf = 3
yf = 0
zf = 5
-> bs::if_else_nan(xf, zf) = 5
-> bs::if_else_nan(yf, zf) = -1