| 1 |
/* fft/real_pass_5.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_real,pass_5) (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 |
const TYPE(gsl_complex) twiddle4[]) |
| 31 |
{ |
| 32 |
size_t k, k1; |
| 33 |
|
| 34 |
const size_t factor = 5; |
| 35 |
const size_t m = n / factor; |
| 36 |
const size_t q = n / product; |
| 37 |
const size_t product_1 = product / factor; |
| 38 |
|
| 39 |
const ATOMIC sina = sin (2.0 * M_PI / 5.0); |
| 40 |
const ATOMIC sinb = sin (2.0 * M_PI / 10.0); |
| 41 |
|
| 42 |
for (k1 = 0; k1 < q; k1++) |
| 43 |
{ |
| 44 |
const size_t from0 = k1 * product_1; |
| 45 |
const size_t from1 = from0 + m; |
| 46 |
const size_t from2 = from1 + m; |
| 47 |
const size_t from3 = from2 + m; |
| 48 |
const size_t from4 = from3 + m; |
| 49 |
|
| 50 |
const ATOMIC z0_real = VECTOR(in,istride,from0); |
| 51 |
const ATOMIC z1_real = VECTOR(in,istride,from1); |
| 52 |
const ATOMIC z2_real = VECTOR(in,istride,from2); |
| 53 |
const ATOMIC z3_real = VECTOR(in,istride,from3); |
| 54 |
const ATOMIC z4_real = VECTOR(in,istride,from4); |
| 55 |
|
| 56 |
/* t1 = z1 + z4 */ |
| 57 |
const ATOMIC t1_real = z1_real + z4_real; |
| 58 |
|
| 59 |
/* t2 = z2 + z3 */ |
| 60 |
const ATOMIC t2_real = z2_real + z3_real; |
| 61 |
|
| 62 |
/* t3 = z1 - z4 */ |
| 63 |
const ATOMIC t3_real = z1_real - z4_real; |
| 64 |
|
| 65 |
/* t4 = z2 - z3 */ |
| 66 |
const ATOMIC t4_real = z2_real - z3_real; |
| 67 |
|
| 68 |
/* t5 = t1 + t2 */ |
| 69 |
const ATOMIC t5_real = t1_real + t2_real; |
| 70 |
|
| 71 |
/* t6 = (sqrt(5)/4)(t1 - t2) */ |
| 72 |
const ATOMIC t6_real = (sqrt (5.0) / 4.0) * (t1_real - t2_real); |
| 73 |
|
| 74 |
/* t7 = z0 - ((t5)/4) */ |
| 75 |
const ATOMIC t7_real = z0_real - t5_real / 4.0; |
| 76 |
|
| 77 |
/* t8 = t7 + t6 */ |
| 78 |
const ATOMIC t8_real = t7_real + t6_real; |
| 79 |
|
| 80 |
/* t9 = t7 - t6 */ |
| 81 |
const ATOMIC t9_real = t7_real - t6_real; |
| 82 |
|
| 83 |
/* t10 = -(sin(2 pi/5) t3 + sin(2 pi/10) t4 ) */ |
| 84 |
const ATOMIC t10_real = -sina * t3_real - sinb * t4_real; |
| 85 |
|
| 86 |
/* t11 = -(sin(2 pi/10) t3 - sin(2 pi/5) t4) */ |
| 87 |
const ATOMIC t11_real = -sinb * t3_real + sina * t4_real; |
| 88 |
|
| 89 |
/* x0 = z0 + t5 */ |
| 90 |
const ATOMIC x0_real = z0_real + t5_real; |
| 91 |
|
| 92 |
/* x1 = t8 + i t10 */ |
| 93 |
const ATOMIC x1_real = t8_real; |
| 94 |
const ATOMIC x1_imag = t10_real; |
| 95 |
|
| 96 |
/* x2 = t9 + i t11 */ |
| 97 |
const ATOMIC x2_real = t9_real; |
| 98 |
const ATOMIC x2_imag = t11_real; |
| 99 |
|
| 100 |
const size_t to0 = product * k1; |
| 101 |
const size_t to1 = to0 + 2 * product_1 - 1; |
| 102 |
const size_t to2 = to1 + 2 * product_1; |
| 103 |
|
| 104 |
VECTOR(out,ostride,to0) = x0_real; |
| 105 |
VECTOR(out,ostride,to1) = x1_real; |
| 106 |
VECTOR(out,ostride,to1 + 1) = x1_imag; |
| 107 |
VECTOR(out,ostride,to2) = x2_real; |
| 108 |
VECTOR(out,ostride,to2 + 1) = x2_imag; |
| 109 |
} |
| 110 |
|
| 111 |
if (product_1 == 1) |
| 112 |
return; |
| 113 |
|
| 114 |
for (k = 1; k < (product_1 + 1) / 2; k++) |
| 115 |
{ |
| 116 |
const ATOMIC w1_real = GSL_REAL(twiddle1[k - 1]); |
| 117 |
const ATOMIC w1_imag = -GSL_IMAG(twiddle1[k - 1]); |
| 118 |
const ATOMIC w2_real = GSL_REAL(twiddle2[k - 1]); |
| 119 |
const ATOMIC w2_imag = -GSL_IMAG(twiddle2[k - 1]); |
| 120 |
const ATOMIC w3_real = GSL_REAL(twiddle3[k - 1]); |
| 121 |
const ATOMIC w3_imag = -GSL_IMAG(twiddle3[k - 1]); |
| 122 |
const ATOMIC w4_real = GSL_REAL(twiddle4[k - 1]); |
| 123 |
const ATOMIC w4_imag = -GSL_IMAG(twiddle4[k - 1]); |
| 124 |
|
| 125 |
for (k1 = 0; k1 < q; k1++) |
| 126 |
{ |
| 127 |
const size_t from0 = k1 * product_1 + 2 * k - 1; |
| 128 |
const size_t from1 = from0 + m; |
| 129 |
const size_t from2 = from1 + m; |
| 130 |
const size_t from3 = from2 + m; |
| 131 |
const size_t from4 = from3 + m; |
| 132 |
|
| 133 |
const ATOMIC f0_real = VECTOR(in,istride,from0); |
| 134 |
const ATOMIC f0_imag = VECTOR(in,istride,from0 + 1); |
| 135 |
const ATOMIC f1_real = VECTOR(in,istride,from1); |
| 136 |
const ATOMIC f1_imag = VECTOR(in,istride,from1 + 1); |
| 137 |
const ATOMIC f2_real = VECTOR(in,istride,from2); |
| 138 |
const ATOMIC f2_imag = VECTOR(in,istride,from2 + 1); |
| 139 |
const ATOMIC f3_real = VECTOR(in,istride,from3); |
| 140 |
const ATOMIC f3_imag = VECTOR(in,istride,from3 + 1); |
| 141 |
const ATOMIC f4_real = VECTOR(in,istride,from4); |
| 142 |
const ATOMIC f4_imag = VECTOR(in,istride,from4 + 1); |
| 143 |
|
| 144 |
const ATOMIC z0_real = f0_real; |
| 145 |
const ATOMIC z0_imag = f0_imag; |
| 146 |
const ATOMIC z1_real = w1_real * f1_real - w1_imag * f1_imag; |
| 147 |
const ATOMIC z1_imag = w1_real * f1_imag + w1_imag * f1_real; |
| 148 |
const ATOMIC z2_real = w2_real * f2_real - w2_imag * f2_imag; |
| 149 |
const ATOMIC z2_imag = w2_real * f2_imag + w2_imag * f2_real; |
| 150 |
const ATOMIC z3_real = w3_real * f3_real - w3_imag * f3_imag; |
| 151 |
const ATOMIC z3_imag = w3_real * f3_imag + w3_imag * f3_real; |
| 152 |
const ATOMIC z4_real = w4_real * f4_real - w4_imag * f4_imag; |
| 153 |
const ATOMIC z4_imag = w4_real * f4_imag + w4_imag * f4_real; |
| 154 |
|
| 155 |
/* compute x = W(5) z */ |
| 156 |
|
| 157 |
/* t1 = z1 + z4 */ |
| 158 |
const ATOMIC t1_real = z1_real + z4_real; |
| 159 |
const ATOMIC t1_imag = z1_imag + z4_imag; |
| 160 |
|
| 161 |
/* t2 = z2 + z3 */ |
| 162 |
const ATOMIC t2_real = z2_real + z3_real; |
| 163 |
const ATOMIC t2_imag = z2_imag + z3_imag; |
| 164 |
|
| 165 |
/* t3 = z1 - z4 */ |
| 166 |
const ATOMIC t3_real = z1_real - z4_real; |
| 167 |
const ATOMIC t3_imag = z1_imag - z4_imag; |
| 168 |
|
| 169 |
/* t4 = z2 - z3 */ |
| 170 |
const ATOMIC t4_real = z2_real - z3_real; |
| 171 |
const ATOMIC t4_imag = z2_imag - z3_imag; |
| 172 |
|
| 173 |
/* t5 = t1 + t2 */ |
| 174 |
const ATOMIC t5_real = t1_real + t2_real; |
| 175 |
const ATOMIC t5_imag = t1_imag + t2_imag; |
| 176 |
|
| 177 |
/* t6 = (sqrt(5)/4)(t1 - t2) */ |
| 178 |
const ATOMIC t6_real = (sqrt (5.0) / 4.0) * (t1_real - t2_real); |
| 179 |
const ATOMIC t6_imag = (sqrt (5.0) / 4.0) * (t1_imag - t2_imag); |
| 180 |
|
| 181 |
/* t7 = z0 - ((t5)/4) */ |
| 182 |
const ATOMIC t7_real = z0_real - t5_real / 4.0; |
| 183 |
const ATOMIC t7_imag = z0_imag - t5_imag / 4.0; |
| 184 |
|
| 185 |
/* t8 = t7 + t6 */ |
| 186 |
const ATOMIC t8_real = t7_real + t6_real; |
| 187 |
const ATOMIC t8_imag = t7_imag + t6_imag; |
| 188 |
|
| 189 |
/* t9 = t7 - t6 */ |
| 190 |
const ATOMIC t9_real = t7_real - t6_real; |
| 191 |
const ATOMIC t9_imag = t7_imag - t6_imag; |
| 192 |
|
| 193 |
/* t10 = - (sin(2 pi/5) t3 + sin(2 pi/10) t4) */ |
| 194 |
const ATOMIC t10_real = -sina * t3_real - sinb * t4_real; |
| 195 |
const ATOMIC t10_imag = -sina * t3_imag - sinb * t4_imag; |
| 196 |
|
| 197 |
/* t11 = -(sin(2 pi/10) t3 - sin(2 pi/5) t4) */ |
| 198 |
const ATOMIC t11_real = -sinb * t3_real + sina * t4_real; |
| 199 |
const ATOMIC t11_imag = -sinb * t3_imag + sina * t4_imag; |
| 200 |
|
| 201 |
/* x0 = z0 + t5 */ |
| 202 |
const ATOMIC x0_real = z0_real + t5_real; |
| 203 |
const ATOMIC x0_imag = z0_imag + t5_imag; |
| 204 |
|
| 205 |
/* x1 = t8 + i t10 */ |
| 206 |
const ATOMIC x1_real = t8_real - t10_imag; |
| 207 |
const ATOMIC x1_imag = t8_imag + t10_real; |
| 208 |
|
| 209 |
/* x2 = t9 + i t11 */ |
| 210 |
const ATOMIC x2_real = t9_real - t11_imag; |
| 211 |
const ATOMIC x2_imag = t9_imag + t11_real; |
| 212 |
|
| 213 |
/* x3 = t9 - i t11 */ |
| 214 |
const ATOMIC x3_real = t9_real + t11_imag; |
| 215 |
const ATOMIC x3_imag = t9_imag - t11_real; |
| 216 |
|
| 217 |
/* x4 = t8 - i t10 */ |
| 218 |
const ATOMIC x4_real = t8_real + t10_imag; |
| 219 |
const ATOMIC x4_imag = t8_imag - t10_real; |
| 220 |
|
| 221 |
const size_t to0 = k1 * product + 2 * k - 1; |
| 222 |
const size_t to1 = to0 + 2 * product_1; |
| 223 |
const size_t to2 = to1 + 2 * product_1; |
| 224 |
const size_t to3 = 2 * product_1 - 2 * k + k1 * product - 1; |
| 225 |
const size_t to4 = to3 + 2 * product_1; |
| 226 |
|
| 227 |
VECTOR(out,ostride,to0) = x0_real; |
| 228 |
VECTOR(out,ostride,to0 + 1) = x0_imag; |
| 229 |
|
| 230 |
VECTOR(out,ostride,to1) = x1_real; |
| 231 |
VECTOR(out,ostride,to1 + 1) = x1_imag; |
| 232 |
|
| 233 |
VECTOR(out,ostride,to2) = x2_real; |
| 234 |
VECTOR(out,ostride,to2 + 1) = x2_imag; |
| 235 |
|
| 236 |
VECTOR(out,ostride,to3) = x4_real; |
| 237 |
VECTOR(out,ostride,to3 + 1) = -x4_imag; |
| 238 |
|
| 239 |
VECTOR(out,ostride,to4) = x3_real; |
| 240 |
VECTOR(out,ostride,to4 + 1) = -x3_imag; |
| 241 |
} |
| 242 |
} |
| 243 |
|
| 244 |
if (product_1 % 2 == 1) |
| 245 |
return; |
| 246 |
|
| 247 |
for (k1 = 0; k1 < q; k1++) |
| 248 |
{ |
| 249 |
const size_t from0 = k1 * product_1 + product_1 - 1; |
| 250 |
const size_t from1 = from0 + m; |
| 251 |
const size_t from2 = from1 + m; |
| 252 |
const size_t from3 = from2 + m; |
| 253 |
const size_t from4 = from3 + m; |
| 254 |
|
| 255 |
const ATOMIC z0_real = VECTOR(in,istride,from0); |
| 256 |
const ATOMIC z1_real = VECTOR(in,istride,from1); |
| 257 |
const ATOMIC z2_real = VECTOR(in,istride,from2); |
| 258 |
const ATOMIC z3_real = VECTOR(in,istride,from3); |
| 259 |
const ATOMIC z4_real = VECTOR(in,istride,from4); |
| 260 |
|
| 261 |
const ATOMIC t1 = z1_real - z4_real; |
| 262 |
const ATOMIC t2 = z1_real + z4_real; |
| 263 |
const ATOMIC t3 = z2_real - z3_real; |
| 264 |
const ATOMIC t4 = z2_real + z3_real; |
| 265 |
const ATOMIC t5 = t1 - t3; |
| 266 |
const ATOMIC t6 = z0_real + t5 / 4.0; |
| 267 |
const ATOMIC t7 = (sqrt (5.0) / 4.0) * (t1 + t3); |
| 268 |
|
| 269 |
const size_t to0 = k1 * product + product_1 - 1; |
| 270 |
const size_t to1 = to0 + 2 * product_1; |
| 271 |
const size_t to2 = to1 + 2 * product_1; |
| 272 |
|
| 273 |
VECTOR(out,ostride,to0) = t6 + t7; |
| 274 |
VECTOR(out,ostride,to0 + 1) = -sinb * t2 - sina * t4; |
| 275 |
|
| 276 |
VECTOR(out,ostride,to1) = t6 - t7; |
| 277 |
VECTOR(out,ostride,to1 + 1) = -sina * t2 + sinb * t4; |
| 278 |
|
| 279 |
VECTOR(out,ostride,to2) = z0_real - t5; |
| 280 |
} |
| 281 |
|
| 282 |
return; |
| 283 |
} |