◆ rem_pio2_cephes()

std::pair<IEEEValue, IEEEValue> boost::simd::rem_pio2_cephes ( IEEEValue const &  x)

This function object returns the Computes the remainder modulo \(\pi/2\) with cephes algorithm, and the angle quadrant between 0 and 3.

This is a quick version accurate if the input is in \([-20\pi,20\pi]\).

Header <boost/simd/function/rem_pio2_cephes.hpp>
Note

Using std::tie(n, r) = rem_pio2_cephes(x) is similar to n = div(inearbyint, x, Pio_2<T>()) and r = remainder(x, Pio_2<T>())

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_cephes(pf);
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_cephes(pf) = " << '\n'
<< "-> pe = " << pe << '\n'
<< "-> pm = " << pm << '\n';
float xf = 2.0f;
float e, m;
std::tie(e, m) = bs::rem_pio2_cephes(xf);
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_cephes(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_cephes(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_cephes(xf) =
-> e = 1
-> m = 0.429204