00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 static char *rcs_id = "$Source: /home/bos/bk/kpro64-pending/libm/mips/SCCS/s.atanf.c $ $Revision: 1.5 $";
00060
00061 #ifdef _CALL_MATHERR
00062 #include <stdio.h>
00063 #include <math.h>
00064 #include <errno.h>
00065 #endif
00066
00067 #include "libm.h"
00068
00069 #if defined(mips) && !defined(__GNUC__)
00070 extern float fatan(float);
00071 extern float atanf(float);
00072
00073 #pragma weak fatan = __atanf
00074 #pragma weak atanf = __atanf
00075 #endif
00076
00077 #if defined(BUILD_OS_DARWIN)
00078 extern float __atanf(float);
00079 #pragma weak atanf
00080 float atanf( float x ) {
00081 return __atanf( x );
00082 }
00083 #elif defined(__GNUC__)
00084 extern float __atanf(float);
00085 float atanf(float) __attribute__ ((weak, alias ("__atanf")));
00086 #endif
00087
00088
00089
00090 static const du P[] =
00091 {
00092 {D(0x4033b1f1, 0x5145e7e8)},
00093 {D(0x4036468d, 0x2d72b575)},
00094 {D(0x4016a439, 0x0afa7438)},
00095 {D(0x3fc69c34, 0x97688a95)},
00096 };
00097
00098 static const du Q[] =
00099 {
00100 {D(0x4033b1f1, 0x5145e7e8)},
00101 {D(0x403cd732, 0xd729eaa7)},
00102 {D(0x4026ab7d, 0x65d9a7a4)},
00103 {D(0x3ff00000, 0x00000000)},
00104 };
00105
00106
00107
00108 static const du P2[] =
00109 {
00110 {D(0x3f825e40, 0xbe79ec0c)},
00111 {D(0x3fd264c4, 0x2019db77)},
00112 {D(0x3ff218ab, 0x3c579116)},
00113 {D(0x3ff00000, 0x00000000)},
00114 };
00115
00116 static const du Q2[] =
00117 {
00118 {D(0x3fa9ff0f, 0x6b64219d)},
00119 {D(0x3fe26aab, 0x734ccc2a)},
00120 {D(0x3ff76e00, 0x7ae4fafe)},
00121 {D(0x3ff00000, 0x00000000)},
00122 };
00123
00124 static const du piby2 =
00125 {D(0x3ff921fb, 0x54442d18)};
00126
00127 static const fu Qnan = {QNANF};
00128
00129 static const fu fpiby2 =
00130 {0x3fc90fdb};
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 float
00143 __atanf( float x )
00144 {
00145 int ix, xpt;
00146 double dx, xsq, num, denom;
00147 float result;
00148 #ifdef _CALL_MATHERR
00149 struct exception exstruct;
00150 #endif
00151
00152 FLT2INT(x, ix);
00153 xpt = (ix >> MANTWIDTH);
00154 xpt &= 0xff;
00155
00156 if ( xpt < 0x7f )
00157 {
00158
00159
00160 dx = x;
00161
00162 if ( xpt >= 0x73 )
00163 {
00164
00165
00166 xsq = dx*dx;
00167
00168 num = ((P[3].d*xsq + P[2].d)*xsq + P[1].d)*xsq + P[0].d;
00169
00170 denom = ((xsq + Q[2].d)*xsq + Q[1].d)*xsq + Q[0].d;
00171
00172 result = (x*num)/denom;
00173
00174 return ( result );
00175 }
00176
00177 return (x);
00178 }
00179
00180 if ( xpt < 0x98 )
00181 {
00182
00183
00184
00185
00186
00187
00188 dx = fabsf(x);
00189
00190 xsq = dx*dx;
00191
00192 num = ((xsq + P2[2].d)*xsq + P2[1].d)*xsq + P2[0].d;
00193
00194 denom = ((xsq + Q2[2].d)*xsq + Q2[1].d)*xsq + Q2[0].d;
00195
00196 result = piby2.d - num/(dx*denom);
00197
00198 if ( x < (float)0.0 )
00199 result = -result;
00200
00201 return ( result );
00202 }
00203
00204 if ( x != x )
00205 {
00206
00207
00208 #ifdef _CALL_MATHERR
00209
00210 exstruct.type = DOMAIN;
00211 exstruct.name = "atanf";
00212 exstruct.arg1 = x;
00213 exstruct.retval = Qnan.f;
00214
00215 if ( matherr( &exstruct ) == 0 )
00216 {
00217 fprintf(stderr, "domain error in atanf\n");
00218 SETERRNO(EDOM);
00219 }
00220
00221 return ( exstruct.retval );
00222 #else
00223 NAN_SETERRNO(EDOM);
00224
00225 return ( Qnan.f );
00226 #endif
00227 }
00228
00229 result = fpiby2.f;
00230
00231 if ( x < (float)0.0 )
00232 result = -result;
00233
00234 return ( result );
00235
00236 }
00237