◆ ulp()

Value boost::simd::ulp ( Value const &  x)

This function object returns the ulp distance to the nearest (distinct) element of the same type.

See also
ulpdist, eps, Eps
Header <boost/simd/function/ulp.hpp>
Example:
#include <boost/simd/ieee.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = {1.0f, 2.0f, -1.0f, 10000.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::ulp(pf) = " << bs::ulp(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::ulp(xf) = " << bs::ulp(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 10000)
-> bs::ulp(pf) = (5.96046e-08, 1.19209e-07, 5.96046e-08, 0.000976562)
---- scalar
<- xf = 2
-> bs::ulp(xf) = 1.19209e-07