acinclude.m4 (GLIBCPP_CHECK_TARGET): New macro...
[platform/upstream/gcc.git] / libstdc++-v3 / libmath / csinhf.c
1 /* Complex sine hyperbole function for float.
2    Copyright (C) 1997,1998 Free Software Foundation, Inc.
3
4    This file is part of the libstdc++ version 3 distribution.
5
6    This software is a copyrighted work licensed under the terms of the
7    Cygnus libstdc++ license. Please consult the file LICENSE.STD for
8    details.  */
9
10 #include <math.h>
11 #include "mathconf.h"
12
13
14 __complex__ float
15 csinhf (__complex__ float x)
16 {
17   __complex__ float retval;
18   int negate = signbit (__real__ x);
19
20   __real__ x = fabsf (__real__ x);
21
22   if (FINITEF_P (__real__ x))
23     {
24       /* Real part is finite.  */
25       if (FINITEF_P (__imag__ x))
26         {
27           /* Imaginary part is finite.  */
28           float sinh_val = sinhf (__real__ x);
29           float cosh_val = coshf (__real__ x);
30           float sinix = sin (__imag__ x);
31           float cosix = cos (__imag__ x);
32
33           __real__ retval = sinh_val * cosix;
34           __imag__ retval = cosh_val * sinix;
35
36           if (negate)
37             __real__ retval = -__real__ retval;
38         }
39       else
40         {
41           if (__real__ x == 0.0)
42             {
43               /* Real part is 0.0.  */
44               __real__ retval = copysignf (0.0, negate ? -1.0 : 1.0);
45               __imag__ retval = NAN + NAN;
46             }
47           else
48             {
49               __real__ retval = NAN;
50               __imag__ retval = NAN;
51             }
52         }
53     }
54   else if (INFINITEF_P (__real__ x))
55     {
56       /* Real part is infinite.  */
57       if (__imag__ x == 0.0)
58         {
59           /* Imaginary part is 0.0.  */
60           __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
61           __imag__ retval = __imag__ x;
62         }
63       else if (FINITEF_P (__imag__ x))
64         {
65           /* Imaginary part is finite.  */
66           float sinix = sinf (__imag__ x);
67           float cosix = cosf (__imag__ x);
68
69           __real__ retval = copysignf (HUGE_VALF, cosix);
70           __imag__ retval = copysignf (HUGE_VALF, sinix);
71
72           if (negate)
73             __real__ retval = -__real__ retval;
74         }
75       else
76         {
77           /* The addition raises the invalid exception.  */
78           __real__ retval = HUGE_VALF;
79           __imag__ retval = NAN + NAN;
80         }
81     }
82   else
83     {
84       __real__ retval = NAN;
85       __imag__ retval = __imag__ x == 0.0 ? __imag__ x : NAN;
86     }
87
88   return retval;
89 }