Example #1
0
__complex128
catanhq (__complex128 x)
{
  __complex128 res;
  int rcls = fpclassifyq (__real__ x);
  int icls = fpclassifyq (__imag__ x);

  if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE)
    {
      if (icls == QUADFP_INFINITE)
	{
	  __real__ res = copysignq (0.0, __real__ x);
	  __imag__ res = copysignq (M_PI_2q, __imag__ x);
	}
      else if (rcls == QUADFP_INFINITE || rcls == QUADFP_ZERO)
	{
	  __real__ res = copysignq (0.0, __real__ x);
	  if (icls >= QUADFP_ZERO)
	    __imag__ res = copysignq (M_PI_2q, __imag__ x);
	  else
	    __imag__ res = nanq ("");
	}
      else
	{
	  __real__ res = nanq ("");
	  __imag__ res = nanq ("");
	}
    }
  else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO)
    {
      res = x;
    }
  else
    {
      __float128 i2, num, den;

      i2 = __imag__ x * __imag__ x;

      num = 1.0 + __real__ x;
      num = i2 + num * num;

      den = 1.0 - __real__ x;
      den = i2 + den * den;

      __real__ res = 0.25 * (logq (num) - logq (den));

      den = 1 - __real__ x * __real__ x - i2;

      __imag__ res = 0.5 * atan2q (2.0 * __imag__ x, den);
    }

  return res;
}
Example #2
0
inline void eval_atan2(float128_backend& result, const float128_backend& a, const float128_backend& b)
{
   result.value() = atan2q(a.value(), b.value());
}
__float128
cargq (__complex128 z)
{
  return atan2q (IMAGPART (z), REALPART (z));
}