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.vtan.c $ $Revision: 1.5 $";
00060
00061 #include "libm.h"
00062
00063 #if defined(mips) && !defined(__GNUC__)
00064 extern void vtan(double *, double *, long, long, long);
00065
00066 #pragma weak vtan = __vtan
00067 #endif
00068
00069 #if defined(BUILD_OS_DARWIN)
00070 extern void __vtan( double *x, double *y, long count, long stridex,
00071 long stridey );
00072 #pragma weak vtan
00073 void vtan( double *x, double *y, long count, long stridex, long stridey ) {
00074 __vtan(x, y, count, stridex, stridey);
00075 }
00076 #elif defined(__GNUC__)
00077 extern void __vtan(double *, double *, long, long, long);
00078 void vtan() __attribute__ ((weak, alias ("__vtan")));
00079 #endif
00080
00081
00082
00083 static const du p[] =
00084 {
00085 {D(0x3ff00000, 0x00000000)},
00086 {D(0xbfc06b8f, 0x5f225706)},
00087 {D(0x3f66fc34, 0x2943627f)},
00088 {D(0xbedf6255, 0x88fc315e)},
00089 };
00090
00091 static const du q[] =
00092 {
00093 {D(0x3ff00000, 0x00000000)},
00094 {D(0xbfdd8b1d, 0x04e680b5)},
00095 {D(0x3f97e798, 0xc16cfadc)},
00096 {D(0xbf2b51d1, 0xd7f65e57)},
00097 };
00098
00099 static const du rpiby2 =
00100 {D(0x3fe45f30, 0x6dc9c883)};
00101
00102 static const du piby2hi =
00103 {D(0x3ff921fb, 0x54400000)};
00104
00105 static const du piby2lo =
00106 {D(0x3dd0b461, 0x1a600000)};
00107
00108 static const du piby2tiny =
00109 {D(0x3ba3198a, 0x2e037073)};
00110
00111 static const du Twop19xpi =
00112 {D(0x413921fb, 0x54442d18)};
00113
00114 static const du Twopm30 =
00115 {D(0x3e100000, 0x00000000)};
00116
00117 static const du Twopm85 =
00118 {D(0x3aa00000, 0x00000000)};
00119
00120 static const du Qnan =
00121 {D(QNANHI, QNANLO)};
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 void
00134 __vtan( double *x, double *y, long count, long stridex, long stridey )
00135 {
00136 long i;
00137 int n;
00138 double arg;
00139 double dx, w;
00140 double xsq;
00141 double num, denom;
00142 double dn;
00143 double poly1, poly2, result;
00144
00145
00146
00147 for ( i=0; i<count; i++ )
00148 {
00149 #ifdef _PREFETCH
00150 #pragma prefetch_ref=*(x+8)
00151 #pragma prefetch_ref=*(y+8)
00152 #endif
00153
00154 arg = *x;
00155
00156 dx = arg;
00157
00158
00159
00160 if ( fabs(arg) > Twop19xpi.d )
00161 dx = 0.0;
00162
00163 if ( arg != arg )
00164 dx = 0.0;
00165
00166 w = dx;
00167
00168 if ( fabs(dx) < Twopm30.d )
00169 w = 0.0;
00170
00171 dn = w*rpiby2.d;
00172
00173 n = ROUND(dn);
00174 dn = n;
00175
00176 dx = dx - dn*piby2hi.d;
00177 dx = dx - dn*piby2lo.d;
00178 dx = dx - dn*piby2tiny.d;
00179
00180 w = dx;
00181
00182
00183
00184 if ( fabs(dx) < Twopm85.d )
00185 w = 0.0;
00186
00187 xsq = w*w;
00188
00189 poly1 = ((p[3].d*xsq + p[2].d)*xsq + p[1].d)*(xsq*dx) + dx;
00190 poly2 = ((q[3].d*xsq + q[2].d)*xsq + q[1].d)*xsq + q[0].d;
00191
00192 if ( (n&1) == 0 )
00193 {
00194
00195
00196 num = poly1;
00197 denom = poly2;
00198 }
00199
00200 if ( (n&1) != 0 )
00201 {
00202
00203
00204 denom = poly1;
00205 num = -poly2;
00206 }
00207
00208 result = num/denom;
00209
00210 if ( arg != arg )
00211 result = Qnan.d;
00212
00213 *y = result;
00214
00215 x += stridex;
00216 y += stridey;
00217 }
00218 }
00219