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.vtanf.c $ $Revision: 1.5 $";
00060
00061 #include "libm.h"
00062
00063 #if defined(mips) && !defined(__GNUC__)
00064 extern void vftan(float *, float *, long, long, long);
00065 extern void vtanf(float *, float *, long, long, long);
00066
00067 #pragma weak vftan = __vtanf
00068 #pragma weak vtanf = __vtanf
00069 #endif
00070
00071 #if defined(BUILD_OS_DARWIN)
00072 extern void __vtanf( float *x, float *y, long count, long stridex,
00073 long stridey );
00074 #pragma weak vtanf
00075 void vtanf( float *x, float *y, long count, long stridex, long stridey ) {
00076 __vtanf(x, y, count, stridex, stridey);
00077 }
00078 #elif defined(__GNUC__)
00079 extern void __vtanf(float *, float *, long, long, long);
00080 void vtanf() __attribute__ ((weak, alias ("__vtanf")));
00081 #endif
00082
00083
00084
00085 static const du p[] =
00086 {
00087 {D(0x3ff00000, 0x00000000)},
00088 {D(0xbfbc81c6, 0x2c5816af)},
00089 {D(0x3f519bb5, 0x82dc4bbf)},
00090 };
00091
00092 static const du q[] =
00093 {
00094 {D(0x3ff00000, 0x00000000)},
00095 {D(0xbfdc75c6, 0xdf240b98)},
00096 {D(0x3f905aab, 0xa06cbb7f)},
00097 };
00098
00099 static const du rpiby2 =
00100 {D(0x3fe45f30, 0x6dc9c883)};
00101
00102 static const du piby2hi =
00103 {D(0x3ff921fb, 0x50000000)};
00104
00105 static const du piby2lo =
00106 {D(0x3e5110b4, 0x611a6263)};
00107
00108 static const fu Twop28 = {0x4d800000};
00109
00110 static const fu Qnan = {QNANF};
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 void
00123 __vtanf( float *x, float *y, long count, long stridex, long stridey )
00124 {
00125 long i;
00126 int n;
00127 float arg, w;
00128 double dx;
00129 double xsq;
00130 double num, denom;
00131 double dn;
00132 double poly1, poly2;
00133 float result;
00134
00135
00136
00137 for ( i=0; i<count; i++ )
00138 {
00139 #ifdef _PREFETCH
00140 #pragma prefetch_ref=*(x+8)
00141 #pragma prefetch_ref=*(y+8)
00142 #endif
00143
00144 arg = *x;
00145 w = arg;
00146
00147 if ( arg != arg )
00148 w = 0.0f;
00149
00150
00151
00152 if ( fabsf(w) >= Twop28.f )
00153 w = 0.0f;
00154
00155
00156
00157
00158
00159
00160
00161 dx = w;
00162
00163 dn = dx*rpiby2.d;
00164 n = ROUND(dn);
00165 dn = n;
00166
00167 dx = dx - dn*piby2hi.d;
00168 dx = dx - dn*piby2lo.d;
00169
00170 xsq = dx*dx;
00171
00172 poly1 = (p[2].d*xsq + p[1].d)*xsq*dx + dx;
00173 poly2 = (q[2].d*xsq + q[1].d)*xsq + q[0].d;
00174
00175 if ( (n&1) == 0 )
00176 {
00177
00178
00179 num = poly1;
00180 denom = poly2;
00181 }
00182
00183 if ( (n&1) != 0 )
00184 {
00185
00186
00187 denom = poly1;
00188 num = -poly2;
00189 }
00190
00191 result = num/denom;
00192
00193 if ( arg != arg )
00194 result = Qnan.f;
00195
00196 *y = result;
00197
00198 x += stridex;
00199 y += stridey;
00200 }
00201 }
00202