1 /* Return arc hyperbole sine for float value, with the imaginary part
2 of the result possibly adjusted for use in computing other
4 Copyright (C) 1997-2013 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
23 #include <math_private.h>
26 /* Return the complex inverse hyperbolic sine of finite nonzero Z,
27 with the imaginary part of the result subtracted from pi/2 if ADJ
31 __kernel_casinhf (__complex__
float x
, int adj
)
33 __complex__
float res
;
37 /* Avoid cancellation by reducing to the first quadrant. */
38 rx
= fabsf (__real__ x
);
39 ix
= fabsf (__imag__ x
);
41 if (rx
>= 1.0f
/ FLT_EPSILON
|| ix
>= 1.0f
/ FLT_EPSILON
)
43 /* For large x in the first quadrant, x + csqrt (1 + x * x)
44 is sufficiently close to 2 * x to make no significant
45 difference to the result; avoid possible overflow from
46 the squaring and addition. */
53 __real__ y
= __copysignf (__imag__ y
, __imag__ x
);
58 __real__ res
+= (float) M_LN2
;
60 else if (rx
>= 0.5f
&& ix
< FLT_EPSILON
/ 8.0f
)
62 float s
= __ieee754_hypotf (1.0f
, rx
);
64 __real__ res
= __ieee754_logf (rx
+ s
);
66 __imag__ res
= __ieee754_atan2f (s
, __imag__ x
);
68 __imag__ res
= __ieee754_atan2f (ix
, s
);
70 else if (rx
< FLT_EPSILON
/ 8.0f
&& ix
>= 1.5f
)
72 float s
= __ieee754_sqrtf ((ix
+ 1.0f
) * (ix
- 1.0f
));
74 __real__ res
= __ieee754_logf (ix
+ s
);
76 __imag__ res
= __ieee754_atan2f (rx
, __copysignf (s
, __imag__ x
));
78 __imag__ res
= __ieee754_atan2f (s
, rx
);
82 __real__ y
= (rx
- ix
) * (rx
+ ix
) + 1.0;
83 __imag__ y
= 2.0 * rx
* ix
;
93 __real__ y
= __copysignf (__imag__ y
, __imag__ x
);
100 /* Give results the correct sign for the original argument. */
101 __real__ res
= __copysignf (__real__ res
, __real__ x
);
102 __imag__ res
= __copysignf (__imag__ res
, (adj
? 1.0f
: __imag__ x
));