E.V.E
v2023.02.15

◆ nextafter

eve::nextafter = {}
inlineconstexpr

Computes the nth next representable element.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T, eve::value U >
}
constexpr callable_nextafter_ nextafter
Computes the nth next representable element.
Definition: nextafter.hpp:73
Definition: abi.hpp:18
typename eve::detail::common_value_impl< void, Ts... >::type common_value_t
Computes the SIMD-compatible common type between all Ts.
Definition: common_value.hpp:50

Parameters

Return value

The value of the next representable value greater than x in the y direction is returned. If y == x returns x.

Example

#include <eve/module/core.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};
w_t qi = {-1.0f, -2.0f, 3.0f, eve::inf(eve::as<float>())};
std::cout << "---- simd" << std::setprecision(9) << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> nextafter(pi, qi) = " << eve::nextafter(pi, qi) << '\n';
std::uint32_t xi = 3, yi = 7;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> nextafter(xi, yi) = " << eve::nextafter(xi, yi) << '\n';
return 0;
}
constexpr callable_eps_ eps
Computes the the machine epsilon.
Definition: eps.hpp:63
constexpr callable_inf_ inf
Computes the infinity ieee value.
Definition: inf.hpp:58
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::nextafter[mask](x, ...) provides a masked version of nextafter which is equivalent to if_else(mask, nextafter(x, ...), x)

    Example

    #include <eve/module/core.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};
    w_t qi = {-1.0f, -2.0f, 3.0f, eve::inf(eve::as<float>())};
    std::cout << "---- simd" << std::setprecision(9) << '\n'
    << " <- pi = " << pi << '\n'
    << " <- qi = " << qi << '\n'
    << " -> nextafter[pi < qi](pi, qi) = " << eve::nextafter[pi < qi](pi, qi) << '\n';
    return 0;
    }