Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/C/atan2.c
+++ new/usr/src/lib/libm/common/C/atan2.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
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
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
20 20 */
21 +
21 22 /*
22 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 24 */
25 +
24 26 /*
25 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 28 * Use is subject to license terms.
27 29 */
28 30
29 31 #pragma weak __atan2 = atan2
30 32
31 33 #include "libm.h"
32 34
33 35 /*
34 36 * Let t(0) = 1 and for i = 1, ..., 160, let t(i) be the slope of
35 37 * the line bisecting the conical hull of the set of points (x,y)
36 38 * where x and y are positive normal floating point numbers and
37 39 * the high order words hx and hy of their binary representations
38 40 * satisfy |hx - hy - i * 0x8000| <= 0x4000. Then:
39 41 *
40 42 * TBL[4*i+2] is t(i) rounded to 21 significant bits (i.e., the
41 43 * low order word is zero), and
42 44 *
43 45 * TBL[4*i] + TBL[4*i+1] form a doubled-double approximation to
44 46 * atan(TBL[4*i+2]).
45 47 *
46 48 * Finally, TBL[4*161] = TBL[4*161+1] = TBL[4*161+2] = 0.
47 49 *
48 50 * Now for any (x,y) with 0 < y <= x and any 0 < t <= 1, we have
49 51 * atan(y/x) = atan(t) + atan((y-t*x)/(x+t*y)). By choosing t =
50 52 * TBL[4*i+2], where i is the multiple of 0x8000 nearest hx - hy,
51 53 * if this multiple is less than 161, and i = 161 otherwise, we
52 54 * find that |(y-t*x)/(x+t*y)| <~ 2^-5.
53 55 */
54 56 static const double TBL[] = {
55 57 7.8539816339744827900e-01, +3.0616169978683830179e-17,
56 58 1.0000000000000000000e+00, +0,
57 59 7.7198905126506112140e-01, +2.6989956960083153652e-16,
58 60 9.7353506088256835938e-01, +0,
59 61 7.6068143954461309164e-01, -3.5178810518941914972e-16,
60 62 9.5174932479858398438e-01, +0,
61 63 7.4953661876353638860e-01, -3.2548100004524337476e-16,
62 64 9.3073129653930664062e-01, +0,
63 65 7.3854614984728339522e-01, -2.0775571023910406668e-16,
64 66 9.1042709350585937500e-01, +0,
65 67 7.2770146962041337702e-01, +3.8883249403168348802e-16,
66 68 8.9078664779663085938e-01, +0,
67 69 7.1699492488093774512e-01, -4.0468841511547224071e-16,
68 70 8.7176513671875000000e-01, +0,
69 71 7.0641813488653149022e-01, +5.6902424353981484031e-17,
70 72 8.5331964492797851562e-01, +0,
71 73 6.9596351101035658360e-01, +2.8245513321075021303e-16,
72 74 8.3541154861450195312e-01, +0,
73 75 6.8562363680534943455e-01, -4.2316970721658854064e-16,
74 76 8.1800508499145507812e-01, +0,
75 77 6.7539055666438230219e-01, +4.3535917281300047233e-16,
76 78 8.0106592178344726562e-01, +0,
77 79 6.6525763346931832132e-01, +1.1830431602404727977e-17,
78 80 7.8456401824951171875e-01, +0,
79 81 6.5521767574310185722e-01, -1.7435923100651044208e-16,
80 82 7.6847028732299804688e-01, +0,
81 83 6.4526390999481897381e-01, -1.4741927403093983947e-16,
82 84 7.5275802612304687500e-01, +0,
83 85 6.3538979894204850041e-01, +1.5734535069995660853e-16,
84 86 7.3740243911743164062e-01, +0,
85 87 6.2558914346942717799e-01, -2.8175588856316910960e-16,
86 88 7.2238063812255859375e-01, +0,
87 89 6.1585586476157949676e-01, -4.3056167357725226449e-16,
88 90 7.0767116546630859375e-01, +0,
89 91 6.0618408027576098362e-01, +1.5018013918429320289e-16,
90 92 6.9325399398803710938e-01, +0,
91 93 5.9656817827486730010e-01, +5.5271942033557644157e-17,
92 94 6.7911052703857421875e-01, +0,
93 95 5.8700289083426504533e-01, -8.2411369282676383293e-17,
94 96 6.6522359848022460938e-01, +0,
95 97 5.7748303053627658699e-01, +4.9400383775709159558e-17,
96 98 6.5157699584960937500e-01, +0,
97 99 5.6800353968303252117e-01, +2.9924431103311109543e-16,
98 100 6.3815546035766601562e-01, +0,
99 101 5.5855953863493823519e-01, -2.0306003403868777403e-16,
100 102 6.2494468688964843750e-01, +0,
101 103 5.4914706708329674711e-01, +2.8255378613779667461e-17,
102 104 6.1193227767944335938e-01, +0,
103 105 5.3976176660618069292e-01, +1.6370248781078747995e-16,
104 106 5.9910583496093750000e-01, +0,
105 107 5.3039888601412332747e-01, -7.6196097360093680134e-17,
106 108 5.8645296096801757812e-01, +0,
107 109 5.2105543924318808990e-01, -2.2400815668154739561e-16,
108 110 5.7396411895751953125e-01, +0,
109 111 5.1172778873967050828e-01, -3.6888136019899681185e-16,
110 112 5.6162929534912109375e-01, +0,
111 113 5.0241199666452196482e-01, -2.5412891474397011281e-16,
112 114 5.4943847656250000000e-01, +0,
113 115 4.9310493954293743712e-01, +4.4132186128251152229e-16,
114 116 5.3738307952880859375e-01, +0,
115 117 4.8380436844750995817e-01, -2.7844387907776656488e-16,
116 118 5.2545595169067382812e-01, +0,
117 119 4.7450670361463753721e-01, -2.0494355197368286028e-16,
118 120 5.1364850997924804688e-01, +0,
119 121 4.6367660027976320691e-01, +3.1709878607954760668e-16,
120 122 5.0003623962402343750e-01, +0,
121 123 4.5304753104003925301e-01, +3.3593436122420574865e-16,
122 124 4.8681926727294921875e-01, +0,
123 125 4.4423658037407065535e-01, +2.1987183192008082015e-17,
124 126 4.7596645355224609375e-01, +0,
125 127 4.3567016972500294258e-01, +3.0118422805369552650e-16,
126 128 4.6550178527832031250e-01, +0,
127 129 4.2733152672544871820e-01, -3.2667693224866479909e-16,
128 130 4.5539522171020507812e-01, +0,
129 131 4.1920540176693954493e-01, -2.2454273841113897647e-16,
130 132 4.4561982154846191406e-01, +0,
131 133 4.1127722812701872357e-01, -3.1620568973494653391e-16,
132 134 4.3615055084228515625e-01, +0,
133 135 4.0353384063084263289e-01, -3.5932009901481421723e-16,
134 136 4.2696499824523925781e-01, +0,
135 137 3.9596319345246833166e-01, -4.0281533417458698585e-16,
136 138 4.1804289817810058594e-01, +0,
137 139 3.8855405220339722661e-01, +1.6132231486045176674e-16,
138 140 4.0936565399169921875e-01, +0,
139 141 3.8129566313738116889e-01, +1.7684657060650804570e-16,
140 142 4.0091586112976074219e-01, +0,
141 143 3.7417884791401867517e-01, +2.6897604227426977619e-16,
142 144 3.9267849922180175781e-01, +0,
143 145 3.6719421967585041955e-01, -4.5886151448673745001e-17,
144 146 3.8463878631591796875e-01, +0,
145 147 3.6033388248727771241e-01, +1.5804115573136074946e-16,
146 148 3.7678408622741699219e-01, +0,
147 149 3.5358982224579182940e-01, +1.2624619863035782939e-16,
148 150 3.6910200119018554688e-01, +0,
149 151 3.4695498404186952968e-01, +9.3221684607372865177e-17,
150 152 3.6158156394958496094e-01, +0,
151 153 3.4042268308109679964e-01, +2.7697913559445449137e-16,
152 154 3.5421252250671386719e-01, +0,
153 155 3.3398684598563566084e-01, +3.6085337449716011085e-16,
154 156 3.4698557853698730469e-01, +0,
155 157 3.2764182824591436827e-01, +2.0581506352606456186e-16,
156 158 3.3989214897155761719e-01, +0,
157 159 3.2138200938788497041e-01, -1.9015787485430693661e-16,
158 160 3.3292388916015625000e-01, +0,
159 161 3.1520245348069497737e-01, +2.6961839659264087022e-16,
160 162 3.2607340812683105469e-01, +0,
161 163 3.0909871873117023000e-01, -1.5641891686756272625e-16,
162 164 3.1933403015136718750e-01, +0,
163 165 3.0306644308947827682e-01, +2.8801634211591956223e-16,
164 166 3.1269931793212890625e-01, +0,
165 167 2.9710135482774191473e-01, -4.3148994478973365819e-16,
166 168 3.0616307258605957031e-01, +0,
167 169 2.9120015759141004708e-01, -6.8539854790808585159e-17,
168 170 2.9972028732299804688e-01, +0,
169 171 2.8535879880370362827e-01, -1.2231638445300492682e-16,
170 172 2.9336524009704589844e-01, +0,
171 173 2.7957422506893880865e-01, -4.6707752931043135528e-17,
172 174 2.8709340095520019531e-01, +0,
173 175 2.7384352102802367313e-01, -4.1215636366229625876e-16,
174 176 2.8090047836303710938e-01, +0,
175 177 2.6816369484161040049e-01, -2.3700583122400495333e-16,
176 178 2.7478218078613281250e-01, +0,
177 179 2.6253212627627764419e-01, +2.3123213692190889610e-16,
178 180 2.6873469352722167969e-01, +0,
179 181 2.5694635355759309903e-01, -4.0638513814701264145e-16,
180 182 2.6275444030761718750e-01, +0,
181 183 2.5140385572454615470e-01, -3.4795333793554943723e-16,
182 184 2.5683784484863281250e-01, +0,
183 185 2.4500357070096612233e-01, +6.6542334848010259289e-17,
184 186 2.5002646446228027344e-01, +0,
185 187 2.3877766609573036760e-01, -2.7756633678549343650e-16,
186 188 2.4342155456542968750e-01, +0,
187 189 2.3365669377188336142e-01, +3.2700803838522067998e-16,
188 190 2.3800384998321533203e-01, +0,
189 191 2.2870810463931334766e-01, -4.4279127662219799521e-16,
190 192 2.3278105258941650391e-01, +0,
191 193 2.2391820542294382790e-01, +3.7558889374284208052e-16,
192 194 2.2773718833923339844e-01, +0,
193 195 2.1927501815429550902e-01, -1.4829838176513811186e-16,
194 196 2.2285830974578857422e-01, +0,
195 197 2.1476740847367459253e-01, -2.0535381496063397578e-17,
196 198 2.1813154220581054688e-01, +0,
197 199 2.1038568111737454558e-01, -4.2826767738736168650e-16,
198 200 2.1354568004608154297e-01, +0,
199 201 2.0612057974373865221e-01, +4.2108051749502232359e-16,
200 202 2.0909011363983154297e-01, +0,
201 203 2.0196410359405447821e-01, +3.5157118083511092869e-16,
202 204 2.0475566387176513672e-01, +0,
203 205 1.9790861144712756925e-01, +3.7894950972257700994e-16,
204 206 2.0053362846374511719e-01, +0,
205 207 1.9394752160084305359e-01, +2.8270367403478935534e-16,
206 208 1.9641649723052978516e-01, +0,
207 209 1.9007440763641536563e-01, -2.0842758095683676397e-16,
208 210 1.9239699840545654297e-01, +0,
209 211 1.8628369629742813629e-01, +3.4710917040399448932e-16,
210 212 1.8846881389617919922e-01, +0,
211 213 1.8256998712939509488e-01, +1.1053834120570125251e-16,
212 214 1.8462586402893066406e-01, +0,
213 215 1.7892875067284830237e-01, +3.0486232913366680305e-16,
214 216 1.8086302280426025391e-01, +0,
215 217 1.7535529778449010507e-01, -2.3810135019970148624e-16,
216 218 1.7717504501342773438e-01, +0,
217 219 1.7184559192514736736e-01, +5.1432582846210893916e-17,
218 220 1.7355740070343017578e-01, +0,
219 221 1.6839590847744290159e-01, +3.1605623296041433586e-18,
220 222 1.7000591754913330078e-01, +0,
221 223 1.6500283902547518977e-01, +1.5405422268770998251e-16,
222 224 1.6651678085327148438e-01, +0,
223 225 1.6166306303174859949e-01, +4.0042241517254928672e-16,
224 226 1.6308629512786865234e-01, +0,
225 227 1.5837358268281231943e-01, -2.2786616251622967291e-16,
226 228 1.5971112251281738281e-01, +0,
227 229 1.5513160990288810126e-01, -3.7547723514797166336e-16,
228 230 1.5638816356658935547e-01, +0,
229 231 1.5193468535499299321e-01, +4.3497510505554267446e-16,
230 232 1.5311467647552490234e-01, +0,
231 233 1.4878033155427861089e-01, -2.3102860235324261895e-16,
232 234 1.4988791942596435547e-01, +0,
233 235 1.4566628729590647140e-01, +9.9227592950040279415e-17,
234 236 1.4670538902282714844e-01, +0,
235 237 1.4259050967286590605e-01, -3.3869909683813096906e-18,
236 238 1.4356482028961181641e-01, +0,
237 239 1.3955105903633846509e-01, +1.5500435650773331566e-17,
238 240 1.4046406745910644531e-01, +0,
239 241 1.3654610022831903393e-01, +3.3965918616682805753e-16,
240 242 1.3740110397338867188e-01, +0,
241 243 1.3357402082462854764e-01, +2.7572431581527535421e-16,
242 244 1.3437414169311523438e-01, +0,
243 245 1.3063319828908959153e-01, -3.4667213797076707331e-16,
244 246 1.3138139247894287109e-01, +0,
245 247 1.2772200049776749609e-01, +3.1089261947725651968e-16,
246 248 1.2842106819152832031e-01, +0,
247 249 1.2436931430778752627e-01, -4.0654251891464630059e-16,
248 250 1.2501454353332519531e-01, +0,
249 251 1.2111683701666819957e-01, -3.9381654342464836012e-16,
250 252 1.2171256542205810547e-01, +0,
251 253 1.1844801833536511282e-01, -3.6673155595150283444e-16,
252 254 1.1900508403778076172e-01, +0,
253 255 1.1587365536613614125e-01, -1.5026628801318421951e-16,
254 256 1.1639505624771118164e-01, +0,
255 257 1.1338607085741525538e-01, +1.2886806274050538880e-16,
256 258 1.1387449502944946289e-01, +0,
257 259 1.1097844020819369604e-01, +2.3848343623577768044e-16,
258 260 1.1143630743026733398e-01, +0,
259 261 1.0864456107308662069e-01, +4.2065430313285469408e-16,
260 262 1.0907405614852905273e-01, +0,
261 263 1.0637891628473727934e-01, -4.6883543790348472687e-18,
262 264 1.0678201913833618164e-01, +0,
263 265 1.0417650062205296990e-01, +1.4774925414624453292e-16,
264 266 1.0455501079559326172e-01, +0,
265 267 1.0203276464730581807e-01, -1.5677032794816452332e-16,
266 268 1.0238832235336303711e-01, +0,
267 269 9.9943617083734892503e-02, +3.4511310907979792828e-16,
268 270 1.0027772188186645508e-01, +0,
269 271 9.7905249824711049200e-02, +3.4489485563461708496e-16,
270 272 9.8219275474548339844e-02, +0,
271 273 9.5914316649349906641e-02, -1.3214510886789011569e-17,
272 274 9.6209526062011718750e-02, +0,
273 275 9.3967698614664918466e-02, +1.1048427091217964090e-16,
274 276 9.4245254993438720703e-02, +0,
275 277 9.2062564267554769515e-02, -3.7297463814697759309e-16,
276 278 9.2323541641235351562e-02, +0,
277 279 9.0196252506350660383e-02, -3.5280143043576718079e-16,
278 280 9.0441644191741943359e-02, +0,
279 281 8.8366391663268650802e-02, -6.1140673227541621183e-17,
280 282 8.8597118854522705078e-02, +0,
281 283 8.6570782100201526532e-02, -2.0998844594957629702e-16,
282 284 8.6787700653076171875e-02, +0,
283 285 8.4807337678923566671e-02, +3.9530981588194673068e-16,
284 286 8.5011243820190429688e-02, +0,
285 287 8.3074323040850828193e-02, -4.3022503210464894539e-17,
286 288 8.3265960216522216797e-02, +0,
287 289 8.1369880712663267275e-02, -6.3063867569127169744e-18,
288 290 8.1549942493438720703e-02, +0,
289 291 7.9692445771216036121e-02, -5.0787623072962671502e-17,
290 292 7.9861581325531005859e-02, +0,
291 293 7.8040568735575632786e-02, -3.8810063021216721741e-16,
292 294 7.8199386596679687500e-02, +0,
293 295 7.6412797391314235540e-02, +4.1246529500495762995e-16,
294 296 7.6561868190765380859e-02, +0,
295 297 7.4807854772808823896e-02, -3.7025599052186724156e-16,
296 298 7.4947714805603027344e-02, +0,
297 299 7.3224639528778112663e-02, +4.2209138483206712401e-17,
298 300 7.3355793952941894531e-02, +0,
299 301 7.1661929761571485642e-02, -3.2074473649855177622e-16,
300 302 7.1784853935241699219e-02, +0,
301 303 7.0118738881148168218e-02, -2.5371257235753296804e-16,
302 304 7.0233881473541259766e-02, +0,
303 305 6.8594137996416115755e-02, +3.3796987842548399135e-16,
304 306 6.8701922893524169922e-02, +0,
305 307 6.7087137393172291411e-02, +5.5061492696328852397e-17,
306 308 6.7187964916229248047e-02, +0,
307 309 6.5596983299946565182e-02, -2.1580863111502565280e-16,
308 310 6.5691232681274414062e-02, +0,
309 311 6.4122802037412718335e-02, -3.1315661827469233434e-16,
310 312 6.4210832118988037109e-02, +0,
311 313 6.2426231582525915087e-02, -2.5758980071296622188e-16,
312 314 6.2507450580596923828e-02, +0,
313 315 6.0781559928021700046e-02, +1.3736899336217710591e-16,
314 316 6.0856521129608154297e-02, +0,
315 317 5.9432882624005145544e-02, +2.2246097394328856474e-16,
316 318 5.9502959251403808594e-02, +0,
317 319 5.8132551274581167888e-02, -6.2525053236379489390e-18,
318 320 5.8198124170303344727e-02, +0,
319 321 5.6876611930681164608e-02, -2.6589930995607417149e-16,
320 322 5.6938022375106811523e-02, +0,
321 323 5.5661522654748551986e-02, -4.2736362859832186197e-16,
322 324 5.5719077587127685547e-02, +0,
323 325 5.4484124463757943602e-02, -1.6708067365310384253e-16,
324 326 5.4538100957870483398e-02, +0,
325 327 5.3341582449436764080e-02, +3.3271673004611311850e-17,
326 328 5.3392231464385986328e-02, +0,
327 329 5.2231267345892007370e-02, -3.5593396674200571616e-16,
328 330 5.2278816699981689453e-02, +0,
329 331 5.1150874758829623090e-02, +1.4432815841187114832e-16,
330 332 5.1195532083511352539e-02, +0,
331 333 5.0098306612679444072e-02, +9.4680943793589404083e-17,
332 334 5.0140261650085449219e-02, +0,
333 335 4.9071641675614507960e-02, +2.1131168520301896817e-16,
334 336 4.9111068248748779297e-02, +0,
335 337 4.8069135772851545596e-02, +1.6035336741307516296e-16,
336 338 4.8106193542480468750e-02, +0,
337 339 4.7089192241088539959e-02, -2.2491738698796901479e-16,
338 340 4.7124028205871582031e-02, +0,
339 341 4.6130362086062248750e-02, -1.5111423469578965206e-16,
340 342 4.6163111925125122070e-02, +0,
341 343 4.5191314382707403752e-02, +4.1989325207399786612e-16,
342 344 4.5222103595733642578e-02, +0,
343 345 4.4270836390474244126e-02, -4.1432635292331004454e-16,
344 346 4.4299781322479248047e-02, +0,
345 347 4.3367774164955186222e-02, -3.0615383054587355892e-16,
346 348 4.3394982814788818359e-02, +0,
347 349 4.2481121875321825598e-02, -3.6730166956273555173e-16,
348 350 4.2506694793701171875e-02, +0,
349 351 4.1609902899457651415e-02, -4.4226425958068821782e-16,
350 352 4.1633933782577514648e-02, +0,
351 353 4.0753259129372665370e-02, +1.9801161516527046872e-16,
352 354 4.0775835514068603516e-02, +0,
353 355 3.9910361780060910064e-02, +8.2560620036613164573e-18,
354 356 3.9931565523147583008e-02, +0,
355 357 3.9080441183869218946e-02, +3.9908991939242971628e-17,
356 358 3.9100348949432373047e-02, +0,
357 359 3.8262816593271686827e-02, +9.5182237812195590276e-17,
358 360 3.8281500339508056641e-02, +0,
359 361 3.7456806948784837630e-02, +1.5213508760679563439e-16,
360 362 3.7474334239959716797e-02, +0,
361 363 3.6661849947035918262e-02, +7.3335516005184616486e-17,
362 364 3.6678284406661987305e-02, +0,
363 365 3.5877353272533163420e-02, -1.3007348019891714540e-16,
364 366 3.5892754793167114258e-02, +0,
365 367 3.5102754135096780885e-02, -2.9903662298950558656e-16,
366 368 3.5117179155349731445e-02, +0,
367 369 3.4337638360670830195e-02, +2.9656295131966114331e-16,
368 370 3.4351140260696411133e-02, +0,
369 371 3.3581472523789734907e-02, +3.4810947205572817820e-16,
370 372 3.3594101667404174805e-02, +0,
371 373 3.2833871859357266487e-02, -3.8885440174405159838e-16,
372 374 3.2845675945281982422e-02, +0,
373 375 3.2094421679560447558e-02, +5.8805134853032009978e-17,
374 376 3.2105445861816406250e-02, +0,
375 377 3.1243584858944295490e-02, +2.8737383773884313066e-17,
376 378 3.1253755092620849609e-02, +0,
377 379 0, 0, 0, 0
378 380 };
379 381
380 382 static const double C[] = {
381 383 0.0,
382 384 0.125,
383 385 1.2980742146337069071e+33,
384 386 7.8539816339744827900e-01,
↓ open down ↓ |
351 lines elided |
↑ open up ↑ |
385 387 1.5707963267948965580e+00,
386 388 6.1232339957367658860e-17,
387 389 -3.1415926535897931160e+00,
388 390 -1.2246467991473531772e-16,
389 391 -3.33333333333327571893331786354179101074860633009e-0001,
390 392 +1.99999999942671624230086497610394721817438631379e-0001,
391 393 -1.42856965565428636896183013324727205980484158356e-0001,
392 394 +1.10894981496317081405107718475040168084164825641e-0001,
393 395 };
394 396
395 -#define zero C[0]
396 -#define twom3 C[1]
397 -#define two110 C[2]
398 -#define pio4 C[3]
399 -#define pio2 C[4]
400 -#define pio2_lo C[5]
401 -#define mpi C[6]
402 -#define mpi_lo C[7]
403 -#define p1 C[8]
404 -#define p2 C[9]
405 -#define p3 C[10]
406 -#define p4 C[11]
397 +#define zero C[0]
398 +#define twom3 C[1]
399 +#define two110 C[2]
400 +#define pio4 C[3]
401 +#define pio2 C[4]
402 +#define pio2_lo C[5]
403 +#define mpi C[6]
404 +#define mpi_lo C[7]
405 +#define p1 C[8]
406 +#define p2 C[9]
407 +#define p3 C[10]
408 +#define p4 C[11]
407 409
408 410 double
409 -atan2(double oy, double ox) {
410 - double ah, al, t, xh, x, y, z;
411 - int i, k, hx, hy, sx, sy;
411 +atan2(double oy, double ox)
412 +{
413 + double ah, al, t, xh, x, y, z;
414 + int i, k, hx, hy, sx, sy;
415 +
412 416 #ifndef lint
413 - volatile int inexact __unused;
417 + volatile int inexact __unused;
414 418 #endif
415 419
416 420 hy = ((int *)&oy)[HIWORD];
417 421 sy = hy & 0x80000000;
418 422 hy &= ~0x80000000;
419 423
420 424 hx = ((int *)&ox)[HIWORD];
421 425 sx = hx & 0x80000000;
422 426 hx &= ~0x80000000;
423 427
424 428 if (hy > hx || (hy == hx && ((unsigned *)&oy)[LOWORD] >
425 429 ((unsigned *)&ox)[LOWORD])) {
426 430 i = hx;
427 431 hx = hy;
428 432 hy = i;
429 433 x = fabs(oy);
430 434 y = fabs(ox);
435 +
431 436 if (sx) {
432 437 ah = pio2;
433 438 al = pio2_lo;
434 439 } else {
435 440 ah = -pio2;
436 441 al = -pio2_lo;
437 442 sy ^= 0x80000000;
438 443 }
439 444 } else {
440 445 x = fabs(ox);
441 446 y = fabs(oy);
447 +
442 448 if (sx) {
443 449 ah = mpi;
444 450 al = mpi_lo;
445 451 sy ^= 0x80000000;
446 452 } else {
447 453 ah = al = zero;
448 454 }
449 455 }
450 456
451 457 if (hx >= 0x7fe00000 || hx - hy >= 0x03600000) {
452 458 if (hx >= 0x7ff00000) {
453 459 if (((hx ^ 0x7ff00000) | ((int *)&x)[LOWORD]) != 0)
454 460 return (ox * oy);
461 +
455 462 if (hy >= 0x7ff00000)
456 463 ah += pio4;
464 +
457 465 #ifndef lint
458 466 inexact = (int)ah; /* inexact if ah != 0 */
459 467 #endif
460 - return ((sy)? -ah : ah);
468 + return ((sy) ? -ah : ah);
461 469 }
470 +
462 471 if (hx - hy >= 0x03600000) {
463 472 if ((int)ah == 0)
464 473 ah = y / x;
465 - return ((sy)? -ah : ah);
474 +
475 + return ((sy) ? -ah : ah);
466 476 }
477 +
467 478 y *= twom3;
468 479 x *= twom3;
469 480 hy -= 0x00300000;
470 481 hx -= 0x00300000;
471 482 } else if (hy < 0x00100000) {
472 483 if ((hy | ((int *)&y)[LOWORD]) == 0) {
473 484 if ((hx | ((int *)&x)[LOWORD]) == 0)
474 485 return (_SVID_libm_err(ox, oy, 3));
486 +
475 487 #ifndef lint
476 488 inexact = (int)ah; /* inexact if ah != 0 */
477 489 #endif
478 - return ((sy)? -ah : ah);
490 + return ((sy) ? -ah : ah);
479 491 }
492 +
480 493 y *= two110;
481 494 x *= two110;
482 495 hy = ((int *)&y)[HIWORD];
483 496 hx = ((int *)&x)[HIWORD];
484 497 }
485 498
486 499 k = (((hx - hy) + 0x00004000) >> 13) & ~0x3;
500 +
487 501 if (k > 644)
488 502 k = 644;
503 +
489 504 ah += TBL[k];
490 - al += TBL[k+1];
491 - t = TBL[k+2];
505 + al += TBL[k + 1];
506 + t = TBL[k + 2];
492 507
493 508 xh = x;
494 509 ((int *)&xh)[LOWORD] = 0;
495 510 z = ((y - t * xh) - t * (x - xh)) / (x + y * t);
496 511 x = z * z;
497 512 t = ah + (z + (al + (z * x) * (p1 + x * (p2 + x * (p3 + x * p4)))));
498 - return ((sy)? -t : t);
513 + return ((sy) ? -t : t);
499 514 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX