9 #ifndef KISSFFT_CLASS_HH
10 #define KISSFFT_CLASS_HH
16 template <
typename scalar_t>
21 typedef std::complex<scalar_t>
cpx_t;
30 const scalar_t phinc = (
_inverse?2:-2)* std::acos( (scalar_t) -1) /
_nfft;
43 default: p += 2;
break;
72 for (
typename std::vector<cpx_t>::iterator it =
_twiddles.begin();
74 it->imag( -it->imag() );
94 cpx_t *
const Fout_beg = fft_out;
95 cpx_t *
const Fout_end = fft_out + p*m;
100 fft_in += fstride*in_stride;
101 }
while(++fft_out != Fout_end );
108 transform(fft_in, fft_out, stage+1, fstride*p,in_stride);
109 fft_in += fstride*in_stride;
110 }
while( (fft_out += m) != Fout_end );
117 case 2:
kf_bfly2(fft_out,fstride,m);
break;
118 case 3:
kf_bfly3(fft_out,fstride,m);
break;
119 case 4:
kf_bfly4(fft_out,fstride,m);
break;
120 case 5:
kf_bfly5(fft_out,fstride,m);
break;
166 dst[0].real() -
dst[0].imag() );
169 const scalar_t pi = std::acos( (scalar_t) -1);
170 const scalar_t half_phi_inc = (
_inverse ? pi : -pi ) / N;
171 const cpx_t twiddle_mul = std::exp(
cpx_t(0, half_phi_inc) );
175 dst[k].real() +
dst[N-k].real(),
176 dst[k].imag() -
dst[N-k].imag() );
178 dst[k].imag() +
dst[N-k].imag(),
179 -
dst[k].real() +
dst[N-k].real() );
180 const cpx_t twiddle =
184 dst[ k] = w + twiddle *
z;
185 dst[N-k] = std::conj( w - twiddle *
z );
188 dst[N/2] = std::conj(
dst[N/2] );
197 Fout[m+k] = Fout[k] - t;
206 const cpx_t *tw1,*tw2;
213 scratch[1] = Fout[m] * *tw1;
214 scratch[2] = Fout[m2] * *tw2;
216 scratch[3] = scratch[1] + scratch[2];
217 scratch[0] = scratch[1] - scratch[2];
221 Fout[m] = Fout[0] - scratch[3]*scalar_t(0.5);
222 scratch[0] *= epi3.imag();
224 Fout[0] += scratch[3];
226 Fout[m2] =
cpx_t( Fout[m].real() + scratch[0].imag() , Fout[m].imag() - scratch[0].real() );
228 Fout[m] +=
cpx_t( -scratch[0].imag(),scratch[0].real() );
236 const scalar_t negative_if_inverse =
_inverse ? -1 : +1;
238 scratch[0] = Fout[k+ m] *
_twiddles[k*fstride ];
239 scratch[1] = Fout[k+2*m] *
_twiddles[k*fstride*2];
240 scratch[2] = Fout[k+3*m] *
_twiddles[k*fstride*3];
241 scratch[5] = Fout[k] - scratch[1];
243 Fout[k] += scratch[1];
244 scratch[3] = scratch[0] + scratch[2];
245 scratch[4] = scratch[0] - scratch[2];
246 scratch[4] =
cpx_t( scratch[4].imag()*negative_if_inverse ,
247 -scratch[4].real()*negative_if_inverse );
249 Fout[k+2*m] = Fout[k] - scratch[3];
250 Fout[k ]+= scratch[3];
251 Fout[k+ m] = scratch[5] + scratch[4];
252 Fout[k+3*m] = scratch[5] - scratch[4];
258 cpx_t *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
272 scratch[1] = *Fout1 *
_twiddles[ u*fstride];
273 scratch[2] = *Fout2 *
_twiddles[2*u*fstride];
274 scratch[3] = *Fout3 *
_twiddles[3*u*fstride];
275 scratch[4] = *Fout4 *
_twiddles[4*u*fstride];
277 scratch[7] = scratch[1] + scratch[4];
278 scratch[10]= scratch[1] - scratch[4];
279 scratch[8] = scratch[2] + scratch[3];
280 scratch[9] = scratch[2] - scratch[3];
282 *Fout0 += scratch[7];
283 *Fout0 += scratch[8];
285 scratch[5] = scratch[0] +
cpx_t(
286 scratch[7].real()*ya.real() + scratch[8].real()*yb.real(),
287 scratch[7].imag()*ya.real() + scratch[8].imag()*yb.real()
291 scratch[10].imag()*ya.imag() + scratch[9].imag()*yb.imag(),
292 -scratch[10].real()*ya.imag() - scratch[9].real()*yb.imag()
295 *Fout1 = scratch[5] - scratch[6];
296 *Fout4 = scratch[5] + scratch[6];
298 scratch[11] = scratch[0] +
300 scratch[7].real()*yb.real() + scratch[8].real()*ya.real(),
301 scratch[7].imag()*yb.real() + scratch[8].imag()*ya.real()
305 -scratch[10].imag()*yb.imag() + scratch[9].imag()*ya.imag(),
306 scratch[10].real()*yb.imag() - scratch[9].real()*ya.imag()
309 *Fout2 = scratch[11] + scratch[12];
310 *Fout3 = scratch[11] - scratch[12];
323 const size_t fstride,
344 twidx += fstride * k;