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