E.V.E  0.1-beta

◆ oneminus

eve::oneminus = {}
inlineconstexpr

Callable object computing the oneminus operation.

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

Members Functions

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

auto operator()(value auto x) const noexcept;
Definition: value.hpp:31

Parameters

x: value.

Return value

Computes elementwise 1-x with the type of x.

Warning
If an element of the expected result is not representable in the result type, the corresponding result element is undefined.

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • saturated

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

    The call saturated(oneminus)(x) is semantically equivalent to saturated(sub)(One(as(x)), x) and is never undefined.

  • eve::diff, eve::diff_1st, eve::diff_nth

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

    The expression diff(oneminus)(x) computes the derivative of the function at x.

Example

See it live on Compiler Explorer

#include <eve/function/oneminus.hpp>
#include <eve/function/saturated/oneminus.hpp>
#include <eve/wide.hpp>
#include <eve/constant/inf.hpp>
#include <eve/constant/minf.hpp>
#include <eve/constant/nan.hpp>
#include <eve/constant/mindenormal.hpp>
#include <iostream>
int main()
{
wide_it pi = { 0, 1, 2, 3, -1, -32766, -32767, -32768};
std::cout
<< "---- simd" << '\n'
<< "<- pi = " << pi << '\n'
<< "-> oneminus(pi) = " << eve::oneminus(pi) << '\n'
<< "-> saturated(oneminus(pi)) = " << eve::saturated(eve::oneminus)(pi) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> oneminus(xf) = " << eve::oneminus(xf) << '\n';
return 0;
}
constexpr callable_oneminus_ oneminus
Callable object computing the oneminus operation.
Definition: oneminus.hpp:87
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr saturated_type const saturated
Higher-order Callable Object imbuing saturation semantic onto other Callable Objects.
Definition: saturated.hpp:68
Wrapper for SIMD registers.
Definition: wide.hpp:65