## ◆ negatenz()

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

This function object returns x multiplied by the signnz of y.

The result is unspecified if y is Nan

Note
If x is null the result is $$\pm0$$. Take care that negatenz distinguish between the signs of T(0) and -T(0) when T is a floating type.
negatenz, 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::negatenz(pf, qf) = " << bs::negatenz(pf, qf) << '\n';
float xf = 2.0f, yf = -1.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> bs::negatenz(xf, yf) = " << bs::negatenz(xf, yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
<- qf = (2, -1, 0.5, 1)
-> bs::negatenz(pf, qf) = (1, -2, -1, 0.5)
---- scalar
<- xf = 2
<- yf = -1
-> bs::negatenz(xf, yf) = -2