◆ maxnum()

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

This function object returns the largest of two floating point arguments, treating NaNs as missing data (between a NaN and a numeric value, the numeric value is chosen).

Header <boost/simd/function/maxnum.hpp>
Decorators
  • std_ for floating entries calls the stdlibc++ function std::fmax.
See also
max, maxnummag, maxmag
Example:
#include <boost/simd/ieee.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/nan.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 4>;
int main()
{
pack_ft pf = { 3.0f, -2.0f, -0.0f, 0.0f };
pack_ft qf = { 4.0f, -1.0f, 0.0f, bs::Nan<float>() };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " -> bs::maxnum(pf, qf) = " << bs::maxnum(pf, qf) << '\n'
<< " -> bs::std_(bs::maxnum)(pf, qf) = " << bs::std_(bs::maxnum)(pf, qf) << '\n';
float xf = 3.0f, yf = 4.0f;
std::cout
<< "---- scalar" << '\n'
<< " xf = " << xf << '\n'
<< " yf = " << yf << '\n'
<< " -> bs::maxnum(xf, yf) = " << bs::maxnum(xf, yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (3, -2, -0, 0)
<- qf = (4, -1, 0, -nan)
-> bs::maxnum(pf, qf) = (4, -1, -0, 0)
-> bs::std_(bs::maxnum)(pf, qf) = (4, -1, 0, 0)
---- scalar
xf = 3
yf = 4
-> bs::maxnum(xf, yf) = 4