E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ atan2

eve::atan2 = functor<atan2_t>
inlineconstexpr

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
template< eve::floating_value T eve::floating_value U>
auto atan2(T x, U y) noexcept;
}
constexpr auto atan2
Callable object computing the arc tangent using the signs of arguments to determine the correct quadr...
Definition: atan2.hpp:99
EVE Main Namespace.
Definition: abi.hpp:18

Parameters

x, y: floating real values

Return value

the arc tangent of \(\frac{y}x\) in the range \([-\pi , +\pi]\) radians, is returned. The IEEE limiting values are almost all satisfied :

  • If x and y are both zero or infinites, Nan is returned (this is not standard conforming)
  • If y is \(\pm0\) and x is strictly negative or \(-0\), \(\pm\pi\) is returned
  • If y is \(\pm0\) and x is strictly positive or \(+0\), \(\pm0\) is returned
  • If y is \(\pm\infty\) and x is finite, \(\pm\frac\pi2\) is returned
  • If x is \(\pm0\) and y is strictly negative, \(-\frac\pi2\) is returned
  • If x is \(\pm0\) and y is strictly positive, \(+\frac\pi2\) is returned
  • If x is \(-\infty\) and y is finite and positive, \(+\pi\) is returned
  • If x is \(-\infty\) and y is finite and negative, \(-\pi\) is returned
  • If x is \(+\infty\) and y is finite and positive, \(+0\) is returned
  • If x is \(+\infty\) and y is finite and negative, \(-0\) is returned
  • If either x is Nan or y is Nan, Nan is returned

    The call will return a NaN if x and y are both either null or infinite: this result is not IEEE conformant, but allows to simplify (and speed) the implementation. In all other cases, the result is standard conformant.

    The result type is the common value type of the two parameters.

Example

#include <eve/module/math.hpp>
#include <eve/wide.hpp>
#include <iostream>
using wide_ft = eve::wide <float, eve::fixed<4>>;
int main()
{
wide_ft pf = { 0.0f, 1.0f, 4.0f, -2.0f };
wide_ft qf = { 1.0f, -1.0f, 3.0f, -0.0f};
std::cout
<< "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> atan2(pf, qf) = " << eve::atan2(pf, qf) << '\n'
;
float xf = 2.0f;
float yf = 10.0f;
std::cout
<< "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "-> atan2(xf, yf) = " << eve::atan2(xf, yf) << '\n';
return 0;
}

Semantic Modifiers

  • eve::pedantic

    The call pedantic(atan2)(x,y) returns the same results as the regular call, but all IEEE limiting values are satisfied :

    • If y is \(\pm\infty\) and x is \(-\infty\), \(\pm\frac{3\pi}4\) is returned
    • If y is \(\pm\infty\) and x is \(+\infty\), \(\pm\frac{\pi}4\) is returned
    • If x is \(\pm0\) and y is \(\pm-0\), \(-\frac\pi2\) is returned
    • If x is \(\pm0\) and y is \(\pm+0\), \(+\frac\pi2\) is returned