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 #include "complex.h"
00061
00062 #if defined(mips) && !defined(__GNUC__)
00063 extern void vfcis(float *, complex *, long, long, long);
00064 extern void vcisf(float *, complex *, long, long, long);
00065
00066 #pragma weak vfcis = __vcisf
00067 #pragma weak vcisf = __vcisf
00068 #endif
00069
00070 #if defined(BUILD_OS_DARWIN)
00071 extern void __vcisf( float *x, complex *y, long count, long stridex,
00072 long stridey );
00073 #pragma weak vcisf
00074 void vcisf( float *x, complex *y, long count, long stridex, long stridey ) {
00075 __vcisf(x, y, count, stridex, stridey);
00076 }
00077 #elif defined(__GNUC__)
00078 extern void __vcisf(float *, complex *, long, long, long);
00079 void vcisf() __attribute__ ((weak, alias ("__vcisf")));
00080 #endif
00081
00082 static const du rpiby2 =
00083 {D(0x3fe45f30, 0x6dc9c883)};
00084
00085 static const du piby2hi =
00086 {D(0x3ff921fb, 0x50000000)};
00087
00088 static const du piby2lo =
00089 {D(0x3e5110b4, 0x611a6263)};
00090
00091 static const fu Twop28 = {0x4d800000};
00092
00093
00094
00095 static const du P[] =
00096 {
00097 {D(0x3ff00000, 0x00000000)},
00098 {D(0xbfc55554, 0x5268a030)},
00099 {D(0x3f811073, 0xafd14db9)},
00100 {D(0xbf29943e, 0x0fc79aa9)},
00101 };
00102
00103
00104
00105 static const du Q[] =
00106 {
00107 {D(0x3ff00000, 0x00000000)},
00108 {D(0xbfdffffb, 0x2a77e083)},
00109 {D(0x3fa553e7, 0xf02ac8aa)},
00110 {D(0xbf5644d6, 0x2993c4ad)},
00111 };
00112
00113 static const fu Qnan = {QNANF};
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 void
00126 __vcisf( float *x, complex *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 complex 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.real = cospoly;
00175 result.imag = sinpoly;
00176
00177 if ( n&1 )
00178 {
00179 result.real = -sinpoly;
00180 result.imag = cospoly;
00181 n--;
00182 }
00183
00184 if ( n&2 )
00185 {
00186 result.real = -result.real;
00187 result.imag = -result.imag;
00188 }
00189
00190 if ( arg != arg )
00191 {
00192 result.real = Qnan.f;
00193 result.imag = Qnan.f;
00194 }
00195
00196 y->real = result.real;
00197 y->imag = result.imag;
00198
00199 x += stridex;
00200 y += stridey;
00201 }
00202 }
00203