Debian Codegraph @

external/gsl/gsl_fft__hc_pass_2.c

raw
1 /* fft/hc_pass_2.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_2) (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) twiddle[])
28 {
29 size_t k, k1;
30 size_t factor, q, m, product_1;
31
32 factor = 2;
33 m = n / factor;
34 q = n / product;
35 product_1 = product / factor;
36
37 for (k1 = 0; k1 < product_1; k1++)
38 {
39 const ATOMIC r0 = VECTOR(in,istride,2 * k1 * q);
40 const ATOMIC r1 = VECTOR(in,istride,2 * k1 * q + 2 * q - 1);
41
42 const ATOMIC s0 = r0 + r1;
43 const ATOMIC s1 = r0 - r1;
44
45 VECTOR(out,ostride,q * k1) = s0;
46 VECTOR(out,ostride,q * k1 + m) = s1;
47 }
48
49 if (q == 1)
50 return;
51
52 for (k = 1; k < (q + 1) / 2; k++)
53 {
54 const ATOMIC w_real = GSL_REAL(twiddle[k - 1]);
55 const ATOMIC w_imag = GSL_IMAG(twiddle[k - 1]);
56
57 for (k1 = 0; k1 < product_1; k1++)
58 {
59 const size_t from0 = 2 * k1 * q + 2 * k - 1;
60 const size_t from1 = 2 * k1 * q - 2 * k + 2 * q - 1;
61
62 const ATOMIC z0_real = VECTOR(in,istride,from0);
63 const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1);
64
65 const ATOMIC z1_real = VECTOR(in,istride,from1);
66 const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1);
67
68 /* compute x = W(2) z */
69
70 /* x0 = z0 + z1 */
71 const ATOMIC x0_real = z0_real + z1_real;
72 const ATOMIC x0_imag = z0_imag - z1_imag;
73
74 /* x1 = z0 - z1 */
75 const ATOMIC x1_real = z0_real - z1_real;
76 const ATOMIC x1_imag = z0_imag + z1_imag;
77
78 const size_t to0 = k1 * q + 2 * k - 1;
79 const size_t to1 = to0 + m;
80
81 VECTOR(out,ostride,to0) = x0_real;
82 VECTOR(out,ostride,to0 + 1) = x0_imag;
83
84 VECTOR(out,ostride,to1) = w_real * x1_real - w_imag * x1_imag;
85 VECTOR(out,ostride,to1 + 1) = w_imag * x1_real + w_real * x1_imag;
86
87 }
88 }
89
90 if (q % 2 == 1)
91 return;
92
93 for (k1 = 0; k1 < product_1; k1++)
94 {
95 const size_t from0 = 2 * k1 * q + q - 1;
96 const size_t to0 = k1 * q + q - 1;
97 const size_t to1 = to0 + m;
98
99 VECTOR(out,ostride,to0) = 2 * VECTOR(in,istride,from0);
100 VECTOR(out,ostride,to1) = -2 * VECTOR(in,istride,from0 + 1);
101 }
102 return;
103 }