Back to index

glibc  2.9
Functions
s_ctan.c File Reference
#include <complex.h>
#include <fenv.h>
#include <math.h>
#include "math_private.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

__complex__ double __ctan (__complex__ double x)

Function Documentation

__complex__ double __ctan ( __complex__ double  x)

Definition at line 29 of file s_ctan.c.

{
  __complex__ double res;

  if (!isfinite (__real__ x) || !isfinite (__imag__ x))
    {
      if (__isinf (__imag__ x))
       {
         __real__ res = __copysign (0.0, __real__ x);
         __imag__ res = __copysign (1.0, __imag__ x);
       }
      else if (__real__ x == 0.0)
       {
         res = x;
       }
      else
       {
         __real__ res = __nan ("");
         __imag__ res = __nan ("");

#ifdef FE_INVALID
         if (__isinf (__real__ x))
           feraiseexcept (FE_INVALID);
#endif
       }
    }
  else
    {
      double sin2rx, cos2rx;
      double den;

      __sincos (2.0 * __real__ x, &sin2rx, &cos2rx);

      den = cos2rx + __ieee754_cosh (2.0 * __imag__ x);

      if (den == 0.0)
       {
         __complex__ double ez = __cexp (1.0i * x);
         __complex__ double emz = __cexp (-1.0i * x);

         res = (ez - emz) / (ez + emz) * -1.0i;
       }
      else
       {
         __real__ res = sin2rx / den;
         __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den;
       }
    }

  return res;
}

Here is the call graph for this function: