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.
31 #define restrict _Restrict
36 extern const double __vlibm_TBL_atan1
[];
39 pio4
= 7.8539816339744827900e-01,
40 pio2
= 1.5707963267948965580e+00,
41 pi
= 3.1415926535897931160e+00;
46 q1
= -3.3333333333296428046e-01f
,
47 q2
= 1.9999999186853752618e-01f
,
51 __vatan2f(int n
, float * restrict y
, int stridey
, float * restrict x
,
52 int stridex
, float * restrict z
, int stridez
)
54 float x0
, x1
, x2
, y0
, y1
, y2
, *pz0
= 0, *pz1
, *pz2
;
58 double sign0
, sign1
, sign2
;
59 int i
, k0
= 0, k1
, k2
, hx
, sx
, sy
;
61 float base0
= 0.0, base1
, base2
;
62 double num0
, num1
, num2
;
63 double den0
, den1
, den2
;
74 sy
= hy0
& 0x80000000;
122 if (hx
>= 0x7f800000 || hx
- hy0
>= 0x0c800000)
124 if (hx
>= 0x7f800000)
126 if (hx
^ 0x7f800000) /* nan */
128 else if (hy0
>= 0x7f800000)
131 else if ((int) ah0
== 0)
133 *z
= (sign0
== one
) ? ah0
: -ah0
;
134 /* sign0*ah0 would change nan behavior relative to previous release */
143 if (hy0
< 0x00800000) {
146 *z
= sign0
* (float) ah0
;
155 y0
*= twop24
; /* scale subnormal y */
156 x0
*= twop24
; /* scale possibly subnormal x */
162 k0
= (hy0
- hx
+ 0x3f800000) & 0xfff80000;
163 if (k0
>= 0x3C800000) /* if |x| >= (1/64)... */
166 k0
= (k0
- 0x3C800000) >> 18; /* (index >> 19) << 1) */
168 /* skip over 0,0,pi/2,pi/2 */
170 else /* |x| < 1/64 */
188 sy
= hy1
& 0x80000000;
191 sx
= hx
& 0x80000000;
236 if (hx
>= 0x7f800000 || hx
- hy1
>= 0x0c800000)
238 if (hx
>= 0x7f800000)
240 if (hx
^ 0x7f800000) /* nan */
242 else if (hy1
>= 0x7f800000)
245 else if ((int) ah1
== 0)
247 *z
= (sign1
== one
)? ah1
: -ah1
;
256 if (hy1
< 0x00800000) {
259 *z
= sign1
* (float) ah1
;
268 y1
*= twop24
; /* scale subnormal y */
269 x1
*= twop24
; /* scale possibly subnormal x */
275 k1
= (hy1
- hx
+ 0x3f800000) & 0xfff80000;
276 if (k1
>= 0x3C800000) /* if |x| >= (1/64)... */
279 k1
= (k1
- 0x3C800000) >> 18; /* (index >> 19) << 1) */
281 /* skip over 0,0,pi/2,pi/2 */
283 else /* |x| < 1/64 */
300 sy
= hy2
& 0x80000000;
303 sx
= hx
& 0x80000000;
348 if (hx
>= 0x7f800000 || hx
- hy2
>= 0x0c800000)
350 if (hx
>= 0x7f800000)
352 if (hx
^ 0x7f800000) /* nan */
354 else if (hy2
>= 0x7f800000)
357 else if ((int) ah2
== 0)
359 *z
= (sign2
== one
)? ah2
: -ah2
;
368 if (hy2
< 0x00800000) {
371 *z
= sign2
* (float) ah2
;
380 y2
*= twop24
; /* scale subnormal y */
381 x2
*= twop24
; /* scale possibly subnormal x */
388 k2
= (hy2
- hx
+ 0x3f800000) & 0xfff80000;
389 if (k2
>= 0x3C800000) /* if |x| >= (1/64)... */
392 k2
= (k2
- 0x3C800000) >> 18; /* (index >> 19) << 1) */
394 /* skip over 0,0,pi/2,pi/2 */
396 else /* |x| < 1/64 */
406 ah2
+= __vlibm_TBL_atan1
[k2
];
407 ah1
+= __vlibm_TBL_atan1
[k1
];
408 ah0
+= __vlibm_TBL_atan1
[k0
];
420 num2
= dy2
- dx2
* db2
;
421 den2
= dx2
+ dy2
* db2
;
423 num1
= dy1
- dx1
* db1
;
424 den1
= dx1
+ dy1
* db1
;
426 num0
= dy0
- dx0
* db0
;
427 den0
= dx0
+ dy0
* db0
;
437 t2
+= t2
* sx2
* (q1
+ sx2
* q2
);
438 t1
+= t1
* sx1
* (q1
+ sx1
* q2
);
439 t0
+= t0
* sx0
* (q1
+ sx0
* q2
);
457 ah1
+= __vlibm_TBL_atan1
[k1
];
458 t1
= (y1
- x1
* (double)base1
) /
459 (x1
+ y1
* (double)base1
);
461 t1
+= t1
* sx1
* (q1
+ sx1
* q2
);
468 ah0
+= __vlibm_TBL_atan1
[k0
];
469 t0
= (y0
- x0
* (double)base0
) /
470 (x0
+ y0
* (double)base0
);
472 t0
+= t0
* sx0
* (q1
+ sx0
* q2
);