4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #pragma weak __csinh = csinh
34 * dcomplex csinh(dcomplex z);
37 * e - e e (cos(y)+i*sin(y)) - e (cos(-y)+i*sin(-y))
38 * sinh z = -------------- = ---------------------------------------------
41 * cos(y) ( e - e ) + i*sin(y) (e + e )
42 * = --------------------------------------------
45 * = cos(y) sinh(x) + i sin(y) cosh(x)
50 * |x| -|x| |x| -2|x| -2|x| -P-4
51 * Note that e +- e = e ( 1 +- e ). If e < 2 , where
53 * P stands for the number of significant bits of the machine precision,
55 * then the result will be rounded to e . Therefore, we have
59 * sinh z = ----- if |x| >= (P/2 + 2)*ln2
62 * EXCEPTION (conform to ISO/IEC 9899:1999(E)):
64 * csinh(0,inf)=(+-0,NaN)
65 * csinh(0,NaN)=(+-0,NaN)
66 * csinh(x,inf) = (NaN,NaN) for finite positive x
67 * csinh(x,NaN) = (NaN,NaN) for finite non-zero x
68 * csinh(inf,0) = (inf, 0)
69 * csinh(inf,y) = (inf*cos(y),inf*sin(y)) for positive finite y
70 * csinh(inf,inf) = (+-inf,NaN)
71 * csinh(inf,NaN) = (+-inf,NaN)
72 * csinh(NaN,0) = (NaN,0)
73 * csinh(NaN,y) = (NaN,NaN) for non-zero y
74 * csinh(NaN,NaN) = (NaN,NaN)
78 #include "libm.h" /* cosh/exp/fabs/scalbn/sinh/sincos/__k_cexp */
79 #include "complex_wrapper.h"
84 int hx
, ix
, lx
, hy
, iy
, ly
, n
;
98 (void) sincos(y
, &S
, &C
);
99 if (ix
>= 0x403c0000) { /* |x| > 28 = prec/2 (14,28,34,60) */
100 if (ix
>= 0x40862E42) { /* |x| > 709.78... ~ log(2**1024) */
101 if (ix
>= 0x7ff00000) { /* |x| is inf or NaN */
102 if ((iy
| ly
) == 0) {
105 } else if (iy
>= 0x7ff00000) {
113 /* return exp(x)=t*2**n */
115 D_RE(ans
) = scalbn(C
* t
, n
- 1);
116 D_IM(ans
) = scalbn(S
* t
, n
- 1);
124 if ((ix
| lx
) == 0) { /* x = 0, return (0,S) */
128 D_RE(ans
) = C
* sinh(x
);
129 D_IM(ans
) = S
* cosh(x
);
133 D_RE(ans
) = -D_RE(ans
);
135 D_IM(ans
) = -D_IM(ans
);