]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/libm-ieee754/s_ccosh.c
Update.
[thirdparty/glibc.git] / sysdeps / libm-ieee754 / s_ccosh.c
CommitLineData
993b3242
UD
1/* Complex cosine hyperbole function for double.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include <complex.h>
22#include <math.h>
23
24
25__complex__ double
26__ccosh (__complex__ double x)
27{
28 __complex__ double retval;
29
30 __real__ x = fabs (__real__ x);
31
32 if (isfinite (__real__ x))
33 {
34 if (isfinite (__imag__ x))
35 {
36 double exp_val = __exp (__real__ x);
37 double rec_exp_val = 1.0 / exp_val;
38
39 __real__ retval = 0.5 * (exp_val + rec_exp_val) * __cos (__imag__ x);
40 __imag__ retval = 0.5 * (exp_val + rec_exp_val) * __sin (__imag__ x);
41 }
42 else
43 {
44 if (__real__ x == 0)
45 {
46 __imag__ retval = 0.0;
47 __real__ retval = __nan ("") + __nan ("");
48 }
49 else
50 {
51 __real__ retval = __nan ("");
52 __imag__ retval = __nan ("") + __nan ("");
53 }
54 }
55 }
56 else if (__isinf (__real__ x))
57 {
58 if (__imag__ x == 0.0)
59 {
60 __real__ retval = HUGE_VAL;
61 __imag__ retval = __imag__ x;
62 }
63 else if (isfinite (__imag__ x))
64 {
65 __real__ retval = __copysign (HUGE_VAL, __cos (__imag__ x));
66 __imag__ retval = __copysign (HUGE_VAL, __sin (__imag__ x));
67 }
68 else
69 {
70 /* The addition raises the invalid exception. */
71 __real__ retval = HUGE_VAL;
72 __imag__ retval = __nan ("") + __nan ("");
73 }
74 }
75 else
76 {
77 if (__imag__ x == 0.0)
78 {
79 __real__ retval = __nan ("");
80 __imag__ retval = __imag__ x;
81 }
82 else
83 {
84 __real__ retval = __nan ("");
85 __imag__ retval = __nan ("");
86 }
87 }
88
89 return retval;
90}
91weak_alias (__ccosh, ccosh)
92#ifdef NO_LONG_DOUBLE
93strong_alias (__ccosh, __ccoshl)
94weak_alias (__ccosh, ccoshl)
95#endif