E.V.E  0.1-beta

◆ sub

eve::sub = {}
inlineconstexpr

Callable object performing the difference of multiple values.

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

Members Functions

Member Effect
operator() Computes the absolute value of its parameter
operator[] Construct a conditional version of current function object

auto operator()(eve::value auto const&... xs) const noexcept;
Definition: value.hpp:31

Parameters

xs: Instances of eve::value

Return value

A value of the common compatible type of all xs containing the elementwise difference of all xs: sub(x0, x1, ..., xn) is semantically equivalent to sub(x0, add(x1, ..., xn)).


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

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

Parameters

cond : conditional expression

Return value

A Callable object so that the expression sub[cond](x0,xs...) is equivalent to if_else(cond,sub(x0,xs...),x0)


Supported decorators

Example

See it live on Compiler Explorer

#include <eve/function/sub.hpp>
#include <eve/function/saturated/sub.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
w_t pi = {3, 2, -32700, 32700}, qi = {4, 1, 100, -100};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> sub(pi, qi) = " << eve::sub(pi, qi) << '\n'
<< " -> pi + qi = " << pi + qi << '\n'
<< " -> saturated(sub)(pi, qi) = " << eve::saturated(eve::sub)(pi, qi) << '\n';
std::int16_t xi = 100, yi = 32700;
std::cout << "---- scalar" << '\n'
<< " <- xi = " << xi << '\n'
<< " <- yi = " << yi << '\n'
<< " -> sub(xi, yi) = " << eve::sub(xi, yi) << '\n'
<< " -> xi + yi = " << xi + yi << '\n'; // C++ promotion to int
std::cout << "---- multi parameters" << '\n'
<< " -> sub(pi, pi, pi, 1) = " << eve::sub(pi, pi, pi, 1) << '\n'
<< " -> saturated(eve::sub)(pi,12, pi,pi) = " << eve::saturated(eve::sub)(pi, 12, pi,pi) << '\n';
return 0;
}
constexpr callable_sub_ sub
Callable object performing the difference of multiple values.
Definition: sub.hpp:88
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