◆ rem_2pi()

IEEEValue boost::simd::rem_2pi ( IEEEValue const &  x)

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

Header <boost/simd/function/rem_2pi.hpp>
Note
  • The result is in \([-\pi, \pi]\).
  • If the input is near \(\pi\) the output can be \(\pi\) or \(-\pi\) depending on register disponibility if extended arithmetic is used.
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};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "-> bs::rem_2pi(pf) = " << bs::rem_2pi(pf) << '\n';
float xf = 2.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> bs::rem_2pi(xf) = " << bs::rem_2pi(xf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (1, 2, -1, 0.5)
-> bs::rem_2pi(pf) = (1, 2, -1, 0.5)
---- scalar
<- xf = 2
-> bs::rem_2pi(xf) = 2