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_6) (const BASE in[],
25 const gsl_fft_direction sign,
28 const TYPE(gsl_complex) twiddle1[],
29 const TYPE(gsl_complex) twiddle2[],
30 const TYPE(gsl_complex) twiddle3[],
31 const TYPE(gsl_complex) twiddle4[],
32 const TYPE(gsl_complex) twiddle5[])
38 const size_t factor = 6;
39 const size_t m = n / factor;
40 const size_t q = n / product;
41 const size_t p_1 = product / factor;
42 const size_t jump = (factor - 1) * p_1;
44 const ATOMIC tau = sqrt (3.0) / 2.0;
46 for (k = 0; k < q; k++)
48 ATOMIC w1_real, w1_imag, w2_real, w2_imag, w3_real, w3_imag, w4_real,
49 w4_imag, w5_real, w5_imag;
66 if (sign == gsl_fft_forward)
68 /* forward tranform */
69 w1_real = GSL_REAL(twiddle1[k - 1]);
70 w1_imag = GSL_IMAG(twiddle1[k - 1]);
71 w2_real = GSL_REAL(twiddle2[k - 1]);
72 w2_imag = GSL_IMAG(twiddle2[k - 1]);
73 w3_real = GSL_REAL(twiddle3[k - 1]);
74 w3_imag = GSL_IMAG(twiddle3[k - 1]);
75 w4_real = GSL_REAL(twiddle4[k - 1]);
76 w4_imag = GSL_IMAG(twiddle4[k - 1]);
77 w5_real = GSL_REAL(twiddle5[k - 1]);
78 w5_imag = GSL_IMAG(twiddle5[k - 1]);
82 /* backward tranform: w -> conjugate(w) */
83 w1_real = GSL_REAL(twiddle1[k - 1]);
84 w1_imag = -GSL_IMAG(twiddle1[k - 1]);
85 w2_real = GSL_REAL(twiddle2[k - 1]);
86 w2_imag = -GSL_IMAG(twiddle2[k - 1]);
87 w3_real = GSL_REAL(twiddle3[k - 1]);
88 w3_imag = -GSL_IMAG(twiddle3[k - 1]);
89 w4_real = GSL_REAL(twiddle4[k - 1]);
90 w4_imag = -GSL_IMAG(twiddle4[k - 1]);
91 w5_real = GSL_REAL(twiddle5[k - 1]);
92 w5_imag = -GSL_IMAG(twiddle5[k - 1]);
96 for (k1 = 0; k1 < p_1; k1++)
98 const ATOMIC z0_real = REAL(in,istride,i);
99 const ATOMIC z0_imag = IMAG(in,istride,i);
100 const ATOMIC z1_real = REAL(in,istride,i+m);
101 const ATOMIC z1_imag = IMAG(in,istride,i+m);
102 const ATOMIC z2_real = REAL(in,istride,i+2*m);
103 const ATOMIC z2_imag = IMAG(in,istride,i+2*m);
104 const ATOMIC z3_real = REAL(in,istride,i+3*m);
105 const ATOMIC z3_imag = IMAG(in,istride,i+3*m);
106 const ATOMIC z4_real = REAL(in,istride,i+4*m);
107 const ATOMIC z4_imag = IMAG(in,istride,i+4*m);
108 const ATOMIC z5_real = REAL(in,istride,i+5*m);
109 const ATOMIC z5_imag = IMAG(in,istride,i+5*m);
111 /* compute x = W(6) z */
113 /* W(6) is a combination of sums and differences of W(3) acting
114 on the even and odd elements of z */
117 const ATOMIC ta1_real = z2_real + z4_real;
118 const ATOMIC ta1_imag = z2_imag + z4_imag;
120 /* ta2 = z0 - ta1/2 */
121 const ATOMIC ta2_real = z0_real - ta1_real / 2;
122 const ATOMIC ta2_imag = z0_imag - ta1_imag / 2;
124 /* ta3 = (+/-) sin(pi/3)*(z2 - z4) */
125 const ATOMIC ta3_real = ((int) sign) * tau * (z2_real - z4_real);
126 const ATOMIC ta3_imag = ((int) sign) * tau * (z2_imag - z4_imag);
129 const ATOMIC a0_real = z0_real + ta1_real;
130 const ATOMIC a0_imag = z0_imag + ta1_imag;
132 /* a1 = ta2 + i ta3 */
133 const ATOMIC a1_real = ta2_real - ta3_imag;
134 const ATOMIC a1_imag = ta2_imag + ta3_real;
136 /* a2 = ta2 - i ta3 */
137 const ATOMIC a2_real = ta2_real + ta3_imag;
138 const ATOMIC a2_imag = ta2_imag - ta3_real;
141 const ATOMIC tb1_real = z5_real + z1_real;
142 const ATOMIC tb1_imag = z5_imag + z1_imag;
144 /* tb2 = z3 - tb1/2 */
145 const ATOMIC tb2_real = z3_real - tb1_real / 2;
146 const ATOMIC tb2_imag = z3_imag - tb1_imag / 2;
148 /* tb3 = (+/-) sin(pi/3)*(z5 - z1) */
149 const ATOMIC tb3_real = ((int) sign) * tau * (z5_real - z1_real);
150 const ATOMIC tb3_imag = ((int) sign) * tau * (z5_imag - z1_imag);
153 const ATOMIC b0_real = z3_real + tb1_real;
154 const ATOMIC b0_imag = z3_imag + tb1_imag;
156 /* b1 = tb2 + i tb3 */
157 const ATOMIC b1_real = tb2_real - tb3_imag;
158 const ATOMIC b1_imag = tb2_imag + tb3_real;
160 /* b2 = tb2 - i tb3 */
161 const ATOMIC b2_real = tb2_real + tb3_imag;
162 const ATOMIC b2_imag = tb2_imag - tb3_real;
165 const ATOMIC x0_real = a0_real + b0_real;
166 const ATOMIC x0_imag = a0_imag + b0_imag;
169 const ATOMIC x4_real = a1_real + b1_real;
170 const ATOMIC x4_imag = a1_imag + b1_imag;
173 const ATOMIC x2_real = a2_real + b2_real;
174 const ATOMIC x2_imag = a2_imag + b2_imag;
177 const ATOMIC x3_real = a0_real - b0_real;
178 const ATOMIC x3_imag = a0_imag - b0_imag;
181 const ATOMIC x1_real = a1_real - b1_real;
182 const ATOMIC x1_imag = a1_imag - b1_imag;
185 const ATOMIC x5_real = a2_real - b2_real;
186 const ATOMIC x5_imag = a2_imag - b2_imag;
188 /* apply twiddle factors */
191 REAL(out,ostride,j) = x0_real;
192 IMAG(out,ostride,j) = x0_imag;
195 REAL(out,ostride,j+p_1) = w1_real * x1_real - w1_imag * x1_imag;
196 IMAG(out,ostride,j+p_1) = w1_real * x1_imag + w1_imag * x1_real;
199 REAL(out,ostride,j+2*p_1) = w2_real * x2_real - w2_imag * x2_imag;
200 IMAG(out,ostride,j+2*p_1) = w2_real * x2_imag + w2_imag * x2_real;
203 REAL(out,ostride,j+3*p_1) = w3_real * x3_real - w3_imag * x3_imag;
204 IMAG(out,ostride,j+3*p_1) = w3_real * x3_imag + w3_imag * x3_real;
207 REAL(out,ostride,j+4*p_1) = w4_real * x4_real - w4_imag * x4_imag;
208 IMAG(out,ostride,j+4*p_1) = w4_real * x4_imag + w4_imag * x4_real;
211 REAL(out,ostride,j+5*p_1) = w5_real * x5_real - w5_imag * x5_imag;
212 IMAG(out,ostride,j+5*p_1) = w5_real * x5_imag + w5_imag * x5_real;