]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/generic/s_ccoshf.c
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[thirdparty/glibc.git] / sysdeps / generic / s_ccoshf.c
CommitLineData
993b3242
UD
1/* Complex cosine hyperbole function for float.
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__ float
29__ccoshf (__complex__ float x)
30{
31 __complex__ float 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 float sinh_val = __ieee754_sinhf (__real__ x);
63551311 42 float cosh_val = __ieee754_coshf (__real__ x);
7799b7b3 43 float sinix, cosix;
993b3242 44
7799b7b3
UD
45 __sincosf (__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 52 __imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf ("");
779ae82e
UD
53 __real__ retval = __nanf ("");
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_VALF;
0a54e401 68 __imag__ retval = __imag__ x * __copysignf (1.0, __real__ x);
993b3242 69 }
63551311 70 else if (icls > FP_ZERO)
993b3242 71 {
63551311 72 /* Imaginary part is finite. */
7799b7b3
UD
73 float sinix, cosix;
74
75 __sincosf (__imag__ x, &sinix, &cosix);
76
77 __real__ retval = __copysignf (HUGE_VALF, cosix);
0a54e401
UD
78 __imag__ retval = (__copysignf (HUGE_VALF, sinix)
79 * __copysignf (1.0, __real__ x));
993b3242
UD
80 }
81 else
82 {
83 /* The addition raises the invalid exception. */
84 __real__ retval = HUGE_VALF;
85 __imag__ retval = __nanf ("") + __nanf ("");
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 = __nanf ("");
96 __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf ("");
993b3242
UD
97 }
98
99 return retval;
100}
1705f0a3 101#ifndef __ccoshf
993b3242 102weak_alias (__ccoshf, ccoshf)
1705f0a3 103#endif