Back to index

glibc  2.9
Functions
s_ctanhf.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__ float __ctanhf (__complex__ float x)

Function Documentation

__complex__ float __ctanhf ( __complex__ float  x)

Definition at line 29 of file s_ctanhf.c.

{
  __complex__ float res;

  if (!isfinite (__real__ x) || !isfinite (__imag__ x))
    {
      if (__isinff (__real__ x))
       {
         __real__ res = __copysignf (1.0, __real__ x);
         __imag__ res = __copysignf (0.0, __imag__ x);
       }
      else if (__imag__ x == 0.0)
       {
         res = x;
       }
      else
       {
         __real__ res = __nanf ("");
         __imag__ res = __nanf ("");

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

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

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

      if (den == 0.0f)
       {
         __complex__ float ez = __cexpf (x);
         __complex__ float emz = __cexpf (-x);

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

  return res;
}

Here is the call graph for this function: