]>
Commit | Line | Data |
---|---|---|
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 | |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
993b3242 UD |
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 | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
993b3242 | 15 | |
41bdb6e2 AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
993b3242 UD |
20 | |
21 | #include <complex.h> | |
779ae82e | 22 | #include <fenv.h> |
993b3242 UD |
23 | #include <math.h> |
24 | ||
63551311 UD |
25 | #include "math_private.h" |
26 | ||
993b3242 UD |
27 | |
28 | __complex__ double | |
29 | __ccosh (__complex__ double x) | |
30 | { | |
31 | __complex__ double retval; | |
63551311 UD |
32 | int rcls = fpclassify (__real__ x); |
33 | int icls = fpclassify (__imag__ x); | |
993b3242 | 34 | |
63551311 | 35 | if (rcls >= FP_ZERO) |
993b3242 | 36 | { |
63551311 UD |
37 | /* Real part is finite. */ |
38 | if (icls >= FP_ZERO) | |
993b3242 | 39 | { |
63551311 | 40 | /* Imaginary part is finite. */ |
779ae82e | 41 | double sinh_val = __ieee754_sinh (__real__ x); |
63551311 | 42 | double cosh_val = __ieee754_cosh (__real__ x); |
7799b7b3 | 43 | double sinix, cosix; |
993b3242 | 44 | |
7799b7b3 UD |
45 | __sincos (__imag__ x, &sinix, &cosix); |
46 | ||
47 | __real__ retval = cosh_val * cosix; | |
779ae82e | 48 | __imag__ retval = sinh_val * sinix; |
993b3242 UD |
49 | } |
50 | else | |
51 | { | |
63551311 UD |
52 | __imag__ retval = __real__ x == 0.0 ? 0.0 : __nan (""); |
53 | __real__ retval = __nan ("") + __nan (""); | |
779ae82e UD |
54 | |
55 | #ifdef FE_INVALID | |
56 | if (icls == FP_INFINITE) | |
57 | feraiseexcept (FE_INVALID); | |
58 | #endif | |
993b3242 UD |
59 | } |
60 | } | |
63551311 | 61 | else if (rcls == FP_INFINITE) |
993b3242 | 62 | { |
63551311 UD |
63 | /* Real part is infinite. */ |
64 | if (icls == FP_ZERO) | |
993b3242 | 65 | { |
63551311 | 66 | /* Imaginary part is 0.0. */ |
993b3242 | 67 | __real__ retval = HUGE_VAL; |
0a54e401 | 68 | __imag__ retval = __imag__ x * __copysign (1.0, __real__ x); |
993b3242 | 69 | } |
63551311 | 70 | else if (icls > FP_ZERO) |
993b3242 | 71 | { |
63551311 | 72 | /* Imaginary part is finite. */ |
7799b7b3 UD |
73 | double sinix, cosix; |
74 | ||
75 | __sincos (__imag__ x, &sinix, &cosix); | |
76 | ||
77 | __real__ retval = __copysign (HUGE_VAL, cosix); | |
0a54e401 UD |
78 | __imag__ retval = (__copysign (HUGE_VAL, sinix) |
79 | * __copysign (1.0, __real__ x)); | |
993b3242 UD |
80 | } |
81 | else | |
82 | { | |
83 | /* The addition raises the invalid exception. */ | |
84 | __real__ retval = HUGE_VAL; | |
85 | __imag__ retval = __nan ("") + __nan (""); | |
779ae82e UD |
86 | |
87 | #ifdef FE_INVALID | |
88 | if (icls == FP_INFINITE) | |
89 | feraiseexcept (FE_INVALID); | |
90 | #endif | |
993b3242 UD |
91 | } |
92 | } | |
93 | else | |
94 | { | |
63551311 UD |
95 | __real__ retval = __nan (""); |
96 | __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nan (""); | |
993b3242 UD |
97 | } |
98 | ||
99 | return retval; | |
100 | } | |
101 | weak_alias (__ccosh, ccosh) | |
102 | #ifdef NO_LONG_DOUBLE | |
103 | strong_alias (__ccosh, __ccoshl) | |
104 | weak_alias (__ccosh, ccoshl) | |
105 | #endif |