◆ safe_min()

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

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

a value which will not underflow when divided by the input argument.

Header <boost/simd/function/safe_min.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 = v " << pf << '\n'
<< "-> bs::safe_min(pf) = " << bs::safe_min(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::safe_min(xf) = " << bs::safe_min(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = v (1, 2, -1, 0.5)
-> bs::safe_min(pf) = (1.0842e-19, 2.1684e-19, 1.0842e-19, 5.42101e-20)
---- scalar
<- xf = 2
-> bs::safe_min(xf) = 2.1684e-19