## ◆ minus()

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

This function object computes the difference of two parameters of the same type.

Infix notation can be used with operator '-',

Header <boost/simd/function/minus.hpp>
Decorators
• saturated_ (See Decorators) computes the saturated difference.
See also
plus, divides, multiplies
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
using pack_it = bs::pack <std::int16_t,4>;
int main()
{
pack_ft pf = { 1.0f, -2.0f, -3.0f, -32700.0f};
pack_ft qf = { 2.0f, -1.0f, -3.0f, 32721 };
pack_it pi = { 1, -2, -2, -32768 };
pack_it qi = { 2, -1, -3, 1 };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> bs::minus(pf, qf) = " << bs::minus(pf, qf) << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> bs::minus(pi, qi) = " << bs::minus(pi, qi) << '\n'
<< " -> bs::saturated_(bs::minus)(pi, qi) = " << bs::saturated_(bs::minus)(pi, qi) << '\n';
float xf = 32767.0f, yf = -32000.0f;
std::int16_t xi = 32767, yi = -32000;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " -> bs::minus(xf, yf) = " << bs::minus(xf, yf) << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> bs::minus(xi, yi) = " << bs::minus(xi, yi) << '\n'
<< " -> bs::saturated_(bs::minus)(xi, yi) = " << bs::saturated_(bs::minus)(xi, yi) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, -2, -3, -32700)
<- qf = (2, -1, -3, 32721)
-> bs::minus(pf, qf) = (-1, -1, 0, -65421)
<- pi = (1, -2, -2, -32768)
<- qi = (2, -1, -3, 1)
-> bs::minus(pi, qi) = (-1, -1, 1, 32767)
-> bs::saturated_(bs::minus)(pi, qi) = (-1, -1, 1, -32768)
---- scalar
xf = 32767
yf = -32000
-> bs::minus(xf, yf) = 64767
xi = 32767
yi = -32000
-> bs::minus(xi, yi) = -769
-> bs::saturated_(bs::minus)(xi, yi) = 32767