◆ dec()

Value boost::simd::dec ( Value const &  x)

This function object returns its parameter decremented by 1.

Header <boost/simd/function/dec.hpp>
Decorators
  • saturated_ ensures that saturated_(dec)(x) will never be strictly greater than x, avoiding the wrap around from Valmin to Valmax with integer types
See also
inc, minus
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, -32768.0f};
pack_it pi = {-1, 2, -3, -32768 };
std::cout
<< "---- simd" << '\n'
<< "pf = " << pf << '\n'
<< "-> bs::dec(pf) = " << bs::dec(pf) << '\n'
<< "pi = " << pi << '\n'
<< "-> bs::dec(pi) = " << bs::dec(pi) << '\n'
<< "-> bs::saturated_(bs::dec(pi)) = " << bs::saturated_(bs::dec)(pi) << '\n';
float xf = -32768.0f;
std::int16_t xi = -32768;
std::cout
<< "---- scalar" << "\n"
<< " <- xf = " << xf << "\n"
<< " -> bs::dec(xf) = " << bs::dec(xf) << "\n"
<< " <- xi = " << xi << "\n"
<< " -> bs::dec(xi) = " << bs::dec(xi) << "\n"
<< " -> bs::saturated_(bs::dec(xi)) = " << bs::saturated_(bs::dec)(xi) << "\n";
return 0;
}
Possible output:
---- simd
pf = (-1, 2, -3, -32768)
-> bs::dec(pf) = (-2, 1, -4, -32769)
pi = (-1, 2, -3, -32768)
-> bs::dec(pi) = (-2, 1, -4, 32767)
-> bs::saturated_(bs::dec(pi)) = (-2, 1, -4, -32768)
---- scalar
<- xf = -32768
-> bs::dec(xf) = -32769
<- xi = -32768
-> bs::dec(xi) = 32767
-> bs::saturated_(bs::dec(xi)) = -32768