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.vatan.c $ $Revision: 1.5 $";
00060
00061 #include "libm.h"
00062
00063 #if defined(mips) && !defined(__GNUC__)
00064 extern void vatan(double *, double *, long, long, long);
00065
00066 #pragma weak vatan = __vatan
00067 #endif
00068
00069 #if defined(BUILD_OS_DARWIN)
00070 extern void __vatan( double *x, double *y, long count, long stridex,
00071 long stridey );
00072 #pragma weak vatan
00073 void vatan( double *x, double *y, long count, long stridex, long stridey ) {
00074 __vatan(x, y, count, stridex, stridey);
00075 }
00076 #elif defined(__GNUC__)
00077 extern void __vatan(double *, double *, long, long, long);
00078 void vatan() __attribute__ ((weak, alias ("__vatan")));
00079 #endif
00080
00081
00082
00083 static const du P[] =
00084 {
00085 {D(0x3ff00000, 0x00000000)},
00086 {D(0xbfd55555, 0x555554cc)},
00087 {D(0x3fc99999, 0x99945d66)},
00088 {D(0xbfc24924, 0x89cbb155)},
00089 {D(0x3fbc71ba, 0x706a40b4)},
00090 {D(0xbfb74107, 0x237438a4)},
00091 {D(0x3fb2cc16, 0x060e74d4)},
00092 };
00093
00094
00095
00096 static const du xk[] =
00097 {
00098 {D(0x00000000, 0x00000000)},
00099 {D(0x3fd00000, 0x00000000)},
00100 {D(0x3fe00000, 0x00000000)},
00101 {D(0x3fe80000, 0x00000000)},
00102 {D(0x3ff00000, 0x00000000)},
00103 {D(0x3ff40000, 0x00000000)},
00104 {D(0x3ff80000, 0x00000000)},
00105 {D(0x3ffc0000, 0x00000000)},
00106 {D(0x40000000, 0x00000000)},
00107 {D(0x40020000, 0x00000000)},
00108 {D(0x40040000, 0x00000000)},
00109 {D(0x40060000, 0x00000000)},
00110 {D(0x40080000, 0x00000000)},
00111 {D(0x400a0000, 0x00000000)},
00112 {D(0x400c0000, 0x00000000)},
00113 {D(0x400e0000, 0x00000000)},
00114 {D(0x40100000, 0x00000000)},
00115 {D(0x40110000, 0x00000000)},
00116 {D(0x40120000, 0x00000000)},
00117 {D(0x40130000, 0x00000000)},
00118 {D(0x40140000, 0x00000000)},
00119 {D(0x40150000, 0x00000000)},
00120 {D(0x40160000, 0x00000000)},
00121 {D(0x40170000, 0x00000000)},
00122 {D(0x40180000, 0x00000000)},
00123 {D(0x40190000, 0x00000000)},
00124 {D(0x401a0000, 0x00000000)},
00125 {D(0x401b0000, 0x00000000)},
00126 {D(0x401c0000, 0x00000000)},
00127 {D(0x401d0000, 0x00000000)},
00128 {D(0x401e0000, 0x00000000)},
00129 {D(0x401f0000, 0x00000000)},
00130 {D(0x40200000, 0x00000000)},
00131 };
00132
00133
00134
00135 static const du yk[] =
00136 {
00137 {D(0x00000000, 0x00000000)},
00138 {D(0x3fcf5b75, 0xf92c80dd)},
00139 {D(0x3fddac67, 0x0561bb4f)},
00140 {D(0x3fe4978f, 0xa3269ee1)},
00141 {D(0x3fe921fb, 0x54442d18)},
00142 {D(0x3fecac7c, 0x57846f9e)},
00143 {D(0x3fef730b, 0xd281f69b)},
00144 {D(0x3ff0d38f, 0x2c5ba09f)},
00145 {D(0x3ff1b6e1, 0x92ebbe44)},
00146 {D(0x3ff270ef, 0x55a53a25)},
00147 {D(0x3ff30b6d, 0x796a4da8)},
00148 {D(0x3ff38d6a, 0x6ce13353)},
00149 {D(0x3ff3fc17, 0x6b7a8560)},
00150 {D(0x3ff45b54, 0x837351a0)},
00151 {D(0x3ff4ae10, 0xfc6589a5)},
00152 {D(0x3ff4f68d, 0xea672617)},
00153 {D(0x3ff5368c, 0x951e9cfd)},
00154 {D(0x3ff56f6f, 0x33a3e6a7)},
00155 {D(0x3ff5a250, 0x52114e60)},
00156 {D(0x3ff5d013, 0xc41adabd)},
00157 {D(0x3ff5f973, 0x15254857)},
00158 {D(0x3ff61f06, 0xc6a92b89)},
00159 {D(0x3ff6414d, 0x44094c7c)},
00160 {D(0x3ff660b0, 0x2c736a06)},
00161 {D(0x3ff67d88, 0x63bc99bd)},
00162 {D(0x3ff69821, 0x3a9d5053)},
00163 {D(0x3ff6b0ba, 0xe830c070)},
00164 {D(0x3ff6c78c, 0x7edeb195)},
00165 {D(0x3ff6dcc5, 0x7bb565fd)},
00166 {D(0x3ff6f08f, 0x07435fec)},
00167 {D(0x3ff7030c, 0xf9403197)},
00168 {D(0x3ff7145e, 0xac2088a4)},
00169 {D(0x3ff7249f, 0xaa996a21)},
00170 };
00171
00172 static const du Twop85 =
00173 {D(0x45400000, 0x00000000)};
00174
00175 static const du Twopm28 =
00176 {D(0x3e300000, 0x00000000)};
00177
00178 static const du Qnan =
00179 {D(QNANHI, QNANLO)};
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 void
00192 __vatan( double *x, double *y, long count, long stridex, long stridey )
00193 {
00194 long i;
00195 int j;
00196 double arg;
00197 double dx, w, z, zsq;
00198 double u, poly, result;
00199
00200
00201
00202 for ( i=0; i<count; i++ )
00203 {
00204 #ifdef _PREFETCH
00205 #pragma prefetch_ref=*(x+8)
00206 #pragma prefetch_ref=*(y+8)
00207 #endif
00208
00209 arg = *x;
00210
00211
00212
00213 dx = fabs(arg);
00214
00215 if ( arg != arg )
00216 dx = 0.0;
00217
00218
00219
00220 if ( dx > Twop85.d )
00221 dx = Twop85.d;
00222
00223 w = dx;
00224
00225
00226
00227 if ( dx > 8.0 )
00228 w = 8.0;
00229
00230 j = ROUND(4.0*w);
00231
00232 z = (dx - xk[j].d)/(1.0 + dx*xk[j].d);
00233
00234
00235
00236 u = z;
00237
00238
00239
00240 if ( fabs(z) < Twopm28.d )
00241 u = 0.0;
00242
00243 zsq = u*u;
00244
00245 poly = (((((P[6].d*zsq + P[5].d)*zsq + P[4].d)*zsq +
00246 P[3].d)*zsq + P[2].d)*zsq + P[1].d)*(zsq*z) + z;
00247
00248 result = yk[j].d + poly;
00249
00250 if ( arg < 0.0 )
00251 result = -result;
00252
00253 if ( arg != arg )
00254 result = Qnan.d;
00255
00256 *y = result;
00257
00258 x += stridex;
00259 y += stridey;
00260 }
00261 }
00262