Debian Codegraph @

external/gsl/gsl_fft__hc_pass_4.c

raw symbols SCIP
1 /* fft/hc_pass_4.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
4 *
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.
9 *
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.
14 *
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.
18 */
19
20 static void
21 FUNCTION(fft_halfcomplex,pass_4) (const BASE in[],
22 const size_t istride,
23 BASE out[],
24 const size_t ostride,
25 const size_t product,
26 const size_t n,
27 const TYPE(gsl_complex) twiddle1[],
28 const TYPE(gsl_complex) twiddle2[],
29 const TYPE(gsl_complex) twiddle3[])
30 {
31 size_t k, k1;
32 size_t factor, q, m, product_1;
33
34
35 factor = 4;
36 m = n / factor;
37 q = n / product;
38 product_1 = product / factor;
39
40 for (k1 = 0; k1 < product_1; k1++)
41 {
42 const size_t from0 = 4 * k1 * q;
43 const size_t from1 = from0 + 2 * q - 1;
44 const size_t from2 = from1 + 2 * q;
45
46 const ATOMIC z0_real = VECTOR(in,istride,from0);
47 const ATOMIC z1_real = VECTOR(in,istride,from1);
48 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
49 const ATOMIC z2_real = VECTOR(in,istride,from2);
50
51 const ATOMIC t1_real = z0_real + z2_real;
52 const ATOMIC t2_real = 2 * z1_real;
53 const ATOMIC t3_real = z0_real - z2_real;
54 const ATOMIC t4_imag = 2 * z1_imag;
55
56 const size_t to0 = q * k1;
57 const size_t to1 = to0 + m;
58 const size_t to2 = to1 + m;
59 const size_t to3 = to2 + m;
60
61 VECTOR(out,ostride,to0) = t1_real + t2_real;
62 VECTOR(out,ostride,to1) = t3_real - t4_imag;
63 VECTOR(out,ostride,to2) = t1_real - t2_real;
64 VECTOR(out,ostride,to3) = t3_real + t4_imag;
65 }
66
67 if (q == 1)
68 return;
69
70 for (k = 1; k < (q + 1) / 2; k++)
71 {
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]);
76 const ATOMIC w3_real = GSL_REAL(twiddle3[k - 1]);
77 const ATOMIC w3_imag = GSL_IMAG(twiddle3[k - 1]);
78
79 for (k1 = 0; k1 < product_1; k1++)
80 {
81 const size_t from0 = 4 * k1 * q + 2 * k - 1;
82 const size_t from1 = from0 + 2 * q;
83 const size_t from2 = 4 * k1 * q - 2 * k + 2 * q - 1;
84 const size_t from3 = from2 + 2 * q;
85
86 const ATOMIC z0_real = VECTOR(in,istride,from0);
87 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
88
89 const ATOMIC z1_real = VECTOR(in,istride,from1);
90 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
91
92 const ATOMIC z2_real = VECTOR(in,istride,from3);
93 const ATOMIC z2_imag = -VECTOR(in,istride,from3 + 1);
94
95 const ATOMIC z3_real = VECTOR(in,istride,from2);
96 const ATOMIC z3_imag = -VECTOR(in,istride,from2 + 1);
97
98 /* compute x = W(4) z */
99
100 /* t1 = z0 + z2 */
101 const ATOMIC t1_real = z0_real + z2_real;
102 const ATOMIC t1_imag = z0_imag + z2_imag;
103
104 /* t2 = z1 + z3 */
105 const ATOMIC t2_real = z1_real + z3_real;
106 const ATOMIC t2_imag = z1_imag + z3_imag;
107
108 /* t3 = z0 - z2 */
109 const ATOMIC t3_real = z0_real - z2_real;
110 const ATOMIC t3_imag = z0_imag - z2_imag;
111
112 /* t4 = (z1 - z3) */
113 const ATOMIC t4_real = (z1_real - z3_real);
114 const ATOMIC t4_imag = (z1_imag - z3_imag);
115
116 /* x0 = t1 + t2 */
117 const ATOMIC x0_real = t1_real + t2_real;
118 const ATOMIC x0_imag = t1_imag + t2_imag;
119
120 /* x1 = t3 + i t4 */
121 const ATOMIC x1_real = t3_real - t4_imag;
122 const ATOMIC x1_imag = t3_imag + t4_real;
123
124 /* x2 = t1 - t2 */
125 const ATOMIC x2_real = t1_real - t2_real;
126 const ATOMIC x2_imag = t1_imag - t2_imag;
127
128 /* x3 = t3 - i t4 */
129 const ATOMIC x3_real = t3_real + t4_imag;
130 const ATOMIC x3_imag = t3_imag - t4_real;
131
132 const size_t to0 = k1 * q + 2 * k - 1;
133 const size_t to1 = to0 + m;
134 const size_t to2 = to1 + m;
135 const size_t to3 = to2 + m;
136
137 VECTOR(out,ostride,to0) = x0_real;
138 VECTOR(out,ostride,to0 + 1) = x0_imag;
139
140 VECTOR(out,ostride,to1) = w1_real * x1_real - w1_imag * x1_imag;
141 VECTOR(out,ostride,to1 + 1) = w1_imag * x1_real + w1_real * x1_imag;
142
143 VECTOR(out,ostride,to2) = w2_real * x2_real - w2_imag * x2_imag;
144 VECTOR(out,ostride,to2 + 1) = w2_imag * x2_real + w2_real * x2_imag;
145
146 /* to3 = w3 * x3 */
147 VECTOR(out,ostride,to3) = w3_real * x3_real - w3_imag * x3_imag;
148 VECTOR(out,ostride,to3 + 1) = w3_real * x3_imag + w3_imag * x3_real;
149
150 }
151 }
152
153 if (q % 2 == 1)
154 return;
155
156 for (k1 = 0; k1 < product_1; k1++)
157 {
158 const size_t from0 = 4 * k1 * q + q - 1;
159 const size_t from1 = from0 + 2 * q;
160
161 const ATOMIC z0_real = VECTOR(in,istride,from0);
162 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
163
164 const ATOMIC z1_real = VECTOR(in,istride,from1);
165 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
166
167 const ATOMIC t1_real = sqrt (2.0) * (z0_imag + z1_imag);
168 const ATOMIC t2_real = sqrt (2.0) * (z0_real - z1_real);
169
170 const ATOMIC x0_real = 2 * (z0_real + z1_real);
171 const ATOMIC x1_real = t2_real - t1_real;
172 const ATOMIC x2_real = 2 * (z1_imag - z0_imag);
173 const ATOMIC x3_real = -(t2_real + t1_real);
174
175 const size_t to0 = k1 * q + q - 1;
176 const size_t to1 = to0 + m;
177 const size_t to2 = to1 + m;
178 const size_t to3 = to2 + m;
179
180 VECTOR(out,ostride,to0) = x0_real;
181 VECTOR(out,ostride,to1) = x1_real;
182 VECTOR(out,ostride,to2) = x2_real;
183 VECTOR(out,ostride,to3) = x3_real;
184 }
185 return;
186 }