◆ mask2logical()

as_logical_t<Value> boost::simd::mask2logical ( Value const &  x)

This function object converts an arithmetic mask where each element is Zero or Allbits to a logical value.

If it is not the case this function asserts.

Header <boost/simd/function/mask2logical.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 = { bs::Nan<float>(), 0.0f, bs::Nan<float>(), 0.0 };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " -> bs::mask2logical(pf) = " << bs::mask2logical(pf) << '\n';
std::int32_t xf = bs::Nan<float>(), yf = 0.0f;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " -> bs::mask2logical(xf) = " << bs::mask2logical(xf) << '\n'
<< " -> bs::mask2logical(yf) = " << bs::mask2logical(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (-nan, 0, -nan, 0)
-> bs::mask2logical(pf) = (true, false, true, false)
---- scalar
xf = 0
yf = 0
-> bs::mask2logical(xf) = false
-> bs::mask2logical(yf) = false