E.V.E  0.1-beta

◆ next

eve::next = {}
inlineconstexpr

Callable object computing the next operation.

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

Members Functions

Member Effect
operator() the next operation
operator[] Construct a conditional version of current function object

template< value T, integral_value U > auto operator()( T x, U n = 1 ) const noexcept requires compatible< T, U >;

Parameters

x, n: values.

Return value

computes elementwise, the nth representable value greater than x. If n is zero returns x.


auto operator[]( conditional_expression auto cond ) const noexcept;

Higher-order function generating a masked version of eve::next

Parameters

cond : conditional expression

Return value

A Callable object so that the expression next[cond](x, ...) is equivalent to if_else(cond,next(x, ...),x)


Supported decorators

  • eve::pedantic

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

    The call pedantic(next)(x) distinguish -0.0 and +0.0 for floating point point inputs. So pedantic(next)(-0.0) is +0.0.

  • eve::saturated

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

    The call pedantic(next)(x) ensures for integral enties that next(x, n) >= x. (equality is obtained only if n == 0 or x = eve::valmax(as(x)))

Example

See it live on Compiler Explorer

#include <eve/function/next.hpp>
#include <eve/function/pedantic/next.hpp>
#include <eve/constant/bitincrement.hpp>
#include <eve/constant/eps.hpp>
#include <eve/wide.hpp>
#include <iostream>
#include <iomanip>
int main()
{
wide_ft pf = {-0.0f, 2.0f, eve::eps(eve::as<float>()), 0.0f};
wide_it pi = {-1, 2, -3, -32};
std::cout << "---- simd" << '\n'
<< "<- pf = " << std::setprecision(12) << pf << '\n'
<< "-> next(pf) = " << eve::next(pf) << '\n'
<< "-> pedantic(next)(pf) = " << eve::pedantic(eve::next)(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> next(pi) = " << eve::next(pi) << '\n';
float xf = 0.0f;
std::int16_t xi = -3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> next(xf, 3) = " << eve::next(xf, 3) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> next(xi) = " << eve::next(xi) << '\n';
return 0;
}
constexpr callable_next_ next
Callable object computing the next operation.
Definition: next.hpp:120
constexpr callable_eps_ eps
Callable object computing the machine epsilon.
Definition: eps.hpp:60
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr pedantic_type const pedantic
Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
Definition: pedantic.hpp:56
Lightweight type-wrapper.
Definition: as.hpp:29
Wrapper for SIMD registers.
Definition: wide.hpp:65