## ◆ multiplies()

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

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

Infix notation can be used with operator '*',

Decorators
• saturated_ (See Decorators) computes the saturated product.
minus, divides, plus
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, 3.0f };
pack_it pi = { 1, -2, -2, 32767 };
pack_it qi = { 2, -1, -3, 2 };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> bs::multiplies(pf, qf) = " << bs::multiplies(pf, qf) << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> bs::multiplies(pi, qi) = " << bs::multiplies(pi, qi) << '\n'
<< " -> bs::saturated_(bs::multiplies)(pi, qi) = " << bs::saturated_(bs::multiplies)(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::multiplies(xf, yf) = " << bs::multiplies(xf, yf) << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> bs::multiplies(xi, yi) = " << bs::multiplies(xi, yi) << '\n'
<< " -> bs::saturated_(bs::multiplies)(xi, yi) = " << bs::saturated_(bs::multiplies)(xi, yi) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, -2, -3, -32700)
<- qf = (2, -1, -3, 3)
-> bs::multiplies(pf, qf) = (2, 2, 9, -98100)
<- pi = (1, -2, -2, 32767)
<- qi = (2, -1, -3, 2)
-> bs::multiplies(pi, qi) = (2, 2, 6, -2)
-> bs::saturated_(bs::multiplies)(pi, qi) = (2, 2, 6, 32767)
---- scalar
xf = 32767
yf = -32000
-> bs::multiplies(xf, yf) = -1.04854e+09
xi = 32767
yi = -32000
-> bs::multiplies(xi, yi) = 32000
-> bs::saturated_(bs::multiplies)(xi, yi) = -32768

returns the product of a and b