E.V.E  0.1-beta

◆ minus

eve::minus = {}
inlineconstexpr

Callable object computing the minus unary operation.

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

Members Functions

Member Effect
operator() the minus unary 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 a value with the same type as x. The result is the opposite of x if this value is representable in the type of x. More specifically, for signed integers the opposite value of their lowest finite value is not representable and the result is undefined behaviour.

Warning
Although the operator notation with - is supported, the - operator on standard scalar type is the original one and so can lead to automatic promotion.

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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

  • saturated

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

    The call saturated(minus)(x) computes the saturated opposite of x. The only interest of this behaviour is that for integral signed type T saturated(minus)(eve::valmin< T >()) returns eve::valmax< T >() and is not u.b.

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

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

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

Example

See it live on Compiler Explorer

#include <eve/function/minus.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
wide_it pi = {-1, 2, -3, -32768};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> minus(pf) = " << eve::minus(pf) << '\n'
<< "<- pi = " << pi << '\n'
<< "-> minus(pi) = " << eve::minus(pi) << '\n';
float xf = -32768.0f;
std::int16_t xi = -32768;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> minus(xf) = " << eve::minus(xf) << '\n'
<< "<- xi = " << xi << '\n'
<< "-> minus(xi) = " << eve::minus(xi) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the value.
Definition: pi.hpp:54
constexpr callable_minus_ minus
Callable object computing the minus unary operation.
Definition: minus.hpp:90
Wrapper for SIMD registers.
Definition: wide.hpp:65