E.V.E  0.1-beta

◆ prev

eve::prev = {}
inlineconstexpr

Callable object computing the prevt operation.

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

Members Functions

Member Effect
operator() the prevt 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 less 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::prev

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • eve::pedantic

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

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

Example

See it live on Compiler Explorer

#include <eve/function/prev.hpp>
#include <eve/function/pedantic/prev.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'
<< "-> prev(pf) =" << eve::prev(pf) << '\n'
<< "-> pedantic(prev)(pf) =" << eve::pedantic(eve::prev)(pf) << '\n'
<< "<- pi =" << pi << '\n'
<< "-> prev(pi) =" << eve::prev(pi) << '\n';
float xf = 0.0f;
std::int16_t xi = -3;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> prev(xf, 3) = " << eve::prev(xf, 3) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> prev(xi) = " << eve::prev(xi) << '\n';
return 0;
}
constexpr callable_prev_ prev
Callable object computing the prevt operation.
Definition: prev.hpp:111
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