E.V.E  0.1-beta

◆ negate

eve::negate = {}
inlineconstexpr

Callable object computing the negate operation.

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

Members Functions

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

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

Parameters

x: value to negate.

y: value whose sign will be used to negate x.

Return value

Returns the elementwise product of the first parameter by the sign of the second.


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

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

Parameters

cond : conditional expression

Return value

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


Supported decorators

no decorators are supported

Example

See it live on Compiler Explorer

#include <eve/function/negate.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {0.0f, -0.0f, 0.0f, -0.0f, 2.0f, -2.0f, 2.0f, 2.0f};
wide_ft qf = {4.0f, 4.0f, -4.0f, -4.0, 4.0f, 4.0f, -0.0f, +0.0f};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> negate(pf, qf) = " << eve::negate(pf, qf) << '\n';
float xf = 4.0f;
float yf = -1.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> negate(xf, yf) = " << eve::negate(xf, yf) << '\n';
return 0;
}
constexpr callable_negate_ negate
Callable object computing the negate operation.
Definition: negate.hpp:74
Wrapper for SIMD registers.
Definition: wide.hpp:65