## ◆ rem_pio2()

 std::pair boost::simd::rem_pio2 ( IEEEValue const & x )

This function object computes the remainder modulo $$\pi/2$$, and the angle quadrant between 0 and 3.

This is a rather slow version, but accurate in the full floating range.

Notes
• This algorithm is accurate over the full floating range, but also is over costly and implies the knowledge of a few hundred $$\pi$$ decimals
• Some simpler algorithms rem_pio2_medium, rem_pio2_cephes or rem_pio2_straight can often be used, but the precision is only insured on smaller intervals.
• Using std::tie(n, r) = rem_pio2(x); is similar to n = div(inearbyint, x, Pio_2<T>()) and r = remainder(x, Pio_2<T>())
rem_pio2_medium, rem_pio2_straight, rem_2pi, rem_pio2_cephes,
Example:
#include <boost/simd/trigonometric.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};
pack_ft pe, pm;
std::tie(pe, pm) = bs::rem_pio2(pf);
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2(pf) = " << '\n'
<< "-> pe = " << pe << '\n'
<< "-> pm = " << pm << '\n';
float xf = 2.0f;
float e, m;
std::tie(e, m) = bs::rem_pio2(xf);
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2(xf) = " << '\n'
<< "-> e = " << e << '\n'
<< "-> m = " << m << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> std::tie(pe, pm) = bs::rem_pio2(pf) =
-> pe = (1, 1, 3, 0)
-> pm = (-0.570796, 0.429204, 0.570796, 0.5)
---- scalar
<- xf = 2
-> std::tie(pe, pm) = bs::rem_pio2(xf) =
-> e = 1
-> m = 0.429204