◆ quadrant()

Value boost::simd::quadrant ( Value const &  n)

This function object computes the quadrant of its parameter.

Header <boost/simd/function/quadrant.hpp>
semantic:
For any given positive integral value (possibly flint) n of quadrant(n) returns the value in the same type 0, 1, 2 or 3 according to the two least significant bits of the truncated input.

for integral types this is similar to n&3.

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::quadrant(pf) = " << bs::quadrant(pf) << '\n'
<< "pi = " << pi << '\n'
<< "-> bs::quadrant(pi) = " << bs::quadrant(pi) << '\n';
float xf = -327.0f;
std::int16_t xi = -327;
std::cout
<< "---- scalar" << "\n"
<< " <- xf = " << xf << "\n"
<< " -> bs::quadrant(xf) = " << bs::quadrant(xf) << "\n"
<< " <- xi = " << xi << "\n"
<< " -> bs::quadrant(xi) = " << bs::quadrant(xi) << "\n";
return 0;
}
Possible output:
---- simd
pf = (-1, 2, -3, -32768)
-> bs::quadrant(pf) = (3, 2, 1, 0)
pi = (-1, 2, -3, -32768)
-> bs::quadrant(pi) = (3, 2, 1, 0)
---- scalar
<- xf = -327
-> bs::quadrant(xf) = 1
<- xi = -327
-> bs::quadrant(xi) = 1