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_3) (const BASE in[],
27 const TYPE(gsl_complex) twiddle1[],
28 const TYPE(gsl_complex) twiddle2[])
30 size_t i, j, k, k1, jump;
31 size_t factor, q, m, product_1;
33 ATOMIC tau = sqrt (3.0) / 2.0;
41 product_1 = product / factor;
42 jump = (factor - 1) * q;
44 for (k1 = 0; k1 < product_1; k1++)
46 const size_t from0 = 3 * k1 * q;
47 const size_t from1 = from0 + 2 * q - 1;
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);
53 const ATOMIC t1_real = 2 * z1_real;
54 const ATOMIC t2_real = z0_real - z1_real;
55 const ATOMIC t3_imag = 2 * tau * z1_imag;
57 const size_t to0 = q * k1;
58 const size_t to1 = to0 + m;
59 const size_t to2 = to1 + m;
61 VECTOR(out,ostride,to0) = z0_real + t1_real;
62 VECTOR(out,ostride,to1) = t2_real - t3_imag;
63 VECTOR(out,ostride,to2) = t2_real + t3_imag;
70 for (k = 1; k < (q + 1) / 2; k++)
72 const ATOMIC w1_real = GSL_REAL(twiddle1[k - 1]);
73 const ATOMIC w1_imag = GSL_IMAG(twiddle1[k - 1]);
74 const ATOMIC w2_real = GSL_REAL(twiddle2[k - 1]);
75 const ATOMIC w2_imag = GSL_IMAG(twiddle2[k - 1]);
77 for (k1 = 0; k1 < product_1; k1++)
79 const size_t from0 = 3 * k1 * q + 2 * k - 1;
80 const size_t from1 = from0 + 2 * q;
81 const size_t from2 = 3 * k1 * q - 2 * k + 2 * q - 1;
83 const ATOMIC z0_real = VECTOR(in,istride,from0);
84 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
86 const ATOMIC z1_real = VECTOR(in,istride,from1);
87 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
89 const ATOMIC z2_real = VECTOR(in,istride,from2);
90 const ATOMIC z2_imag = -VECTOR(in,istride,from2 + 1);
92 /* compute x = W(3) z */
95 const ATOMIC t1_real = z1_real + z2_real;
96 const ATOMIC t1_imag = z1_imag + z2_imag;
99 const ATOMIC t2_real = z0_real - t1_real / 2.0;
100 const ATOMIC t2_imag = z0_imag - t1_imag / 2.0;
102 /* t3 = sin(pi/3)*(z1 - z2) */
103 const ATOMIC t3_real = tau * (z1_real - z2_real);
104 const ATOMIC t3_imag = tau * (z1_imag - z2_imag);
107 const ATOMIC x0_real = z0_real + t1_real;
108 const ATOMIC x0_imag = z0_imag + t1_imag;
111 const ATOMIC x1_real = t2_real - t3_imag;
112 const ATOMIC x1_imag = t2_imag + t3_real;
115 const ATOMIC x2_real = t2_real + t3_imag;
116 const ATOMIC x2_imag = t2_imag - t3_real;
118 const size_t to0 = k1 * q + 2 * k - 1;
119 const size_t to1 = to0 + m;
120 const size_t to2 = to1 + m;
122 VECTOR(out,ostride,to0) = x0_real;
123 VECTOR(out,ostride,to0 + 1) = x0_imag;
125 VECTOR(out,ostride,to1) = w1_real * x1_real - w1_imag * x1_imag;
126 VECTOR(out,ostride,to1 + 1) = w1_imag * x1_real + w1_real * x1_imag;
128 VECTOR(out,ostride,to2) = w2_real * x2_real - w2_imag * x2_imag;
129 VECTOR(out,ostride,to2 + 1) = w2_imag * x2_real + w2_real * x2_imag;
137 for (k1 = 0; k1 < product_1; k1++)
139 const size_t from0 = 3 * k1 * q + q - 1;
140 const size_t from1 = from0 + 2 * q;
142 const ATOMIC z0_real = VECTOR(in,istride,from0);
143 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
144 const ATOMIC z1_real = VECTOR(in,istride,from1);
146 const ATOMIC t1_real = z0_real - z1_real;
147 const ATOMIC t2_real = 2 * tau * z0_imag;
149 const ATOMIC x0_real = 2 * z0_real + z1_real;
150 const ATOMIC x1_real = t1_real - t2_real;
151 const ATOMIC x2_real = -t1_real - t2_real;
153 const size_t to0 = k1 * q + q - 1;
154 const size_t to1 = to0 + m;
155 const size_t to2 = to1 + m;
157 VECTOR(out,ostride,to0) = x0_real;
158 VECTOR(out,ostride,to1) = x1_real;
159 VECTOR(out,ostride,to2) = x2_real;