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/SCCS/s.vatanf.c $ $Revision: 1.5 $";
00060
00061 #include "libm.h"
00062
00063 #if defined(mips) && !defined(__GNUC__)
00064 extern void vfatan(float *, float *, long, long, long);
00065 extern void vatanf(float *, float *, long, long, long);
00066
00067 #pragma weak vfatan = __vatanf
00068 #pragma weak vatanf = __vatanf
00069 #endif
00070
00071 #if defined(BUILD_OS_DARWIN)
00072 extern void __vatanf( float *x, float *y, long count, long stridex,
00073 long stridey );
00074 #pragma weak vatanf
00075 void vatanf( float *x, float *y, long count, long stridex, long stridey ) {
00076 __vatanf(x, y, count, stridex, stridey);
00077 }
00078 #elif defined(__GNUC__)
00079 extern void __vatanf(float *, float *, long, long, long);
00080 void vatanf() __attribute__ ((weak, alias ("__vatanf")));
00081 #endif
00082
00083
00084
00085 static const du P[] =
00086 {
00087 {D(0x3ff00000, 0x00000000)},
00088 {D(0xbfd55554, 0xfa93267a)},
00089 {D(0x3fc9992a, 0x5f168922)},
00090 {D(0xbfc233d7, 0x10c23920)},
00091 {D(0x3fb92edf, 0xe7e2c83b)},
00092 };
00093
00094
00095
00096 static const du xk[] =
00097 {
00098 {D(0x00000000, 0x00000000)},
00099 {D(0x3fe00000, 0x00000000)},
00100 {D(0x3ff00000, 0x00000000)},
00101 {D(0x3ff80000, 0x00000000)},
00102 {D(0x40000000, 0x00000000)},
00103 {D(0x40040000, 0x00000000)},
00104 {D(0x40080000, 0x00000000)},
00105 {D(0x400c0000, 0x00000000)},
00106 {D(0x40100000, 0x00000000)},
00107 };
00108
00109
00110
00111 static const du yk[] =
00112 {
00113 {D(0x00000000, 0x00000000)},
00114 {D(0x3fddac67, 0x0561bb4f)},
00115 {D(0x3fe921fb, 0x54442d18)},
00116 {D(0x3fef730b, 0xd281f69b)},
00117 {D(0x3ff1b6e1, 0x92ebbe44)},
00118 {D(0x3ff30b6d, 0x796a4da8)},
00119 {D(0x3ff3fc17, 0x6b7a8560)},
00120 {D(0x3ff4ae10, 0xfc6589a5)},
00121 {D(0x3ff5368c, 0x951e9cfd)},
00122 };
00123
00124 static const du Twopm28 =
00125 {D(0x3e300000, 0x00000000)};
00126
00127 static const du Twop26 =
00128 {D(0x41900000, 0x00000000)};
00129
00130 static const fu Qnan = {QNANF};
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 void
00143 __vatanf( float *x, float *y, long count, long stridex, long stridey )
00144 {
00145 long i;
00146 int j;
00147 float arg;
00148 float result;
00149 double dx, w;
00150 double z, zsq;
00151 double u, poly;
00152
00153
00154
00155 for ( i=0; i<count; i++ )
00156 {
00157 #ifdef _PREFETCH
00158 #pragma prefetch_ref=*(x+8)
00159 #pragma prefetch_ref=*(y+8)
00160 #endif
00161
00162 arg = *x;
00163
00164
00165
00166 dx = fabsf(arg);
00167
00168 if ( arg != arg )
00169 dx = 0.0;
00170
00171
00172
00173 if ( dx > Twop26.d )
00174 dx = Twop26.d;
00175
00176 w = dx;
00177
00178
00179
00180 if ( dx > 4.0 )
00181 w = 4.0;
00182
00183 j = ROUND(w+w);
00184
00185 z = (dx - xk[j].d)/(1.0 + dx*xk[j].d);
00186
00187
00188
00189 u = z;
00190
00191
00192
00193 if ( fabs(z) < Twopm28.d )
00194 u = 0.0;
00195
00196 zsq = u*u;
00197
00198 poly = (((P[4].d*zsq + P[3].d)*zsq + P[2].d)*zsq +
00199 P[1].d)*(zsq*z) + z;
00200
00201 result = yk[j].d + poly;
00202
00203 if ( arg < 0.0f )
00204 result = -result;
00205
00206 if ( arg != arg )
00207 result = Qnan.f;
00208
00209 *y = result;
00210
00211 x += stridex;
00212 y += stridey;
00213 }
00214 }
00215