Computes the elementwise product of the first parameter by the sign of the second.
Defined in Header
#include <eve/module/core.hpp>
{
template< eve::value T, eve::value U >
}
constexpr callable_negate_ negate
Computes the elementwise product of the first parameter by the sign of the second.
Definition: negate.hpp:63
typename eve::detail::common_value_impl< void, Ts... >::type common_value_t
Computes the SIMD-compatible common type between all Ts.
Definition: common_value.hpp:50
Parameters
Return value
The elementwise product of the first parameter by the sign of the second is returned.
#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
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'
<<
"-> negate[pf < qf](pf, qf) = " <<
eve::negate[pf < qf](pf, qf) <<
'\n';
return 0;
}