◆ rem_pio2_straight()

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

This function object returns the Computes the remainder modulo \(\pi/2\).

Header <boost/simd/function/rem_pio2_straight.hpp>
Notes
  • rem_pio2_straight computes the remainder modulo \(\pi/2\) with "straight" algorithm, and returns an angle quadrant which is always 1. This is a very quick version only correct if the input is in \([\pi/4,\pi/2]\).
  • In fact it only substracts \(\pi/2\) to the input so it can be viewed as a specially accurate minuspio_2 function outside the interval in which it can be used as a substitute to rem_pio2.
  • The reduction of the argument modulo \(\pi/2\) is generally the most difficult part of trigonometric evaluations. The accurate algorithm over the whole floating point range 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 specific intervals.
See also
rem_pio2, rem_pio2_medium,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_straight(pf);
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_straight(pf) = " << '\n'
<< "-> pe = " << pe << '\n'
<< "-> pm = " << pm << '\n';
float xf = 2.0f;
float e, m;
std::tie(e, m) = bs::rem_pio2_straight(xf);
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> std::tie(pe, pm) = bs::rem_pio2_straight(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_straight(pf) =
-> pe = (1, 1, 0, 0)
-> pm = (-0.570796, 0.429204, -1, 0.5)
---- scalar
<- xf = 2
-> std::tie(pe, pm) = bs::rem_pio2_straight(xf) =
-> e = 1
-> m = 0.429204