◆ is_not_equal_with_equal_nans()

as_logical_t<Value> boost::simd::is_not_equal_with_equal_nans ( Value const &  x,
Value const &  y 
)

This function object returns True if x and y are not equal else False, nans being considered equal.

Header <boost/simd/function/is_not_equal_with_equal_nans.hpp>
Note

Using is_not_equal_with_equal_nans(x,y) is similar to: (x != y) || ((x!= x) && (y!= y))

Example:
#include <boost/simd/predicates.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/inf.hpp>
#include <boost/simd/constant/minf.hpp>
#include <boost/simd/constant/nan.hpp>
#include <boost/simd/constant/mindenormal.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 8>;
int main()
{
pack_ft pf = { 0.0f, 1.0f, -1.0f, -2.0f
, bs::Mindenormal<float>(), bs::Inf<float>(), bs::Minf<float>(), bs::Nan<float>() };
pack_ft qf = { bs::Mindenormal<float>(), bs::Inf<float>(), bs::Minf<float>(), bs::Nan<float>(),
0.0f, 1.0f, -1.0f, bs::Nan<float>() };
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << pf << '\n'
<< "-> bs::is_not_equal_with_equal_nans(pf, qf) = " << bs::is_not_equal_with_equal_nans(pf, qf) << '\n';
float xf = 1.0f;
float yf = bs::Nan<float>();
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> bs::is_not_equal_with_equal_nans(xf, yf) = " << bs::is_not_equal_with_equal_nans(xf, yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (0, 1, -1, -2, 1.4013e-45, inf, -inf, -nan)
<- qf = (0, 1, -1, -2, 1.4013e-45, inf, -inf, -nan)
-> bs::is_not_equal_with_equal_nans(pf, qf) = (true, true, true, false, true, true, true, false)
---- scalar
<- xf = 1
<- yf = -nan