Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/complex/ccosh.c
+++ new/usr/src/lib/libm/common/complex/ccosh.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#pragma weak ccosh = __ccosh
30 +#pragma weak __ccosh = ccosh
31 31
32 32 /* INDENT OFF */
33 33 /*
34 34 * dcomplex ccosh(dcomplex z);
35 35 *
36 36 * z -z x -x
37 37 * e + e e (cos(y)+i*sin(y)) + e (cos(-y)+i*sin(-y))
38 38 * cosh z = -------------- = ---------------------------------------------
39 39 * 2 2
40 40 * x -x x -x
41 41 * cos(y) ( e + e ) + i*sin(y) (e - e )
42 42 * = --------------------------------------------
43 43 * 2
44 44 *
45 45 * = cos(y) cosh(x) + i sin(y) sinh(x)
46 46 *
47 47 * Implementation Note
48 48 * -------------------
49 49 *
50 50 * |x| -|x| |x| -2|x| -2|x| -P-4
51 51 * Note that e +- e = e ( 1 +- e ). If e < 2 , where
52 52 *
53 53 * P stands for the number of significant bits of the machine precision,
54 54 * |x|
55 55 * then the result will be rounded to e . Therefore, we have
56 56 *
57 57 * z
58 58 * e
59 59 * cosh z = ----- if |x| >= (P/2 + 2)*ln2
60 60 * 2
61 61 *
62 62 * EXCEPTION (conform to ISO/IEC 9899:1999(E)):
63 63 * ccosh(0,0)=(1,0)
64 64 * ccosh(0,inf)=(NaN,+-0)
65 65 * ccosh(0,NaN)=(NaN,+-0)
66 66 * ccosh(x,inf) = (NaN,NaN) for finite non-zero x
67 67 * ccosh(x,NaN) = (NaN,NaN) for finite non-zero x
68 68 * ccosh(inf,0) = (inf, 0)
69 69 * ccosh(inf,y) = (inf*cos(y),inf*sin(y)) for finite non-zero y
70 70 * ccosh(inf,inf) = (+-inf,NaN)
71 71 * ccosh(inf,NaN) = (+inf,NaN)
72 72 * ccosh(NaN,0) = (NaN,+-0)
73 73 * ccosh(NaN,y) = (NaN,NaN) for non-zero y
74 74 * ccosh(NaN,NaN) = (NaN,NaN)
75 75 */
76 76 /* INDENT ON */
77 77
78 78 #include "libm.h" /* cosh/exp/fabs/scalbn/sinh/sincos/__k_cexp */
79 79 #include "complex_wrapper.h"
80 80
81 81 dcomplex
82 82 ccosh(dcomplex z) {
83 83 double t, x, y, S, C;
84 84 int hx, ix, lx, hy, iy, ly, n;
85 85 dcomplex ans;
86 86
87 87 x = D_RE(z);
88 88 y = D_IM(z);
89 89 hx = HI_WORD(x);
90 90 lx = LO_WORD(x);
91 91 ix = hx & 0x7fffffff;
92 92 hy = HI_WORD(y);
93 93 ly = LO_WORD(y);
94 94 iy = hy & 0x7fffffff;
95 95 x = fabs(x);
96 96 y = fabs(y);
97 97
98 98 (void) sincos(y, &S, &C);
99 99 if (ix >= 0x403c0000) { /* |x| > 28 = prec/2 (14,28,34,60) */
100 100 if (ix >= 0x40862E42) { /* |x| > 709.78... ~ log(2**1024) */
101 101 if (ix >= 0x7ff00000) { /* |x| is inf or NaN */
102 102 if ((iy | ly) == 0) {
103 103 D_RE(ans) = x;
104 104 D_IM(ans) = y;
105 105 } else if (iy >= 0x7ff00000) {
106 106 D_RE(ans) = x;
107 107 D_IM(ans) = x - y;
108 108 } else {
109 109 D_RE(ans) = C * x;
110 110 D_IM(ans) = S * x;
111 111 }
112 112 } else {
113 113 t = __k_cexp(x, &n);
114 114 /* return exp(x)=t*2**n */
115 115 D_RE(ans) = scalbn(C * t, n - 1);
116 116 D_IM(ans) = scalbn(S * t, n - 1);
117 117 }
118 118 } else {
119 119 t = exp(x) * 0.5;
120 120 D_RE(ans) = C * t;
121 121 D_IM(ans) = S * t;
122 122 }
123 123 } else {
124 124 if ((ix | lx) == 0) { /* x = 0, return (C,0) */
125 125 D_RE(ans) = C;
126 126 D_IM(ans) = 0.0;
127 127 } else {
128 128 D_RE(ans) = C * cosh(x);
129 129 D_IM(ans) = S * sinh(x);
130 130 }
131 131 }
132 132 if ((hx ^ hy) < 0)
133 133 D_IM(ans) = -D_IM(ans);
134 134 return (ans);
135 135 }
↓ open down ↓ |
95 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX