Back to index

glibc  2.9
Functions
s_ctanh.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 __ctanh (__complex__ double x)

Function Documentation

__complex__ double __ctanh ( __complex__ double  x)

Definition at line 29 of file s_ctanh.c.

{
  __complex__ double res;

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

#ifdef FE_INVALID
         if (__isinf (__imag__ x))
           feraiseexcept (FE_INVALID);
#endif
       }
    }
  else
    {
      double sin2ix, cos2ix;
      double den;

      __sincos (2.0 * __imag__ x, &sin2ix, &cos2ix);

      den = (__ieee754_cosh (2.0 * __real__ x) + cos2ix);

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

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

  return res;
}

Here is the call graph for this function: