| 1 | /* fft/hc_pass_3.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_3) (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 | { |
| 30 | size_t k, k1; |
| 31 | size_t factor, q, m, product_1; |
| 32 | |
| 33 | ATOMIC tau = sqrt (3.0) / 2.0; |
| 34 | |
| 35 | factor = 3; |
| 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 = 3 * k1 * q; |
| 43 | const size_t from1 = from0 + 2 * q - 1; |
| 44 | |
| 45 | const ATOMIC z0_real = VECTOR(in,istride,from0); |
| 46 | const ATOMIC z1_real = VECTOR(in,istride,from1); |
| 47 | const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1); |
| 48 | |
| 49 | const ATOMIC t1_real = 2 * z1_real; |
| 50 | const ATOMIC t2_real = z0_real - z1_real; |
| 51 | const ATOMIC t3_imag = 2 * tau * z1_imag; |
| 52 | |
| 53 | const size_t to0 = q * k1; |
| 54 | const size_t to1 = to0 + m; |
| 55 | const size_t to2 = to1 + m; |
| 56 | |
| 57 | VECTOR(out,ostride,to0) = z0_real + t1_real; |
| 58 | VECTOR(out,ostride,to1) = t2_real - t3_imag; |
| 59 | VECTOR(out,ostride,to2) = t2_real + t3_imag; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | if (q == 1) |
| 64 | return; |
| 65 | |
| 66 | for (k = 1; k < (q + 1) / 2; k++) |
| 67 | { |
| 68 | const ATOMIC w1_real = GSL_REAL(twiddle1[k - 1]); |
| 69 | const ATOMIC w1_imag = GSL_IMAG(twiddle1[k - 1]); |
| 70 | const ATOMIC w2_real = GSL_REAL(twiddle2[k - 1]); |
| 71 | const ATOMIC w2_imag = GSL_IMAG(twiddle2[k - 1]); |
| 72 | |
| 73 | for (k1 = 0; k1 < product_1; k1++) |
| 74 | { |
| 75 | const size_t from0 = 3 * k1 * q + 2 * k - 1; |
| 76 | const size_t from1 = from0 + 2 * q; |
| 77 | const size_t from2 = 3 * k1 * q - 2 * k + 2 * q - 1; |
| 78 | |
| 79 | const ATOMIC z0_real = VECTOR(in,istride,from0); |
| 80 | const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1); |
| 81 | |
| 82 | const ATOMIC z1_real = VECTOR(in,istride,from1); |
| 83 | const ATOMIC z1_imag = VECTOR(in,istride,from1 + 1); |
| 84 | |
| 85 | const ATOMIC z2_real = VECTOR(in,istride,from2); |
| 86 | const ATOMIC z2_imag = -VECTOR(in,istride,from2 + 1); |
| 87 | |
| 88 | /* compute x = W(3) z */ |
| 89 | |
| 90 | /* t1 = z1 + z2 */ |
| 91 | const ATOMIC t1_real = z1_real + z2_real; |
| 92 | const ATOMIC t1_imag = z1_imag + z2_imag; |
| 93 | |
| 94 | /* t2 = z0 - t1/2 */ |
| 95 | const ATOMIC t2_real = z0_real - t1_real / 2.0; |
| 96 | const ATOMIC t2_imag = z0_imag - t1_imag / 2.0; |
| 97 | |
| 98 | /* t3 = sin(pi/3)*(z1 - z2) */ |
| 99 | const ATOMIC t3_real = tau * (z1_real - z2_real); |
| 100 | const ATOMIC t3_imag = tau * (z1_imag - z2_imag); |
| 101 | |
| 102 | /* x0 = z0 + t1 */ |
| 103 | const ATOMIC x0_real = z0_real + t1_real; |
| 104 | const ATOMIC x0_imag = z0_imag + t1_imag; |
| 105 | |
| 106 | /* x1 = t2 + i t3 */ |
| 107 | const ATOMIC x1_real = t2_real - t3_imag; |
| 108 | const ATOMIC x1_imag = t2_imag + t3_real; |
| 109 | |
| 110 | /* x2 = t2 - i t3 */ |
| 111 | const ATOMIC x2_real = t2_real + t3_imag; |
| 112 | const ATOMIC x2_imag = t2_imag - t3_real; |
| 113 | |
| 114 | const size_t to0 = k1 * q + 2 * k - 1; |
| 115 | const size_t to1 = to0 + m; |
| 116 | const size_t to2 = to1 + m; |
| 117 | |
| 118 | VECTOR(out,ostride,to0) = x0_real; |
| 119 | VECTOR(out,ostride,to0 + 1) = x0_imag; |
| 120 | |
| 121 | VECTOR(out,ostride,to1) = w1_real * x1_real - w1_imag * x1_imag; |
| 122 | VECTOR(out,ostride,to1 + 1) = w1_imag * x1_real + w1_real * x1_imag; |
| 123 | |
| 124 | VECTOR(out,ostride,to2) = w2_real * x2_real - w2_imag * x2_imag; |
| 125 | VECTOR(out,ostride,to2 + 1) = w2_imag * x2_real + w2_real * x2_imag; |
| 126 | |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (q % 2 == 1) |
| 131 | return; |
| 132 | |
| 133 | for (k1 = 0; k1 < product_1; k1++) |
| 134 | { |
| 135 | const size_t from0 = 3 * k1 * q + q - 1; |
| 136 | const size_t from1 = from0 + 2 * q; |
| 137 | |
| 138 | const ATOMIC z0_real = VECTOR(in,istride,from0); |
| 139 | const ATOMIC z0_imag = VECTOR(in,istride,from0 + 1); |
| 140 | const ATOMIC z1_real = VECTOR(in,istride,from1); |
| 141 | |
| 142 | const ATOMIC t1_real = z0_real - z1_real; |
| 143 | const ATOMIC t2_real = 2 * tau * z0_imag; |
| 144 | |
| 145 | const ATOMIC x0_real = 2 * z0_real + z1_real; |
| 146 | const ATOMIC x1_real = t1_real - t2_real; |
| 147 | const ATOMIC x2_real = -t1_real - t2_real; |
| 148 | |
| 149 | const size_t to0 = k1 * q + q - 1; |
| 150 | const size_t to1 = to0 + m; |
| 151 | const size_t to2 = to1 + m; |
| 152 | |
| 153 | VECTOR(out,ostride,to0) = x0_real; |
| 154 | VECTOR(out,ostride,to1) = x1_real; |
| 155 | VECTOR(out,ostride,to2) = x2_real; |
| 156 | } |
| 157 | return; |
| 158 | } |