3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 FUNCTION(fft_complex,pass_2) (const BASE in[],
25 const gsl_fft_direction sign,
28 const TYPE(gsl_complex) twiddle[])
33 const size_t factor = 2;
34 const size_t m = n / factor;
35 const size_t q = n / product;
36 const size_t product_1 = product / factor;
37 const size_t jump = (factor - 1) * product_1;
39 for (k = 0; k < q; k++)
41 ATOMIC w_real, w_imag;
50 if (sign == gsl_fft_forward)
52 /* forward tranform */
53 w_real = GSL_REAL(twiddle[k - 1]);
54 w_imag = GSL_IMAG(twiddle[k - 1]);
58 /* backward tranform: w -> conjugate(w) */
59 w_real = GSL_REAL(twiddle[k - 1]);
60 w_imag = -GSL_IMAG(twiddle[k - 1]);
64 for (k1 = 0; k1 < product_1; k1++)
66 const ATOMIC z0_real = REAL(in,istride,i);
67 const ATOMIC z0_imag = IMAG(in,istride,i);
69 const ATOMIC z1_real = REAL(in,istride,i+m);
70 const ATOMIC z1_imag = IMAG(in,istride,i+m);
72 /* compute x = W(2) z */
75 const ATOMIC x0_real = z0_real + z1_real;
76 const ATOMIC x0_imag = z0_imag + z1_imag;
79 const ATOMIC x1_real = z0_real - z1_real;
80 const ATOMIC x1_imag = z0_imag - z1_imag;
82 /* apply twiddle factors */
85 REAL(out,ostride,j) = x0_real;
86 IMAG(out,ostride,j) = x0_imag;
89 REAL(out,ostride,j+product_1) = w_real * x1_real - w_imag * x1_imag;
90 IMAG(out,ostride,j+product_1) = w_real * x1_imag + w_imag * x1_real;