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 #include <sys/isa_defs.h>
31 #include "libm_inlines.h"
34 #define HI(x) *(1+(int*)x)
35 #define LO(x) *(unsigned*)x
37 #define HI(x) *(int*)x
38 #define LO(x) *(1+(unsigned*)x)
42 #define restrict _Restrict
47 extern const double __vlibm_TBL_atan2
[];
53 two110
= 1.2980742146337069071e+33,
54 pio4
= 7.8539816339744827900e-01,
55 pio2
= 1.5707963267948965580e+00,
56 pio2_lo
= 6.1232339957367658860e-17,
57 pi
= 3.1415926535897931160e+00,
58 pi_lo
= 1.2246467991473531772e-16,
59 p1
= -3.33333333333327571893331786354179101074860633009e-0001,
60 p2
= 1.99999999942671624230086497610394721817438631379e-0001,
61 p3
= -1.42856965565428636896183013324727205980484158356e-0001,
62 p4
= 1.10894981496317081405107718475040168084164825641e-0001;
64 /* Don't __ the following; acomp will handle it */
65 extern double fabs(double);
68 __vatan2(int n
, double * restrict y
, int stridey
, double * restrict x
,
69 int stridex
, double * restrict z
, int stridez
)
71 double x0
, x1
, x2
, y0
, y1
, y2
, *pz0
, *pz1
, *pz2
;
72 double ah0
, ah1
, ah2
, al0
, al1
, al2
, t0
, t1
, t2
;
73 double z0
, z1
, z2
, sign0
, sign1
, sign2
, xh
;
74 int i
, k
, hx
, hy
, sx
, sy
;
82 sign0
= (sy
)? -one
: one
;
88 if (hy
> hx
|| (hy
== hx
&& LO(y
) > LO(x
)))
121 if (hx
>= 0x7fe00000 || hx
- hy
>= 0x03600000)
123 if (hx
>= 0x7ff00000)
125 if ((hx
^ 0x7ff00000) | LO(&x0
)) /* nan */
127 else if (hy
>= 0x7ff00000)
138 if (hx
- hy
>= 0x03600000)
156 else if (hy
< 0x00100000)
158 if ((hy
| LO(&y0
)) == 0)
175 k
= (((hx
- hy
) + 0x00004000) >> 13) & ~0x3;
178 ah0
+= __vlibm_TBL_atan2
[k
];
179 al0
+= __vlibm_TBL_atan2
[k
+1];
180 t0
= __vlibm_TBL_atan2
[k
+2];
184 z0
= ((y0
- t0
* xh
) - t0
* (x0
- xh
)) / (x0
+ y0
* t0
);
195 sy
= hy
& 0x80000000;
197 sign1
= (sy
)? -one
: one
;
200 sx
= hx
& 0x80000000;
203 if (hy
> hx
|| (hy
== hx
&& LO(y
) > LO(x
)))
236 if (hx
>= 0x7fe00000 || hx
- hy
>= 0x03600000)
238 if (hx
>= 0x7ff00000)
240 if ((hx
^ 0x7ff00000) | LO(&x1
)) /* nan */
242 else if (hy
>= 0x7ff00000)
253 if (hx
- hy
>= 0x03600000)
271 else if (hy
< 0x00100000)
273 if ((hy
| LO(&y1
)) == 0)
290 k
= (((hx
- hy
) + 0x00004000) >> 13) & ~0x3;
293 ah1
+= __vlibm_TBL_atan2
[k
];
294 al1
+= __vlibm_TBL_atan2
[k
+1];
295 t1
= __vlibm_TBL_atan2
[k
+2];
299 z1
= ((y1
- t1
* xh
) - t1
* (x1
- xh
)) / (x1
+ y1
* t1
);
310 sy
= hy
& 0x80000000;
312 sign2
= (sy
)? -one
: one
;
315 sx
= hx
& 0x80000000;
318 if (hy
> hx
|| (hy
== hx
&& LO(y
) > LO(x
)))
351 if (hx
>= 0x7fe00000 || hx
- hy
>= 0x03600000)
353 if (hx
>= 0x7ff00000)
355 if ((hx
^ 0x7ff00000) | LO(&x2
)) /* nan */
357 else if (hy
>= 0x7ff00000)
368 if (hx
- hy
>= 0x03600000)
386 else if (hy
< 0x00100000)
388 if ((hy
| LO(&y2
)) == 0)
405 k
= (((hx
- hy
) + 0x00004000) >> 13) & ~0x3;
408 ah2
+= __vlibm_TBL_atan2
[k
];
409 al2
+= __vlibm_TBL_atan2
[k
+1];
410 t2
= __vlibm_TBL_atan2
[k
+2];
414 z2
= ((y2
- t2
* xh
) - t2
* (x2
- xh
)) / (x2
+ y2
* t2
);
421 t0
= ah0
+ (z0
+ (al0
+ (z0
* x0
) * (p1
+ x0
*
422 (p2
+ x0
* (p3
+ x0
* p4
)))));
423 t1
= ah1
+ (z1
+ (al1
+ (z1
* x1
) * (p1
+ x1
*
424 (p2
+ x1
* (p3
+ x1
* p4
)))));
425 t2
= ah2
+ (z2
+ (al2
+ (z2
* x2
) * (p1
+ x2
*
426 (p2
+ x2
* (p3
+ x2
* p4
)))));
443 t1
= ah1
+ (z1
+ (al1
+ (z1
* x1
) * (p1
+ x1
*
444 (p2
+ x1
* (p3
+ x1
* p4
)))));
449 t0
= ah0
+ (z0
+ (al0
+ (z0
* x0
) * (p1
+ x0
*
450 (p2
+ x0
* (p3
+ x0
* p4
)))));