Back to index

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

Function Documentation

__complex__ double __csin ( __complex__ double  x)

Definition at line 29 of file s_csin.c.

{
  __complex__ double retval;
  int negate = signbit (__real__ x);
  int rcls = fpclassify (__real__ x);
  int icls = fpclassify (__imag__ x);

  __real__ x = fabs (__real__ x);

  if (icls >= FP_ZERO)
    {
      /* Imaginary part is finite.  */
      if (rcls >= FP_ZERO)
       {
         /* Real part is finite.  */
         double sinh_val = __ieee754_sinh (__imag__ x);
         double cosh_val = __ieee754_cosh (__imag__ x);
         double sinix, cosix;

         __sincos (__real__ x, &sinix, &cosix);

         __real__ retval = cosh_val * sinix;
         __imag__ retval = sinh_val * cosix;

         if (negate)
           __real__ retval = -__real__ retval;
       }
      else
       {
         if (icls == FP_ZERO)
           {
             /* Imaginary part is 0.0.  */
             __real__ retval = __nan ("");
             __imag__ retval = __imag__ x;

#ifdef FE_INVALID
             if (rcls == FP_INFINITE)
              feraiseexcept (FE_INVALID);
#endif
           }
         else
           {
             __real__ retval = __nan ("");
             __imag__ retval = __nan ("");

#ifdef FE_INVALID
             feraiseexcept (FE_INVALID);
#endif
           }
       }
    }
  else if (icls == FP_INFINITE)
    {
      /* Imaginary part is infinite.  */
      if (rcls == FP_ZERO)
       {
         /* Real part is 0.0.  */
         __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
         __imag__ retval = __imag__ x;
       }
      else if (rcls > FP_ZERO)
       {
         /* Real part is finite.  */
         double sinix, cosix;

         __sincos (__real__ x, &sinix, &cosix);

         __real__ retval = __copysign (HUGE_VAL, sinix);
         __imag__ retval = __copysign (HUGE_VAL, cosix);

         if (negate)
           __real__ retval = -__real__ retval;
         if (signbit (__imag__ x))
           __imag__ retval = -__imag__ retval;
       }
      else
       {
         /* The addition raises the invalid exception.  */
         __real__ retval = __nan ("");
         __imag__ retval = HUGE_VAL;

#ifdef FE_INVALID
         if (rcls == FP_INFINITE)
           feraiseexcept (FE_INVALID);
#endif
       }
    }
  else
    {
      if (rcls == FP_ZERO)
       __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
      else
       __real__ retval = __nan ("");
      __imag__ retval = __nan ("");
    }

  return retval;
}

Here is the call graph for this function: