17 template <
typename _Scalar>
35 for (
int i=0;i<nfft;++i)
49 default: p += 2;
break;
62 template <
typename _Src>
64 void work(
int stage,
Complex * xout,
const _Src * xin,
size_t fstride,
size_t in_stride)
69 Complex * Fout_end = xout + p*m;
77 work(stage+1, xout , xin, fstride*p,in_stride);
78 xin += fstride*in_stride;
79 }
while( (xout += m) != Fout_end );
83 xin += fstride*in_stride;
84 }
while(++xout != Fout_end );
90 case 2:
bfly2(xout,fstride,m);
break;
91 case 3:
bfly3(xout,fstride,m);
break;
92 case 4:
bfly4(xout,fstride,m);
break;
93 case 5:
bfly5(xout,fstride,m);
break;
101 for (
int k=0;k<m;++k) {
103 Fout[m+k] = Fout[k] - t;
112 int negative_if_inverse =
m_inverse * -2 +1;
113 for (
size_t k=0;k<m;++k) {
114 scratch[0] = Fout[k+m] *
m_twiddles[k*fstride];
115 scratch[1] = Fout[k+2*m] *
m_twiddles[k*fstride*2];
116 scratch[2] = Fout[k+3*m] *
m_twiddles[k*fstride*3];
117 scratch[5] = Fout[k] - scratch[1];
119 Fout[k] += scratch[1];
120 scratch[3] = scratch[0] + scratch[2];
121 scratch[4] = scratch[0] - scratch[2];
122 scratch[4] =
Complex( scratch[4].
imag()*negative_if_inverse , -scratch[4].
real()* negative_if_inverse );
124 Fout[k+2*m] = Fout[k] - scratch[3];
125 Fout[k] += scratch[3];
126 Fout[k+m] = scratch[5] + scratch[4];
127 Fout[k+3*m] = scratch[5] - scratch[4];
135 const size_t m2 = 2*m;
144 scratch[1]=Fout[m] * *tw1;
145 scratch[2]=Fout[m2] * *tw2;
147 scratch[3]=scratch[1]+scratch[2];
148 scratch[0]=scratch[1]-scratch[2];
152 scratch[0] *= epi3.imag();
163 Complex *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
169 ya = twiddles[fstride*m];
170 yb = twiddles[fstride*2*m];
179 for ( u=0; u<m; ++u ) {
182 scratch[1] = *Fout1 * tw[u*fstride];
183 scratch[2] = *Fout2 * tw[2*u*fstride];
184 scratch[3] = *Fout3 * tw[3*u*fstride];
185 scratch[4] = *Fout4 * tw[4*u*fstride];
187 scratch[7] = scratch[1] + scratch[4];
188 scratch[10] = scratch[1] - scratch[4];
189 scratch[8] = scratch[2] + scratch[3];
190 scratch[9] = scratch[2] - scratch[3];
192 *Fout0 += scratch[7];
193 *Fout0 += scratch[8];
195 scratch[5] = scratch[0] +
Complex(
196 (scratch[7].
real()*ya.real() ) + (scratch[8].real() *yb.real() ),
197 (scratch[7].imag()*ya.real()) + (scratch[8].imag()*yb.real())
201 (scratch[10].
imag()*ya.imag()) + (scratch[9].imag()*yb.imag()),
202 -(scratch[10].real()*ya.imag()) - (scratch[9].real()*yb.imag())
205 *Fout1 = scratch[5] - scratch[6];
206 *Fout4 = scratch[5] + scratch[6];
208 scratch[11] = scratch[0] +
210 (scratch[7].
real()*yb.real()) + (scratch[8].real()*ya.real()),
211 (scratch[7].imag()*yb.real()) + (scratch[8].imag()*ya.real())
215 -(scratch[10].
imag()*yb.imag()) + (scratch[9].imag()*ya.imag()),
216 (scratch[10].real()*yb.imag()) - (scratch[9].real()*ya.imag())
219 *Fout2=scratch[11]+scratch[12];
220 *Fout3=scratch[11]-scratch[12];
222 ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4;
230 const size_t fstride,
238 int Norig =
static_cast<int>(
m_twiddles.size());
241 for ( u=0; u<m; ++u ) {
243 for ( q1=0 ; q1<p ; ++q1 ) {
244 scratchbuf[q1] = Fout[ k ];
249 for ( q1=0 ; q1<p ; ++q1 ) {
251 Fout[ k ] = scratchbuf[0];
253 twidx +=
static_cast<int>(fstride) * k;
254 if (twidx>=Norig) twidx-=Norig;
255 t=scratchbuf[
q] * twiddles[twidx];
264 template <
typename _Scalar>
314 int ncfft2 = nfft>>2;
318 fwd( dst,
reinterpret_cast<const Complex*
> (src), ncfft);
319 Complex dc = dst[0].real() + dst[0].imag();
320 Complex nyquist = dst[0].real() - dst[0].imag();
322 for ( k=1;k <= ncfft2 ; ++k ) {
328 dst[k] = (f1k + tw) *
Scalar(.5);
332 dst[ncfft] = nyquist;
351 for (
int k=1;k<(nfft>>1)+1;++k)
354 for (
int k=0;k<nfft;++k)
359 int ncfft2 = nfft>>2;
363 for (
int k = 1; k <= ncfft / 2; ++k) {
386 int PlanKey(
int nfft,
bool isinverse)
const {
return (nfft<<1) |
int(isinverse); }
405 if ( (
int)twidref.size() != ncfft2 ) {
406 twidref.resize(ncfft2);
407 int ncfft= ncfft2<<1;
409 for (
int k=1;k<=ncfft2;++k)