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]
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #pragma weak __catanf = catanf
32 #include "complex_wrapper.h"
34 #if defined(__i386) && !defined(__amd64)
35 extern int __swapRP(int);
39 pi_2
= 1.570796326794896558e+00F
,
48 float x
, y
, ax
, ay
, t
;
61 if (ix
>= 0x7f800000) { /* x is inf or NaN */
62 if (ix
== 0x7f800000) {
67 if (iy
== 0 || iy
== 0x7f800000)
70 F_IM(ans
) = (fabsf(y
) - ay
) / (fabsf(y
) - ay
);
72 } else if (iy
>= 0x7f800000) { /* y is inf or NaN */
73 if (iy
== 0x7f800000) {
77 F_RE(ans
) = (fabsf(x
) - ax
) / (fabsf(x
) - ax
);
85 * A = --- * atan2(2x, 1-x*x-y*y) = --- atan2(0,1-|y|)
88 * 1 [ (y+1)*(y+1) ] 1 2 1 2y
89 * B = - log [ ----------- ] = - log (1+ ---) or - log(1+ ----)
90 * 4 [ (y-1)*(y-1) ] 2 y-1 2 1-y
94 if (iy
== 0x3f800000) {
95 /* y=1: catan(0,1)=(0,+inf) with 1/0 signal */
98 } else if (iy
> 0x3f800000) { /* y>1 */
99 F_IM(ans
) = half
* log1pf(two
/ (-t
));
102 F_IM(ans
) = half
* log1pf((ay
+ ay
) / t
);
108 * use double precision x,y
110 * A = --- * atan2(2x, 1-x*x-y*y)
113 * 1 [ x*x+(y+1)*(y+1) ] 1 4y
114 * B = - log [ --------------- ] = - log (1+ -----------------)
115 * 4 [ x*x+(y-1)*(y-1) ] 4 x*x + (y-1)*(y-1)
118 #if defined(__i386) && !defined(__amd64)
119 int rp
= __swapRP(fp_extended
);
123 F_RE(ans
) = (float)(0.5 * atan2(dx
+ dx
,
124 1.0 - dx
* dx
- dy
* dy
));
126 F_IM(ans
) = (float)(0.25 * log1p(4.0 * dy
/
127 (dx
* dx
+ dt
* dt
)));
128 #if defined(__i386) && !defined(__amd64)
129 if (rp
!= fp_extended
)
134 F_RE(ans
) = -F_RE(ans
);
136 F_IM(ans
) = -F_IM(ans
);