## ◆ negate()

 Value boost::simd::negate ( Value const & x, Value const & y )

This function object returns the first element multiplied by 1, 0 or -1 depending on the fact its second argument is greater, equal or lesser than zero.

Note
If y is Zero the result is zero. This can be avoided using negatenz or copysign.
sign, negatenz, copysign, Mzero, is_positive, is_negative
Example:
#include <boost/simd/ieee.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = {1.0f, 2.0f, -1.0f, 0.5f};
pack_ft qf = {2.0f, -1.0f, 0.5f, 1.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> bs::negate(pf, qf) = " << bs::negate(pf, qf) << '\n';
float xf = 2.0f, yf = -1.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> bs::negate(xf, yf) = " << bs::negate(xf, yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
<- qf = (2, -1, 0.5, 1)
-> bs::negate(pf, qf) = (1, -2, -1, 0.5)
---- scalar
<- xf = 2
<- yf = -1
-> bs::negate(xf, yf) = -2