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 vcis(double *, dcomplex *, long, long, long);
00064
00065 #pragma weak vcis = __vcis
00066 #endif
00067
00068 #if defined(BUILD_OS_DARWIN)
00069 extern void __vcis( double *x, dcomplex *y, long count, long stridex,
00070 long stridey );
00071 #pragma weak vcis
00072 void vcis( double *x, dcomplex *y, long count, long stridex, long stridey ) {
00073 __vcis(x, y, count, stridex, stridey);
00074 }
00075 #elif defined(__GNUC__)
00076 extern void __vcis(double *, dcomplex *, long, long, long);
00077 void vcis() __attribute__ ((weak, alias ("__vcis")));
00078 #endif
00079
00080 static const du rpiby2 =
00081 {D(0x3fe45f30, 0x6dc9c883)};
00082
00083 static const du piby2hi =
00084 {D(0x3ff921fb, 0x54400000)};
00085
00086 static const du piby2lo =
00087 {D(0x3dd0b461, 0x1a600000)};
00088
00089 static const du piby2tiny =
00090 {D(0x3ba3198a, 0x2e037073)};
00091
00092 static const du Twopm30 =
00093 {D(0x3e100000, 0x00000000)};
00094
00095 static const du Twop19xpi =
00096 {D(0x413921fb, 0x54442d18)};
00097
00098
00099
00100 static const du P[] =
00101 {
00102 {D(0x3ff00000, 0x00000000)},
00103 {D(0xbfc55555, 0x55555548)},
00104 {D(0x3f811111, 0x1110f7d0)},
00105 {D(0xbf2a01a0, 0x19bfdf03)},
00106 {D(0x3ec71de3, 0x567d4896)},
00107 {D(0xbe5ae5e5, 0xa9291691)},
00108 {D(0x3de5d8fd, 0x1fcf0ec1)},
00109 };
00110
00111
00112
00113 static const du Q[] =
00114 {
00115 {D(0x3ff00000, 0x00000000)},
00116 {D(0xbfdfffff, 0xffffff96)},
00117 {D(0x3fa55555, 0x5554f0ab)},
00118 {D(0xbf56c16c, 0x1640aaca)},
00119 {D(0x3efa019f, 0x81cb6a1d)},
00120 {D(0xbe927df4, 0x609cb202)},
00121 {D(0x3e21b8b9, 0x947ab5c8)},
00122 };
00123
00124 static const du Qnan =
00125 {D(QNANHI, QNANLO)};
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 void
00139 __vcis( double *x, dcomplex *y, long count, long stridex, long stridey )
00140 {
00141 long i;
00142 int n;
00143 double dx, arg;
00144 double w;
00145 double xsq;
00146 double sinpoly, cospoly;
00147 double resultr, resulti;
00148 double dn;
00149
00150
00151
00152 for ( i=0; i<count; i++ )
00153 {
00154 #ifdef _PREFETCH
00155 #pragma prefetch_ref=*(x+8)
00156 #pragma prefetch_ref=*(y+8)
00157 #endif
00158
00159 arg = *x;
00160
00161 dx = arg;
00162
00163 if ( arg != arg )
00164 dx = 0.0;
00165
00166
00167
00168 if ( fabs(arg) > Twop19xpi.d )
00169 dx = 0.0;
00170
00171
00172
00173 w = dx;
00174
00175 if ( fabs(arg) < Twopm30.d )
00176 w = 0.0;
00177
00178 dn = w*rpiby2.d;
00179
00180 n = ROUND(dn);
00181 dn = n;
00182
00183 dx = dx - dn*piby2hi.d;
00184 dx = dx - dn*piby2lo.d;
00185 dx = dx - dn*piby2tiny.d;
00186
00187 w = dx;
00188
00189 if ( fabs(arg) < Twopm30.d )
00190 w = 0.0;
00191
00192 xsq = w*w;
00193
00194 cospoly = (((((Q[6].d*xsq + Q[5].d)*xsq + Q[4].d)*xsq
00195 + Q[3].d)*xsq + Q[2].d)*xsq + Q[1].d)*xsq + Q[0].d;
00196
00197 sinpoly = (((((P[6].d*xsq + P[5].d)*xsq + P[4].d)*xsq
00198 + P[3].d)*xsq + P[2].d)*xsq + P[1].d)*(xsq*dx) + dx;
00199
00200 resultr = cospoly;
00201 resulti = sinpoly;
00202
00203 if ( n&1 )
00204 {
00205 resultr = -sinpoly;
00206 resulti = cospoly;
00207 n--;
00208 }
00209
00210 if ( n&2 )
00211 {
00212 resultr = -resultr;
00213 resulti = -resulti;
00214 }
00215
00216 if ( arg != arg )
00217 {
00218 resultr = Qnan.d;
00219 resulti = Qnan.d;
00220 }
00221
00222 y->dreal = resultr;
00223 y->dimag = resulti;
00224
00225 x += stridex;
00226 y += stridey;
00227 }
00228 }
00229