## ◆ rem_pio2_medium()

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

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

Note:
• This is a medium version accurate if the input is in: $$[-2^6\pi,2^6\pi]$$ for float, $$[-2^{18}\pi,2^{18}\pi]$$ for double.
The reduction of the argument modulo $$\pi/2$$ is generally the most difficult part of trigonometric evaluations. The accurate algorithm rem_pio2 is over costly and implies the knowledge of a few hundred $$\pi$$ decimals some simpler algorithms as this one can be used, but the precision is only insured on smaller intervals.
rem_pio2, 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_medium(pf);
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_medium(pf) = " << '\n'
<< "-> pe = " << pe << '\n'
<< "-> pm = " << pm << '\n';
float xf = 2.0f;
float e, m;
std::tie(e, m) = bs::rem_pio2_medium(xf);
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_medium(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_medium(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_medium(xf) =
-> e = 1
-> m = 0.429204