Back to index

glibc  2.9
s_ccos.c
Go to the documentation of this file.
00001 /* Return cosine of complex double value.
00002    Copyright (C) 1997 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <complex.h>
00022 #include <fenv.h>
00023 #include <math.h>
00024 
00025 
00026 __complex__ double
00027 __ccos (__complex__ double x)
00028 {
00029   __complex__ double res;
00030 
00031   if (!isfinite (__real__ x) || __isnan (__imag__ x))
00032     {
00033       if (__real__ x == 0.0 || __imag__ x == 0.0)
00034        {
00035          __real__ res = __nan ("");
00036          __imag__ res = 0.0;
00037 
00038 #ifdef FE_INVALID
00039          if (__isinf (__real__ x))
00040            feraiseexcept (FE_INVALID);
00041 #endif
00042        }
00043       else if (__isinf (__imag__ x))
00044        {
00045          __real__ res = HUGE_VAL;
00046          __imag__ res = __nan ("");
00047 
00048 #ifdef FE_INVALID
00049          if (__isinf (__real__ x))
00050            feraiseexcept (FE_INVALID);
00051 #endif
00052        }
00053       else
00054        {
00055          __real__ res = __nan ("");
00056          __imag__ res = __nan ("");
00057 
00058 #ifdef FE_INVALID
00059          if (isfinite (__imag__ x))
00060            feraiseexcept (FE_INVALID);
00061 #endif
00062        }
00063     }
00064   else
00065     {
00066       __complex__ double y;
00067 
00068       __real__ y = -__imag__ x;
00069       __imag__ y = __real__ x;
00070 
00071       res = __ccosh (y);
00072     }
00073 
00074   return res;
00075 }
00076 weak_alias (__ccos, ccos)
00077 #ifdef NO_LONG_DOUBLE
00078 strong_alias (__ccos, __ccosl)
00079 weak_alias (__ccos, ccosl)
00080 #endif