Hi,
Im trying to compare two float vectors using a custom compare that takes nan values into account.
I'm currently trying something like this:
BOOST_COMPUTE_FUNCTION(bool, float_equal, (value_type x, value_type y),
{
if (isnan(x) && isnan(y))
{
return true;
}
if (isnan(x) || isnan(y))
{
return false;
}
return x == y;
});
return boost::compute::all_of(
boost::compute::make_zip_iterator(boost::make_tuple(begin1, begin2)),
boost::compute::make_zip_iterator(boost::make_tuple(end1, end2)),
float_equal
);
Except the all_of function only accepts unary operators.
Wouldn't it make sense for the all_of algorithm to support a binary predicate so it can be used in combination with a zip_iterator.
Or am I overlooking something that would make this possible?
My current solution is to perform a transform_reduce that counts the number of non_equals but the all_of solution seems more natural.
Kind regards,
Dirk