◆ safe_max()

IEEEValue boost::simd::safe_max ( IEEEValue const &  x)

This function object returns a safe maximal value relative to the input, i.e.

a value which will not overflow when multiplied by the input argument.

Header <boost/simd/function/safe_max.hpp>
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::safe_max(pf) = " << bs::safe_max(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::safe_max(xf) = " << bs::safe_max(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::safe_max(pf) = (1.84467e+19, 9.22337e+18, 1.84467e+19, 3.68935e+19)
---- scalar
<- xf = 2
-> bs::safe_max(xf) = 9.22337e+18