E.V.E
v2022.09.01

◆ negate

eve::negate = {}
inlineconstexpr

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

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T, eve::value U >
eve::common_compatible_t<T, U> negate(T x, U y) noexcept;
}
constexpr callable_negate_ negate
Computes the elementwise product of the first parameter by the sign of the second.
Definition: negate.hpp:63
Definition: all_of.hpp:22

Parameters

Return value

The elementwise product of the first parameter by the sign of the second is returned.

Example

#include <eve/module/core.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;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::negate[mask](x, ...) provides a masked version of negate which is equivalent to if_else(mask, negate(x, ...), x) Example

    #include <eve/module/core.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'
    << "-> raw(negate)(pf, qf) = " << eve::raw(negate)(pf, qf) << '\n';
    float xf = 4.0f;
    float yf = -1.0f;
    std::cout << "---- scalar" << '\n'
    << "<- xf = " << xf << '\n'
    << "<- yf = " << yf << '\n'
    << "-> raw(negate)(xf, yf) = " << eve::raw(negate)(xf, yf) << '\n';
    return 0;
    }
    constexpr raw_type const raw
    Higher-order Callable Object imbuing quick and dirty behaviour onto other Callable Objects.
    Definition: raw.hpp:43