◆ dist
Callable object computing the distance between two values. Required header: Members Functions
template< value T, value U > auto operator()( T x, U y ) const noexcept requires compatible< T, U >;
Parameters
Return value auto r = dist(x,y);
constexpr callable_dist_ dist Callable object computing the distance between two values. Definition: dist.hpp:97 is semantically equivalent to: auto r = abs(x-y);
constexpr callable_abs_ abs Callable object computing the absolute value. Definition: abs.hpp:91 If an element of the expected result is not representable in the result type, the corresponding result element is undefined. The result type is the common compatible type of the two parameters. auto operator[]( conditional_expression auto cond ) const noexcept;
Higher-order function generating a masked version of eve::dist Parameters
Return value A Callable object so that the expression Supported decorators
ExampleSee it live on Compiler Explorer #include <eve/function/dist.hpp>
#include <eve/function/saturated/dist.hpp>
#include <eve/wide.hpp>
#include <eve/constant/valmax.hpp>
#include <eve/constant/valmin.hpp>
#include <iostream>
using wide_it = eve::wide<int16_t, eve::fixed<4>>;
int main()
{
wide_it pf = {0, 1, -1, -eve::valmax(eve::as<int16_t>())};
wide_it qf = {1, -1, 0, eve::valmax(eve::as<int16_t>())};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< '\n';
int16_t xf = -eve::valmax(eve::as<int16_t>());
int16_t yf = eve::valmax(eve::as<int16_t>());
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< '\n';
return 0;
}
constexpr callable_valmax_ valmax Callable object computing the greatest representable value. Definition: valmax.hpp:53 constexpr saturated_type const saturated Higher-order Callable Object imbuing saturation semantic onto other Callable Objects. Definition: saturated.hpp:68 |