◆ arg()

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

This function computes the angular orientation of its floating parameter (the result is undifined for Nan entries if the pedantic_ decorator is not used)

Header <boost/simd/function/arg.hpp>

Using arg(x) is equivalent to (is_negative(x)) ? Pi(as(x)) : Zero(as(x))

Notes
  • always returns \(+0\) or \(\pi\) taking into account the bit of sign even in the Nan case.
  • This function implement the restriction to real numbers of the complex arg(ument) function.
Decorators
  • pedantic_ returns Nan(as(x)) for a nan input,
See also
is_negative, Pi, Nan
Example:
#include <boost/simd/arithmetic.hpp>
#include <boost/simd/pack.hpp>
#include <boost/simd/constant/minf.hpp>
#include <boost/simd/constant/inf.hpp>
#include <boost/simd/constant/nan.hpp>
#include <iostream>
namespace bs = boost::simd;
using pack_ft = bs::pack <float, 8>;
int main()
{
pack_ft pf = { -1.0f, -0.0f, 0.0f, 1.0f
, -bs::Nan<float>(), bs::Nan<float>(), bs::Inf<float>(), bs::Minf<float>() };
std::cout
<< "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " -> bs::arg(pf) = " << bs::arg(pf) << '\n'
<< " <- pf = " << pf << '\n'
<< " -> bs::pedantic_(bs::arg)(pf) = " << bs::pedantic_(bs::arg)(pf) << '\n'
<< "scalar" << '\n';
float xf = 1.0f;
float yf = -1.0f;
std::cout
<< "---- scalar" << '\n'
<< " <- xf = " << xf << '\n'
<< " -> bs::arg(xf) = " << bs::arg(xf) << '\n'
<< " <- yf = " << yf << '\n'
<< " -> bs::arg(yf) = " << bs::arg(yf) << '\n';
return 0;
}
Possible output:
---- simd
<- pf = (-1, -0, 0, 1, nan, -nan, inf, -inf)
-> bs::arg(pf) = (3.14159, 3.14159, 0, 0, 0, 3.14159, 0, 3.14159)
<- pf = (-1, -0, 0, 1, nan, -nan, inf, -inf)
-> bs::pedantic_(bs::arg)(pf) = (3.14159, 3.14159, 0, 0, -nan, -nan, 0, 3.14159)
scalar
---- scalar
<- xf = 1
-> bs::arg(xf) = 0
<- yf = -1
-> bs::arg(yf) = 3.14159