◆ predecessor()

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

This function object returns the n-th greatest element strictly less than the parameter.

Header <boost/simd/function/predecessor.hpp>
Note

If n is null returns x else computes the n-th greatest representable value strictly less than x in its type. n must be positive or null.

  • For integer types it saturates at Valmin.
  • For floating point numbers, all Minf strict predecessors are Nan.
See also
next, prev, successor, nextafter, Minf, Valmin, Nan
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};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::predecessor(pf) = " << bs::predecessor(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::predecessor(xf) = " << bs::predecessor(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::predecessor(pf) = (1, 2, -1, 0.5)
---- scalar
<- xf = 2
-> bs::predecessor(xf) = 2