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_halfcomplex,pass_4) (const BASE in[],
27 const TYPE(gsl_complex) twiddle1[],
28 const TYPE(gsl_complex) twiddle2[],
29 const TYPE(gsl_complex) twiddle3[])
31 size_t i, j, k, k1, jump;
32 size_t factor, q, m, product_1;
40 product_1 = product / factor;
41 jump = (factor - 1) * q;
43 for (k1 = 0; k1 < product_1; k1++)
45 const size_t from0 = 4 * k1 * q;
46 const size_t from1 = from0 + 2 * q - 1;
47 const size_t from2 = from1 + 2 * q;
49 const ATOMIC z0_real = VECTOR(in,istride,from0);
50 const ATOMIC z1_real = VECTOR(in,istride,from1);
51 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
52 const ATOMIC z2_real = VECTOR(in,istride,from2);
54 const ATOMIC t1_real = z0_real + z2_real;
55 const ATOMIC t2_real = 2 * z1_real;
56 const ATOMIC t3_real = z0_real - z2_real;
57 const ATOMIC t4_imag = 2 * z1_imag;
59 const size_t to0 = q * k1;
60 const size_t to1 = to0 + m;
61 const size_t to2 = to1 + m;
62 const size_t to3 = to2 + m;
64 VECTOR(out,ostride,to0) = t1_real + t2_real;
65 VECTOR(out,ostride,to1) = t3_real - t4_imag;
66 VECTOR(out,ostride,to2) = t1_real - t2_real;
67 VECTOR(out,ostride,to3) = t3_real + t4_imag;
73 for (k = 1; k < (q + 1) / 2; k++)
75 const ATOMIC w1_real = GSL_REAL(twiddle1[k - 1]);
76 const ATOMIC w1_imag = GSL_IMAG(twiddle1[k - 1]);
77 const ATOMIC w2_real = GSL_REAL(twiddle2[k - 1]);
78 const ATOMIC w2_imag = GSL_IMAG(twiddle2[k - 1]);
79 const ATOMIC w3_real = GSL_REAL(twiddle3[k - 1]);
80 const ATOMIC w3_imag = GSL_IMAG(twiddle3[k - 1]);
82 for (k1 = 0; k1 < product_1; k1++)
84 const size_t from0 = 4 * k1 * q + 2 * k - 1;
85 const size_t from1 = from0 + 2 * q;
86 const size_t from2 = 4 * k1 * q - 2 * k + 2 * q - 1;
87 const size_t from3 = from2 + 2 * q;
89 const ATOMIC z0_real = VECTOR(in,istride,from0);
90 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
92 const ATOMIC z1_real = VECTOR(in,istride,from1);
93 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
95 const ATOMIC z2_real = VECTOR(in,istride,from3);
96 const ATOMIC z2_imag = -VECTOR(in,istride,from3 + 1);
98 const ATOMIC z3_real = VECTOR(in,istride,from2);
99 const ATOMIC z3_imag = -VECTOR(in,istride,from2 + 1);
101 /* compute x = W(4) z */
104 const ATOMIC t1_real = z0_real + z2_real;
105 const ATOMIC t1_imag = z0_imag + z2_imag;
108 const ATOMIC t2_real = z1_real + z3_real;
109 const ATOMIC t2_imag = z1_imag + z3_imag;
112 const ATOMIC t3_real = z0_real - z2_real;
113 const ATOMIC t3_imag = z0_imag - z2_imag;
116 const ATOMIC t4_real = (z1_real - z3_real);
117 const ATOMIC t4_imag = (z1_imag - z3_imag);
120 const ATOMIC x0_real = t1_real + t2_real;
121 const ATOMIC x0_imag = t1_imag + t2_imag;
124 const ATOMIC x1_real = t3_real - t4_imag;
125 const ATOMIC x1_imag = t3_imag + t4_real;
128 const ATOMIC x2_real = t1_real - t2_real;
129 const ATOMIC x2_imag = t1_imag - t2_imag;
132 const ATOMIC x3_real = t3_real + t4_imag;
133 const ATOMIC x3_imag = t3_imag - t4_real;
135 const size_t to0 = k1 * q + 2 * k - 1;
136 const size_t to1 = to0 + m;
137 const size_t to2 = to1 + m;
138 const size_t to3 = to2 + m;
140 VECTOR(out,ostride,to0) = x0_real;
141 VECTOR(out,ostride,to0 + 1) = x0_imag;
143 VECTOR(out,ostride,to1) = w1_real * x1_real - w1_imag * x1_imag;
144 VECTOR(out,ostride,to1 + 1) = w1_imag * x1_real + w1_real * x1_imag;
146 VECTOR(out,ostride,to2) = w2_real * x2_real - w2_imag * x2_imag;
147 VECTOR(out,ostride,to2 + 1) = w2_imag * x2_real + w2_real * x2_imag;
150 VECTOR(out,ostride,to3) = w3_real * x3_real - w3_imag * x3_imag;
151 VECTOR(out,ostride,to3 + 1) = w3_real * x3_imag + w3_imag * x3_real;
159 for (k1 = 0; k1 < product_1; k1++)
161 const size_t from0 = 4 * k1 * q + q - 1;
162 const size_t from1 = from0 + 2 * q;
164 const ATOMIC z0_real = VECTOR(in,istride,from0);
165 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
167 const ATOMIC z1_real = VECTOR(in,istride,from1);
168 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
170 const ATOMIC t1_real = sqrt (2.0) * (z0_imag + z1_imag);
171 const ATOMIC t2_real = sqrt (2.0) * (z0_real - z1_real);
173 const ATOMIC x0_real = 2 * (z0_real + z1_real);
174 const ATOMIC x1_real = t2_real - t1_real;
175 const ATOMIC x2_real = 2 * (z1_imag - z0_imag);
176 const ATOMIC x3_real = -(t2_real + t1_real);
178 const size_t to0 = k1 * q + q - 1;
179 const size_t to1 = to0 + m;
180 const size_t to2 = to1 + m;
181 const size_t to3 = to2 + m;
183 VECTOR(out,ostride,to0) = x0_real;
184 VECTOR(out,ostride,to1) = x1_real;
185 VECTOR(out,ostride,to2) = x2_real;
186 VECTOR(out,ostride,to3) = x3_real;