E.V.E  0.1-beta

◆ ulpdist

eve::ulpdist = {}
inlineconstexpr

Callable object computing the ulpdistt operation.

Required header: #include <eve/function/ulpdist.hpp>

Members Functions

Member Effect
operator() the ulpdistt operation

template< value T, value U > auto operator()( T x, U y ) const noexcept requires compatible< T, U >;

Parameters

x, y: values.

Return value

computes elementwise the 'units in the last place' distance betwween x and y. This is semantically equivalent to:`

  • if is_ordered(x,y), nb_values(x,y)/2.0 is returned
  • otherwise a Nan is returned

Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/ulpdist.hpp>
#include <eve/constant/eps.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/smallestposval.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
w_t pi = {0.0f, 1.0f, 1.0f-eve::eps(eve::as<float>())/2, 1.0f };
std::cout << "---- simd" << std::setprecision(9) << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> ulpdist(pi, qi) = " << eve::ulpdist(pi, qi) << '\n';
std::uint32_t xi = 3, yi = 7;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> ulpdist(xi, yi) = " << eve::ulpdist(xi, yi) << '\n';
return 0;
}
constexpr callable_eps_ eps
Callable object computing the machine epsilon.
Definition: eps.hpp:60
constexpr callable_smallestposval_ smallestposval
Callable object computing the smallest normal positive value.
Definition: smallestposval.hpp:56
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr callable_inf_ inf
Callable object computing the infinity ieee value.
Definition: inf.hpp:54
constexpr callable_ulpdist_ ulpdist
Callable object computing the ulpdistt operation.
Definition: ulpdist.hpp:63
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65