Team Riedel - display
Dependencies: LCD_fonts SPI_TFT_ILI9341 CMSIS_DSP_401_without_cm4 mbed-src SDFileSystem wavfile
arm_cfft_f32.c@9:5a860b9c8a6a, 2015-12-13 (annotated)
- Committer:
- EricLew
- Date:
- Sun Dec 13 16:46:14 2015 +0000
- Revision:
- 9:5a860b9c8a6a
Added DFSDM core functionality
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 9:5a860b9c8a6a | 1 | /* ---------------------------------------------------------------------- |
EricLew | 9:5a860b9c8a6a | 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
EricLew | 9:5a860b9c8a6a | 3 | * |
EricLew | 9:5a860b9c8a6a | 4 | * $Date: 19. March 2015 |
EricLew | 9:5a860b9c8a6a | 5 | * $Revision: V.1.4.5 |
EricLew | 9:5a860b9c8a6a | 6 | * |
EricLew | 9:5a860b9c8a6a | 7 | * Project: CMSIS DSP Library |
EricLew | 9:5a860b9c8a6a | 8 | * Title: arm_cfft_f32.c |
EricLew | 9:5a860b9c8a6a | 9 | * |
EricLew | 9:5a860b9c8a6a | 10 | * Description: Combined Radix Decimation in Frequency CFFT Floating point processing function |
EricLew | 9:5a860b9c8a6a | 11 | * |
EricLew | 9:5a860b9c8a6a | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
EricLew | 9:5a860b9c8a6a | 13 | * |
EricLew | 9:5a860b9c8a6a | 14 | * Redistribution and use in source and binary forms, with or without |
EricLew | 9:5a860b9c8a6a | 15 | * modification, are permitted provided that the following conditions |
EricLew | 9:5a860b9c8a6a | 16 | * are met: |
EricLew | 9:5a860b9c8a6a | 17 | * - Redistributions of source code must retain the above copyright |
EricLew | 9:5a860b9c8a6a | 18 | * notice, this list of conditions and the following disclaimer. |
EricLew | 9:5a860b9c8a6a | 19 | * - Redistributions in binary form must reproduce the above copyright |
EricLew | 9:5a860b9c8a6a | 20 | * notice, this list of conditions and the following disclaimer in |
EricLew | 9:5a860b9c8a6a | 21 | * the documentation and/or other materials provided with the |
EricLew | 9:5a860b9c8a6a | 22 | * distribution. |
EricLew | 9:5a860b9c8a6a | 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
EricLew | 9:5a860b9c8a6a | 24 | * may be used to endorse or promote products derived from this |
EricLew | 9:5a860b9c8a6a | 25 | * software without specific prior written permission. |
EricLew | 9:5a860b9c8a6a | 26 | * |
EricLew | 9:5a860b9c8a6a | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
EricLew | 9:5a860b9c8a6a | 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
EricLew | 9:5a860b9c8a6a | 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
EricLew | 9:5a860b9c8a6a | 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
EricLew | 9:5a860b9c8a6a | 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
EricLew | 9:5a860b9c8a6a | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
EricLew | 9:5a860b9c8a6a | 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
EricLew | 9:5a860b9c8a6a | 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 9:5a860b9c8a6a | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
EricLew | 9:5a860b9c8a6a | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
EricLew | 9:5a860b9c8a6a | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
EricLew | 9:5a860b9c8a6a | 38 | * POSSIBILITY OF SUCH DAMAGE. |
EricLew | 9:5a860b9c8a6a | 39 | * -------------------------------------------------------------------- */ |
EricLew | 9:5a860b9c8a6a | 40 | |
EricLew | 9:5a860b9c8a6a | 41 | #include "arm_math.h" |
EricLew | 9:5a860b9c8a6a | 42 | #include "arm_common_tables.h" |
EricLew | 9:5a860b9c8a6a | 43 | |
EricLew | 9:5a860b9c8a6a | 44 | extern void arm_radix8_butterfly_f32( |
EricLew | 9:5a860b9c8a6a | 45 | float32_t * pSrc, |
EricLew | 9:5a860b9c8a6a | 46 | uint16_t fftLen, |
EricLew | 9:5a860b9c8a6a | 47 | const float32_t * pCoef, |
EricLew | 9:5a860b9c8a6a | 48 | uint16_t twidCoefModifier); |
EricLew | 9:5a860b9c8a6a | 49 | |
EricLew | 9:5a860b9c8a6a | 50 | extern void arm_bitreversal_32( |
EricLew | 9:5a860b9c8a6a | 51 | uint32_t * pSrc, |
EricLew | 9:5a860b9c8a6a | 52 | const uint16_t bitRevLen, |
EricLew | 9:5a860b9c8a6a | 53 | const uint16_t * pBitRevTable); |
EricLew | 9:5a860b9c8a6a | 54 | |
EricLew | 9:5a860b9c8a6a | 55 | /** |
EricLew | 9:5a860b9c8a6a | 56 | * @ingroup groupTransforms |
EricLew | 9:5a860b9c8a6a | 57 | */ |
EricLew | 9:5a860b9c8a6a | 58 | |
EricLew | 9:5a860b9c8a6a | 59 | /** |
EricLew | 9:5a860b9c8a6a | 60 | * @defgroup ComplexFFT Complex FFT Functions |
EricLew | 9:5a860b9c8a6a | 61 | * |
EricLew | 9:5a860b9c8a6a | 62 | * \par |
EricLew | 9:5a860b9c8a6a | 63 | * The Fast Fourier Transform (FFT) is an efficient algorithm for computing the |
EricLew | 9:5a860b9c8a6a | 64 | * Discrete Fourier Transform (DFT). The FFT can be orders of magnitude faster |
EricLew | 9:5a860b9c8a6a | 65 | * than the DFT, especially for long lengths. |
EricLew | 9:5a860b9c8a6a | 66 | * The algorithms described in this section |
EricLew | 9:5a860b9c8a6a | 67 | * operate on complex data. A separate set of functions is devoted to handling |
EricLew | 9:5a860b9c8a6a | 68 | * of real sequences. |
EricLew | 9:5a860b9c8a6a | 69 | * \par |
EricLew | 9:5a860b9c8a6a | 70 | * There are separate algorithms for handling floating-point, Q15, and Q31 data |
EricLew | 9:5a860b9c8a6a | 71 | * types. The algorithms available for each data type are described next. |
EricLew | 9:5a860b9c8a6a | 72 | * \par |
EricLew | 9:5a860b9c8a6a | 73 | * The FFT functions operate in-place. That is, the array holding the input data |
EricLew | 9:5a860b9c8a6a | 74 | * will also be used to hold the corresponding result. The input data is complex |
EricLew | 9:5a860b9c8a6a | 75 | * and contains <code>2*fftLen</code> interleaved values as shown below. |
EricLew | 9:5a860b9c8a6a | 76 | * <pre> {real[0], imag[0], real[1], imag[1],..} </pre> |
EricLew | 9:5a860b9c8a6a | 77 | * The FFT result will be contained in the same array and the frequency domain |
EricLew | 9:5a860b9c8a6a | 78 | * values will have the same interleaving. |
EricLew | 9:5a860b9c8a6a | 79 | * |
EricLew | 9:5a860b9c8a6a | 80 | * \par Floating-point |
EricLew | 9:5a860b9c8a6a | 81 | * The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-8 |
EricLew | 9:5a860b9c8a6a | 82 | * stages are performed along with a single radix-2 or radix-4 stage, as needed. |
EricLew | 9:5a860b9c8a6a | 83 | * The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses |
EricLew | 9:5a860b9c8a6a | 84 | * a different twiddle factor table. |
EricLew | 9:5a860b9c8a6a | 85 | * \par |
EricLew | 9:5a860b9c8a6a | 86 | * The function uses the standard FFT definition and output values may grow by a |
EricLew | 9:5a860b9c8a6a | 87 | * factor of <code>fftLen</code> when computing the forward transform. The |
EricLew | 9:5a860b9c8a6a | 88 | * inverse transform includes a scale of <code>1/fftLen</code> as part of the |
EricLew | 9:5a860b9c8a6a | 89 | * calculation and this matches the textbook definition of the inverse FFT. |
EricLew | 9:5a860b9c8a6a | 90 | * \par |
EricLew | 9:5a860b9c8a6a | 91 | * Pre-initialized data structures containing twiddle factors and bit reversal |
EricLew | 9:5a860b9c8a6a | 92 | * tables are provided and defined in <code>arm_const_structs.h</code>. Include |
EricLew | 9:5a860b9c8a6a | 93 | * this header in your function and then pass one of the constant structures as |
EricLew | 9:5a860b9c8a6a | 94 | * an argument to arm_cfft_f32. For example: |
EricLew | 9:5a860b9c8a6a | 95 | * \par |
EricLew | 9:5a860b9c8a6a | 96 | * <code>arm_cfft_f32(arm_cfft_sR_f32_len64, pSrc, 1, 1)</code> |
EricLew | 9:5a860b9c8a6a | 97 | * \par |
EricLew | 9:5a860b9c8a6a | 98 | * computes a 64-point inverse complex FFT including bit reversal. |
EricLew | 9:5a860b9c8a6a | 99 | * The data structures are treated as constant data and not modified during the |
EricLew | 9:5a860b9c8a6a | 100 | * calculation. The same data structure can be reused for multiple transforms |
EricLew | 9:5a860b9c8a6a | 101 | * including mixing forward and inverse transforms. |
EricLew | 9:5a860b9c8a6a | 102 | * \par |
EricLew | 9:5a860b9c8a6a | 103 | * Earlier releases of the library provided separate radix-2 and radix-4 |
EricLew | 9:5a860b9c8a6a | 104 | * algorithms that operated on floating-point data. These functions are still |
EricLew | 9:5a860b9c8a6a | 105 | * provided but are deprecated. The older functions are slower and less general |
EricLew | 9:5a860b9c8a6a | 106 | * than the new functions. |
EricLew | 9:5a860b9c8a6a | 107 | * \par |
EricLew | 9:5a860b9c8a6a | 108 | * An example of initialization of the constants for the arm_cfft_f32 function follows: |
EricLew | 9:5a860b9c8a6a | 109 | * \code |
EricLew | 9:5a860b9c8a6a | 110 | * const static arm_cfft_instance_f32 *S; |
EricLew | 9:5a860b9c8a6a | 111 | * ... |
EricLew | 9:5a860b9c8a6a | 112 | * switch (length) { |
EricLew | 9:5a860b9c8a6a | 113 | * case 16: |
EricLew | 9:5a860b9c8a6a | 114 | * S = &arm_cfft_sR_f32_len16; |
EricLew | 9:5a860b9c8a6a | 115 | * break; |
EricLew | 9:5a860b9c8a6a | 116 | * case 32: |
EricLew | 9:5a860b9c8a6a | 117 | * S = &arm_cfft_sR_f32_len32; |
EricLew | 9:5a860b9c8a6a | 118 | * break; |
EricLew | 9:5a860b9c8a6a | 119 | * case 64: |
EricLew | 9:5a860b9c8a6a | 120 | * S = &arm_cfft_sR_f32_len64; |
EricLew | 9:5a860b9c8a6a | 121 | * break; |
EricLew | 9:5a860b9c8a6a | 122 | * case 128: |
EricLew | 9:5a860b9c8a6a | 123 | * S = &arm_cfft_sR_f32_len128; |
EricLew | 9:5a860b9c8a6a | 124 | * break; |
EricLew | 9:5a860b9c8a6a | 125 | * case 256: |
EricLew | 9:5a860b9c8a6a | 126 | * S = &arm_cfft_sR_f32_len256; |
EricLew | 9:5a860b9c8a6a | 127 | * break; |
EricLew | 9:5a860b9c8a6a | 128 | * case 512: |
EricLew | 9:5a860b9c8a6a | 129 | * S = &arm_cfft_sR_f32_len512; |
EricLew | 9:5a860b9c8a6a | 130 | * break; |
EricLew | 9:5a860b9c8a6a | 131 | * case 1024: |
EricLew | 9:5a860b9c8a6a | 132 | * S = &arm_cfft_sR_f32_len1024; |
EricLew | 9:5a860b9c8a6a | 133 | * break; |
EricLew | 9:5a860b9c8a6a | 134 | * case 2048: |
EricLew | 9:5a860b9c8a6a | 135 | * S = &arm_cfft_sR_f32_len2048; |
EricLew | 9:5a860b9c8a6a | 136 | * break; |
EricLew | 9:5a860b9c8a6a | 137 | * case 4096: |
EricLew | 9:5a860b9c8a6a | 138 | * S = &arm_cfft_sR_f32_len4096; |
EricLew | 9:5a860b9c8a6a | 139 | * break; |
EricLew | 9:5a860b9c8a6a | 140 | * } |
EricLew | 9:5a860b9c8a6a | 141 | * \endcode |
EricLew | 9:5a860b9c8a6a | 142 | * \par Q15 and Q31 |
EricLew | 9:5a860b9c8a6a | 143 | * The floating-point complex FFT uses a mixed-radix algorithm. Multiple radix-4 |
EricLew | 9:5a860b9c8a6a | 144 | * stages are performed along with a single radix-2 stage, as needed. |
EricLew | 9:5a860b9c8a6a | 145 | * The algorithm supports lengths of [16, 32, 64, ..., 4096] and each length uses |
EricLew | 9:5a860b9c8a6a | 146 | * a different twiddle factor table. |
EricLew | 9:5a860b9c8a6a | 147 | * \par |
EricLew | 9:5a860b9c8a6a | 148 | * The function uses the standard FFT definition and output values may grow by a |
EricLew | 9:5a860b9c8a6a | 149 | * factor of <code>fftLen</code> when computing the forward transform. The |
EricLew | 9:5a860b9c8a6a | 150 | * inverse transform includes a scale of <code>1/fftLen</code> as part of the |
EricLew | 9:5a860b9c8a6a | 151 | * calculation and this matches the textbook definition of the inverse FFT. |
EricLew | 9:5a860b9c8a6a | 152 | * \par |
EricLew | 9:5a860b9c8a6a | 153 | * Pre-initialized data structures containing twiddle factors and bit reversal |
EricLew | 9:5a860b9c8a6a | 154 | * tables are provided and defined in <code>arm_const_structs.h</code>. Include |
EricLew | 9:5a860b9c8a6a | 155 | * this header in your function and then pass one of the constant structures as |
EricLew | 9:5a860b9c8a6a | 156 | * an argument to arm_cfft_q31. For example: |
EricLew | 9:5a860b9c8a6a | 157 | * \par |
EricLew | 9:5a860b9c8a6a | 158 | * <code>arm_cfft_q31(arm_cfft_sR_q31_len64, pSrc, 1, 1)</code> |
EricLew | 9:5a860b9c8a6a | 159 | * \par |
EricLew | 9:5a860b9c8a6a | 160 | * computes a 64-point inverse complex FFT including bit reversal. |
EricLew | 9:5a860b9c8a6a | 161 | * The data structures are treated as constant data and not modified during the |
EricLew | 9:5a860b9c8a6a | 162 | * calculation. The same data structure can be reused for multiple transforms |
EricLew | 9:5a860b9c8a6a | 163 | * including mixing forward and inverse transforms. |
EricLew | 9:5a860b9c8a6a | 164 | * \par |
EricLew | 9:5a860b9c8a6a | 165 | * Earlier releases of the library provided separate radix-2 and radix-4 |
EricLew | 9:5a860b9c8a6a | 166 | * algorithms that operated on floating-point data. These functions are still |
EricLew | 9:5a860b9c8a6a | 167 | * provided but are deprecated. The older functions are slower and less general |
EricLew | 9:5a860b9c8a6a | 168 | * than the new functions. |
EricLew | 9:5a860b9c8a6a | 169 | * \par |
EricLew | 9:5a860b9c8a6a | 170 | * An example of initialization of the constants for the arm_cfft_q31 function follows: |
EricLew | 9:5a860b9c8a6a | 171 | * \code |
EricLew | 9:5a860b9c8a6a | 172 | * const static arm_cfft_instance_q31 *S; |
EricLew | 9:5a860b9c8a6a | 173 | * ... |
EricLew | 9:5a860b9c8a6a | 174 | * switch (length) { |
EricLew | 9:5a860b9c8a6a | 175 | * case 16: |
EricLew | 9:5a860b9c8a6a | 176 | * S = &arm_cfft_sR_q31_len16; |
EricLew | 9:5a860b9c8a6a | 177 | * break; |
EricLew | 9:5a860b9c8a6a | 178 | * case 32: |
EricLew | 9:5a860b9c8a6a | 179 | * S = &arm_cfft_sR_q31_len32; |
EricLew | 9:5a860b9c8a6a | 180 | * break; |
EricLew | 9:5a860b9c8a6a | 181 | * case 64: |
EricLew | 9:5a860b9c8a6a | 182 | * S = &arm_cfft_sR_q31_len64; |
EricLew | 9:5a860b9c8a6a | 183 | * break; |
EricLew | 9:5a860b9c8a6a | 184 | * case 128: |
EricLew | 9:5a860b9c8a6a | 185 | * S = &arm_cfft_sR_q31_len128; |
EricLew | 9:5a860b9c8a6a | 186 | * break; |
EricLew | 9:5a860b9c8a6a | 187 | * case 256: |
EricLew | 9:5a860b9c8a6a | 188 | * S = &arm_cfft_sR_q31_len256; |
EricLew | 9:5a860b9c8a6a | 189 | * break; |
EricLew | 9:5a860b9c8a6a | 190 | * case 512: |
EricLew | 9:5a860b9c8a6a | 191 | * S = &arm_cfft_sR_q31_len512; |
EricLew | 9:5a860b9c8a6a | 192 | * break; |
EricLew | 9:5a860b9c8a6a | 193 | * case 1024: |
EricLew | 9:5a860b9c8a6a | 194 | * S = &arm_cfft_sR_q31_len1024; |
EricLew | 9:5a860b9c8a6a | 195 | * break; |
EricLew | 9:5a860b9c8a6a | 196 | * case 2048: |
EricLew | 9:5a860b9c8a6a | 197 | * S = &arm_cfft_sR_q31_len2048; |
EricLew | 9:5a860b9c8a6a | 198 | * break; |
EricLew | 9:5a860b9c8a6a | 199 | * case 4096: |
EricLew | 9:5a860b9c8a6a | 200 | * S = &arm_cfft_sR_q31_len4096; |
EricLew | 9:5a860b9c8a6a | 201 | * break; |
EricLew | 9:5a860b9c8a6a | 202 | * } |
EricLew | 9:5a860b9c8a6a | 203 | * \endcode |
EricLew | 9:5a860b9c8a6a | 204 | * |
EricLew | 9:5a860b9c8a6a | 205 | */ |
EricLew | 9:5a860b9c8a6a | 206 | |
EricLew | 9:5a860b9c8a6a | 207 | void arm_cfft_radix8by2_f32( arm_cfft_instance_f32 * S, float32_t * p1) |
EricLew | 9:5a860b9c8a6a | 208 | { |
EricLew | 9:5a860b9c8a6a | 209 | uint32_t L = S->fftLen; |
EricLew | 9:5a860b9c8a6a | 210 | float32_t * pCol1, * pCol2, * pMid1, * pMid2; |
EricLew | 9:5a860b9c8a6a | 211 | float32_t * p2 = p1 + L; |
EricLew | 9:5a860b9c8a6a | 212 | const float32_t * tw = (float32_t *) S->pTwiddle; |
EricLew | 9:5a860b9c8a6a | 213 | float32_t t1[4], t2[4], t3[4], t4[4], twR, twI; |
EricLew | 9:5a860b9c8a6a | 214 | float32_t m0, m1, m2, m3; |
EricLew | 9:5a860b9c8a6a | 215 | uint32_t l; |
EricLew | 9:5a860b9c8a6a | 216 | |
EricLew | 9:5a860b9c8a6a | 217 | pCol1 = p1; |
EricLew | 9:5a860b9c8a6a | 218 | pCol2 = p2; |
EricLew | 9:5a860b9c8a6a | 219 | |
EricLew | 9:5a860b9c8a6a | 220 | // Define new length |
EricLew | 9:5a860b9c8a6a | 221 | L >>= 1; |
EricLew | 9:5a860b9c8a6a | 222 | // Initialize mid pointers |
EricLew | 9:5a860b9c8a6a | 223 | pMid1 = p1 + L; |
EricLew | 9:5a860b9c8a6a | 224 | pMid2 = p2 + L; |
EricLew | 9:5a860b9c8a6a | 225 | |
EricLew | 9:5a860b9c8a6a | 226 | // do two dot Fourier transform |
EricLew | 9:5a860b9c8a6a | 227 | for ( l = L >> 2; l > 0; l-- ) |
EricLew | 9:5a860b9c8a6a | 228 | { |
EricLew | 9:5a860b9c8a6a | 229 | t1[0] = p1[0]; |
EricLew | 9:5a860b9c8a6a | 230 | t1[1] = p1[1]; |
EricLew | 9:5a860b9c8a6a | 231 | t1[2] = p1[2]; |
EricLew | 9:5a860b9c8a6a | 232 | t1[3] = p1[3]; |
EricLew | 9:5a860b9c8a6a | 233 | |
EricLew | 9:5a860b9c8a6a | 234 | t2[0] = p2[0]; |
EricLew | 9:5a860b9c8a6a | 235 | t2[1] = p2[1]; |
EricLew | 9:5a860b9c8a6a | 236 | t2[2] = p2[2]; |
EricLew | 9:5a860b9c8a6a | 237 | t2[3] = p2[3]; |
EricLew | 9:5a860b9c8a6a | 238 | |
EricLew | 9:5a860b9c8a6a | 239 | t3[0] = pMid1[0]; |
EricLew | 9:5a860b9c8a6a | 240 | t3[1] = pMid1[1]; |
EricLew | 9:5a860b9c8a6a | 241 | t3[2] = pMid1[2]; |
EricLew | 9:5a860b9c8a6a | 242 | t3[3] = pMid1[3]; |
EricLew | 9:5a860b9c8a6a | 243 | |
EricLew | 9:5a860b9c8a6a | 244 | t4[0] = pMid2[0]; |
EricLew | 9:5a860b9c8a6a | 245 | t4[1] = pMid2[1]; |
EricLew | 9:5a860b9c8a6a | 246 | t4[2] = pMid2[2]; |
EricLew | 9:5a860b9c8a6a | 247 | t4[3] = pMid2[3]; |
EricLew | 9:5a860b9c8a6a | 248 | |
EricLew | 9:5a860b9c8a6a | 249 | *p1++ = t1[0] + t2[0]; |
EricLew | 9:5a860b9c8a6a | 250 | *p1++ = t1[1] + t2[1]; |
EricLew | 9:5a860b9c8a6a | 251 | *p1++ = t1[2] + t2[2]; |
EricLew | 9:5a860b9c8a6a | 252 | *p1++ = t1[3] + t2[3]; // col 1 |
EricLew | 9:5a860b9c8a6a | 253 | |
EricLew | 9:5a860b9c8a6a | 254 | t2[0] = t1[0] - t2[0]; |
EricLew | 9:5a860b9c8a6a | 255 | t2[1] = t1[1] - t2[1]; |
EricLew | 9:5a860b9c8a6a | 256 | t2[2] = t1[2] - t2[2]; |
EricLew | 9:5a860b9c8a6a | 257 | t2[3] = t1[3] - t2[3]; // for col 2 |
EricLew | 9:5a860b9c8a6a | 258 | |
EricLew | 9:5a860b9c8a6a | 259 | *pMid1++ = t3[0] + t4[0]; |
EricLew | 9:5a860b9c8a6a | 260 | *pMid1++ = t3[1] + t4[1]; |
EricLew | 9:5a860b9c8a6a | 261 | *pMid1++ = t3[2] + t4[2]; |
EricLew | 9:5a860b9c8a6a | 262 | *pMid1++ = t3[3] + t4[3]; // col 1 |
EricLew | 9:5a860b9c8a6a | 263 | |
EricLew | 9:5a860b9c8a6a | 264 | t4[0] = t4[0] - t3[0]; |
EricLew | 9:5a860b9c8a6a | 265 | t4[1] = t4[1] - t3[1]; |
EricLew | 9:5a860b9c8a6a | 266 | t4[2] = t4[2] - t3[2]; |
EricLew | 9:5a860b9c8a6a | 267 | t4[3] = t4[3] - t3[3]; // for col 2 |
EricLew | 9:5a860b9c8a6a | 268 | |
EricLew | 9:5a860b9c8a6a | 269 | twR = *tw++; |
EricLew | 9:5a860b9c8a6a | 270 | twI = *tw++; |
EricLew | 9:5a860b9c8a6a | 271 | |
EricLew | 9:5a860b9c8a6a | 272 | // multiply by twiddle factors |
EricLew | 9:5a860b9c8a6a | 273 | m0 = t2[0] * twR; |
EricLew | 9:5a860b9c8a6a | 274 | m1 = t2[1] * twI; |
EricLew | 9:5a860b9c8a6a | 275 | m2 = t2[1] * twR; |
EricLew | 9:5a860b9c8a6a | 276 | m3 = t2[0] * twI; |
EricLew | 9:5a860b9c8a6a | 277 | |
EricLew | 9:5a860b9c8a6a | 278 | // R = R * Tr - I * Ti |
EricLew | 9:5a860b9c8a6a | 279 | *p2++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 280 | // I = I * Tr + R * Ti |
EricLew | 9:5a860b9c8a6a | 281 | *p2++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 282 | |
EricLew | 9:5a860b9c8a6a | 283 | // use vertical symmetry |
EricLew | 9:5a860b9c8a6a | 284 | // 0.9988 - 0.0491i <==> -0.0491 - 0.9988i |
EricLew | 9:5a860b9c8a6a | 285 | m0 = t4[0] * twI; |
EricLew | 9:5a860b9c8a6a | 286 | m1 = t4[1] * twR; |
EricLew | 9:5a860b9c8a6a | 287 | m2 = t4[1] * twI; |
EricLew | 9:5a860b9c8a6a | 288 | m3 = t4[0] * twR; |
EricLew | 9:5a860b9c8a6a | 289 | |
EricLew | 9:5a860b9c8a6a | 290 | *pMid2++ = m0 - m1; |
EricLew | 9:5a860b9c8a6a | 291 | *pMid2++ = m2 + m3; |
EricLew | 9:5a860b9c8a6a | 292 | |
EricLew | 9:5a860b9c8a6a | 293 | twR = *tw++; |
EricLew | 9:5a860b9c8a6a | 294 | twI = *tw++; |
EricLew | 9:5a860b9c8a6a | 295 | |
EricLew | 9:5a860b9c8a6a | 296 | m0 = t2[2] * twR; |
EricLew | 9:5a860b9c8a6a | 297 | m1 = t2[3] * twI; |
EricLew | 9:5a860b9c8a6a | 298 | m2 = t2[3] * twR; |
EricLew | 9:5a860b9c8a6a | 299 | m3 = t2[2] * twI; |
EricLew | 9:5a860b9c8a6a | 300 | |
EricLew | 9:5a860b9c8a6a | 301 | *p2++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 302 | *p2++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 303 | |
EricLew | 9:5a860b9c8a6a | 304 | m0 = t4[2] * twI; |
EricLew | 9:5a860b9c8a6a | 305 | m1 = t4[3] * twR; |
EricLew | 9:5a860b9c8a6a | 306 | m2 = t4[3] * twI; |
EricLew | 9:5a860b9c8a6a | 307 | m3 = t4[2] * twR; |
EricLew | 9:5a860b9c8a6a | 308 | |
EricLew | 9:5a860b9c8a6a | 309 | *pMid2++ = m0 - m1; |
EricLew | 9:5a860b9c8a6a | 310 | *pMid2++ = m2 + m3; |
EricLew | 9:5a860b9c8a6a | 311 | } |
EricLew | 9:5a860b9c8a6a | 312 | |
EricLew | 9:5a860b9c8a6a | 313 | // first col |
EricLew | 9:5a860b9c8a6a | 314 | arm_radix8_butterfly_f32( pCol1, L, (float32_t *) S->pTwiddle, 2u); |
EricLew | 9:5a860b9c8a6a | 315 | // second col |
EricLew | 9:5a860b9c8a6a | 316 | arm_radix8_butterfly_f32( pCol2, L, (float32_t *) S->pTwiddle, 2u); |
EricLew | 9:5a860b9c8a6a | 317 | } |
EricLew | 9:5a860b9c8a6a | 318 | |
EricLew | 9:5a860b9c8a6a | 319 | void arm_cfft_radix8by4_f32( arm_cfft_instance_f32 * S, float32_t * p1) |
EricLew | 9:5a860b9c8a6a | 320 | { |
EricLew | 9:5a860b9c8a6a | 321 | uint32_t L = S->fftLen >> 1; |
EricLew | 9:5a860b9c8a6a | 322 | float32_t * pCol1, *pCol2, *pCol3, *pCol4, *pEnd1, *pEnd2, *pEnd3, *pEnd4; |
EricLew | 9:5a860b9c8a6a | 323 | const float32_t *tw2, *tw3, *tw4; |
EricLew | 9:5a860b9c8a6a | 324 | float32_t * p2 = p1 + L; |
EricLew | 9:5a860b9c8a6a | 325 | float32_t * p3 = p2 + L; |
EricLew | 9:5a860b9c8a6a | 326 | float32_t * p4 = p3 + L; |
EricLew | 9:5a860b9c8a6a | 327 | float32_t t2[4], t3[4], t4[4], twR, twI; |
EricLew | 9:5a860b9c8a6a | 328 | float32_t p1ap3_0, p1sp3_0, p1ap3_1, p1sp3_1; |
EricLew | 9:5a860b9c8a6a | 329 | float32_t m0, m1, m2, m3; |
EricLew | 9:5a860b9c8a6a | 330 | uint32_t l, twMod2, twMod3, twMod4; |
EricLew | 9:5a860b9c8a6a | 331 | |
EricLew | 9:5a860b9c8a6a | 332 | pCol1 = p1; // points to real values by default |
EricLew | 9:5a860b9c8a6a | 333 | pCol2 = p2; |
EricLew | 9:5a860b9c8a6a | 334 | pCol3 = p3; |
EricLew | 9:5a860b9c8a6a | 335 | pCol4 = p4; |
EricLew | 9:5a860b9c8a6a | 336 | pEnd1 = p2 - 1; // points to imaginary values by default |
EricLew | 9:5a860b9c8a6a | 337 | pEnd2 = p3 - 1; |
EricLew | 9:5a860b9c8a6a | 338 | pEnd3 = p4 - 1; |
EricLew | 9:5a860b9c8a6a | 339 | pEnd4 = pEnd3 + L; |
EricLew | 9:5a860b9c8a6a | 340 | |
EricLew | 9:5a860b9c8a6a | 341 | tw2 = tw3 = tw4 = (float32_t *) S->pTwiddle; |
EricLew | 9:5a860b9c8a6a | 342 | |
EricLew | 9:5a860b9c8a6a | 343 | L >>= 1; |
EricLew | 9:5a860b9c8a6a | 344 | |
EricLew | 9:5a860b9c8a6a | 345 | // do four dot Fourier transform |
EricLew | 9:5a860b9c8a6a | 346 | |
EricLew | 9:5a860b9c8a6a | 347 | twMod2 = 2; |
EricLew | 9:5a860b9c8a6a | 348 | twMod3 = 4; |
EricLew | 9:5a860b9c8a6a | 349 | twMod4 = 6; |
EricLew | 9:5a860b9c8a6a | 350 | |
EricLew | 9:5a860b9c8a6a | 351 | // TOP |
EricLew | 9:5a860b9c8a6a | 352 | p1ap3_0 = p1[0] + p3[0]; |
EricLew | 9:5a860b9c8a6a | 353 | p1sp3_0 = p1[0] - p3[0]; |
EricLew | 9:5a860b9c8a6a | 354 | p1ap3_1 = p1[1] + p3[1]; |
EricLew | 9:5a860b9c8a6a | 355 | p1sp3_1 = p1[1] - p3[1]; |
EricLew | 9:5a860b9c8a6a | 356 | |
EricLew | 9:5a860b9c8a6a | 357 | // col 2 |
EricLew | 9:5a860b9c8a6a | 358 | t2[0] = p1sp3_0 + p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 359 | t2[1] = p1sp3_1 - p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 360 | // col 3 |
EricLew | 9:5a860b9c8a6a | 361 | t3[0] = p1ap3_0 - p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 362 | t3[1] = p1ap3_1 - p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 363 | // col 4 |
EricLew | 9:5a860b9c8a6a | 364 | t4[0] = p1sp3_0 - p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 365 | t4[1] = p1sp3_1 + p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 366 | // col 1 |
EricLew | 9:5a860b9c8a6a | 367 | *p1++ = p1ap3_0 + p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 368 | *p1++ = p1ap3_1 + p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 369 | |
EricLew | 9:5a860b9c8a6a | 370 | // Twiddle factors are ones |
EricLew | 9:5a860b9c8a6a | 371 | *p2++ = t2[0]; |
EricLew | 9:5a860b9c8a6a | 372 | *p2++ = t2[1]; |
EricLew | 9:5a860b9c8a6a | 373 | *p3++ = t3[0]; |
EricLew | 9:5a860b9c8a6a | 374 | *p3++ = t3[1]; |
EricLew | 9:5a860b9c8a6a | 375 | *p4++ = t4[0]; |
EricLew | 9:5a860b9c8a6a | 376 | *p4++ = t4[1]; |
EricLew | 9:5a860b9c8a6a | 377 | |
EricLew | 9:5a860b9c8a6a | 378 | tw2 += twMod2; |
EricLew | 9:5a860b9c8a6a | 379 | tw3 += twMod3; |
EricLew | 9:5a860b9c8a6a | 380 | tw4 += twMod4; |
EricLew | 9:5a860b9c8a6a | 381 | |
EricLew | 9:5a860b9c8a6a | 382 | for (l = (L - 2) >> 1; l > 0; l-- ) |
EricLew | 9:5a860b9c8a6a | 383 | { |
EricLew | 9:5a860b9c8a6a | 384 | // TOP |
EricLew | 9:5a860b9c8a6a | 385 | p1ap3_0 = p1[0] + p3[0]; |
EricLew | 9:5a860b9c8a6a | 386 | p1sp3_0 = p1[0] - p3[0]; |
EricLew | 9:5a860b9c8a6a | 387 | p1ap3_1 = p1[1] + p3[1]; |
EricLew | 9:5a860b9c8a6a | 388 | p1sp3_1 = p1[1] - p3[1]; |
EricLew | 9:5a860b9c8a6a | 389 | // col 2 |
EricLew | 9:5a860b9c8a6a | 390 | t2[0] = p1sp3_0 + p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 391 | t2[1] = p1sp3_1 - p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 392 | // col 3 |
EricLew | 9:5a860b9c8a6a | 393 | t3[0] = p1ap3_0 - p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 394 | t3[1] = p1ap3_1 - p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 395 | // col 4 |
EricLew | 9:5a860b9c8a6a | 396 | t4[0] = p1sp3_0 - p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 397 | t4[1] = p1sp3_1 + p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 398 | // col 1 - top |
EricLew | 9:5a860b9c8a6a | 399 | *p1++ = p1ap3_0 + p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 400 | *p1++ = p1ap3_1 + p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 401 | |
EricLew | 9:5a860b9c8a6a | 402 | // BOTTOM |
EricLew | 9:5a860b9c8a6a | 403 | p1ap3_1 = pEnd1[-1] + pEnd3[-1]; |
EricLew | 9:5a860b9c8a6a | 404 | p1sp3_1 = pEnd1[-1] - pEnd3[-1]; |
EricLew | 9:5a860b9c8a6a | 405 | p1ap3_0 = pEnd1[0] + pEnd3[0]; |
EricLew | 9:5a860b9c8a6a | 406 | p1sp3_0 = pEnd1[0] - pEnd3[0]; |
EricLew | 9:5a860b9c8a6a | 407 | // col 2 |
EricLew | 9:5a860b9c8a6a | 408 | t2[2] = pEnd2[0] - pEnd4[0] + p1sp3_1; |
EricLew | 9:5a860b9c8a6a | 409 | t2[3] = pEnd1[0] - pEnd3[0] - pEnd2[-1] + pEnd4[-1]; |
EricLew | 9:5a860b9c8a6a | 410 | // col 3 |
EricLew | 9:5a860b9c8a6a | 411 | t3[2] = p1ap3_1 - pEnd2[-1] - pEnd4[-1]; |
EricLew | 9:5a860b9c8a6a | 412 | t3[3] = p1ap3_0 - pEnd2[0] - pEnd4[0]; |
EricLew | 9:5a860b9c8a6a | 413 | // col 4 |
EricLew | 9:5a860b9c8a6a | 414 | t4[2] = pEnd2[0] - pEnd4[0] - p1sp3_1; |
EricLew | 9:5a860b9c8a6a | 415 | t4[3] = pEnd4[-1] - pEnd2[-1] - p1sp3_0; |
EricLew | 9:5a860b9c8a6a | 416 | // col 1 - Bottom |
EricLew | 9:5a860b9c8a6a | 417 | *pEnd1-- = p1ap3_0 + pEnd2[0] + pEnd4[0]; |
EricLew | 9:5a860b9c8a6a | 418 | *pEnd1-- = p1ap3_1 + pEnd2[-1] + pEnd4[-1]; |
EricLew | 9:5a860b9c8a6a | 419 | |
EricLew | 9:5a860b9c8a6a | 420 | // COL 2 |
EricLew | 9:5a860b9c8a6a | 421 | // read twiddle factors |
EricLew | 9:5a860b9c8a6a | 422 | twR = *tw2++; |
EricLew | 9:5a860b9c8a6a | 423 | twI = *tw2++; |
EricLew | 9:5a860b9c8a6a | 424 | // multiply by twiddle factors |
EricLew | 9:5a860b9c8a6a | 425 | // let Z1 = a + i(b), Z2 = c + i(d) |
EricLew | 9:5a860b9c8a6a | 426 | // => Z1 * Z2 = (a*c - b*d) + i(b*c + a*d) |
EricLew | 9:5a860b9c8a6a | 427 | |
EricLew | 9:5a860b9c8a6a | 428 | // Top |
EricLew | 9:5a860b9c8a6a | 429 | m0 = t2[0] * twR; |
EricLew | 9:5a860b9c8a6a | 430 | m1 = t2[1] * twI; |
EricLew | 9:5a860b9c8a6a | 431 | m2 = t2[1] * twR; |
EricLew | 9:5a860b9c8a6a | 432 | m3 = t2[0] * twI; |
EricLew | 9:5a860b9c8a6a | 433 | |
EricLew | 9:5a860b9c8a6a | 434 | *p2++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 435 | *p2++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 436 | // use vertical symmetry col 2 |
EricLew | 9:5a860b9c8a6a | 437 | // 0.9997 - 0.0245i <==> 0.0245 - 0.9997i |
EricLew | 9:5a860b9c8a6a | 438 | // Bottom |
EricLew | 9:5a860b9c8a6a | 439 | m0 = t2[3] * twI; |
EricLew | 9:5a860b9c8a6a | 440 | m1 = t2[2] * twR; |
EricLew | 9:5a860b9c8a6a | 441 | m2 = t2[2] * twI; |
EricLew | 9:5a860b9c8a6a | 442 | m3 = t2[3] * twR; |
EricLew | 9:5a860b9c8a6a | 443 | |
EricLew | 9:5a860b9c8a6a | 444 | *pEnd2-- = m0 - m1; |
EricLew | 9:5a860b9c8a6a | 445 | *pEnd2-- = m2 + m3; |
EricLew | 9:5a860b9c8a6a | 446 | |
EricLew | 9:5a860b9c8a6a | 447 | // COL 3 |
EricLew | 9:5a860b9c8a6a | 448 | twR = tw3[0]; |
EricLew | 9:5a860b9c8a6a | 449 | twI = tw3[1]; |
EricLew | 9:5a860b9c8a6a | 450 | tw3 += twMod3; |
EricLew | 9:5a860b9c8a6a | 451 | // Top |
EricLew | 9:5a860b9c8a6a | 452 | m0 = t3[0] * twR; |
EricLew | 9:5a860b9c8a6a | 453 | m1 = t3[1] * twI; |
EricLew | 9:5a860b9c8a6a | 454 | m2 = t3[1] * twR; |
EricLew | 9:5a860b9c8a6a | 455 | m3 = t3[0] * twI; |
EricLew | 9:5a860b9c8a6a | 456 | |
EricLew | 9:5a860b9c8a6a | 457 | *p3++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 458 | *p3++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 459 | // use vertical symmetry col 3 |
EricLew | 9:5a860b9c8a6a | 460 | // 0.9988 - 0.0491i <==> -0.9988 - 0.0491i |
EricLew | 9:5a860b9c8a6a | 461 | // Bottom |
EricLew | 9:5a860b9c8a6a | 462 | m0 = -t3[3] * twR; |
EricLew | 9:5a860b9c8a6a | 463 | m1 = t3[2] * twI; |
EricLew | 9:5a860b9c8a6a | 464 | m2 = t3[2] * twR; |
EricLew | 9:5a860b9c8a6a | 465 | m3 = t3[3] * twI; |
EricLew | 9:5a860b9c8a6a | 466 | |
EricLew | 9:5a860b9c8a6a | 467 | *pEnd3-- = m0 - m1; |
EricLew | 9:5a860b9c8a6a | 468 | *pEnd3-- = m3 - m2; |
EricLew | 9:5a860b9c8a6a | 469 | |
EricLew | 9:5a860b9c8a6a | 470 | // COL 4 |
EricLew | 9:5a860b9c8a6a | 471 | twR = tw4[0]; |
EricLew | 9:5a860b9c8a6a | 472 | twI = tw4[1]; |
EricLew | 9:5a860b9c8a6a | 473 | tw4 += twMod4; |
EricLew | 9:5a860b9c8a6a | 474 | // Top |
EricLew | 9:5a860b9c8a6a | 475 | m0 = t4[0] * twR; |
EricLew | 9:5a860b9c8a6a | 476 | m1 = t4[1] * twI; |
EricLew | 9:5a860b9c8a6a | 477 | m2 = t4[1] * twR; |
EricLew | 9:5a860b9c8a6a | 478 | m3 = t4[0] * twI; |
EricLew | 9:5a860b9c8a6a | 479 | |
EricLew | 9:5a860b9c8a6a | 480 | *p4++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 481 | *p4++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 482 | // use vertical symmetry col 4 |
EricLew | 9:5a860b9c8a6a | 483 | // 0.9973 - 0.0736i <==> -0.0736 + 0.9973i |
EricLew | 9:5a860b9c8a6a | 484 | // Bottom |
EricLew | 9:5a860b9c8a6a | 485 | m0 = t4[3] * twI; |
EricLew | 9:5a860b9c8a6a | 486 | m1 = t4[2] * twR; |
EricLew | 9:5a860b9c8a6a | 487 | m2 = t4[2] * twI; |
EricLew | 9:5a860b9c8a6a | 488 | m3 = t4[3] * twR; |
EricLew | 9:5a860b9c8a6a | 489 | |
EricLew | 9:5a860b9c8a6a | 490 | *pEnd4-- = m0 - m1; |
EricLew | 9:5a860b9c8a6a | 491 | *pEnd4-- = m2 + m3; |
EricLew | 9:5a860b9c8a6a | 492 | } |
EricLew | 9:5a860b9c8a6a | 493 | |
EricLew | 9:5a860b9c8a6a | 494 | //MIDDLE |
EricLew | 9:5a860b9c8a6a | 495 | // Twiddle factors are |
EricLew | 9:5a860b9c8a6a | 496 | // 1.0000 0.7071-0.7071i -1.0000i -0.7071-0.7071i |
EricLew | 9:5a860b9c8a6a | 497 | p1ap3_0 = p1[0] + p3[0]; |
EricLew | 9:5a860b9c8a6a | 498 | p1sp3_0 = p1[0] - p3[0]; |
EricLew | 9:5a860b9c8a6a | 499 | p1ap3_1 = p1[1] + p3[1]; |
EricLew | 9:5a860b9c8a6a | 500 | p1sp3_1 = p1[1] - p3[1]; |
EricLew | 9:5a860b9c8a6a | 501 | |
EricLew | 9:5a860b9c8a6a | 502 | // col 2 |
EricLew | 9:5a860b9c8a6a | 503 | t2[0] = p1sp3_0 + p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 504 | t2[1] = p1sp3_1 - p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 505 | // col 3 |
EricLew | 9:5a860b9c8a6a | 506 | t3[0] = p1ap3_0 - p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 507 | t3[1] = p1ap3_1 - p2[1] - p4[1]; |
EricLew | 9:5a860b9c8a6a | 508 | // col 4 |
EricLew | 9:5a860b9c8a6a | 509 | t4[0] = p1sp3_0 - p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 510 | t4[1] = p1sp3_1 + p2[0] - p4[0]; |
EricLew | 9:5a860b9c8a6a | 511 | // col 1 - Top |
EricLew | 9:5a860b9c8a6a | 512 | *p1++ = p1ap3_0 + p2[0] + p4[0]; |
EricLew | 9:5a860b9c8a6a | 513 | *p1++ = p1ap3_1 + p2[1] + p4[1]; |
EricLew | 9:5a860b9c8a6a | 514 | |
EricLew | 9:5a860b9c8a6a | 515 | // COL 2 |
EricLew | 9:5a860b9c8a6a | 516 | twR = tw2[0]; |
EricLew | 9:5a860b9c8a6a | 517 | twI = tw2[1]; |
EricLew | 9:5a860b9c8a6a | 518 | |
EricLew | 9:5a860b9c8a6a | 519 | m0 = t2[0] * twR; |
EricLew | 9:5a860b9c8a6a | 520 | m1 = t2[1] * twI; |
EricLew | 9:5a860b9c8a6a | 521 | m2 = t2[1] * twR; |
EricLew | 9:5a860b9c8a6a | 522 | m3 = t2[0] * twI; |
EricLew | 9:5a860b9c8a6a | 523 | |
EricLew | 9:5a860b9c8a6a | 524 | *p2++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 525 | *p2++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 526 | // COL 3 |
EricLew | 9:5a860b9c8a6a | 527 | twR = tw3[0]; |
EricLew | 9:5a860b9c8a6a | 528 | twI = tw3[1]; |
EricLew | 9:5a860b9c8a6a | 529 | |
EricLew | 9:5a860b9c8a6a | 530 | m0 = t3[0] * twR; |
EricLew | 9:5a860b9c8a6a | 531 | m1 = t3[1] * twI; |
EricLew | 9:5a860b9c8a6a | 532 | m2 = t3[1] * twR; |
EricLew | 9:5a860b9c8a6a | 533 | m3 = t3[0] * twI; |
EricLew | 9:5a860b9c8a6a | 534 | |
EricLew | 9:5a860b9c8a6a | 535 | *p3++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 536 | *p3++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 537 | // COL 4 |
EricLew | 9:5a860b9c8a6a | 538 | twR = tw4[0]; |
EricLew | 9:5a860b9c8a6a | 539 | twI = tw4[1]; |
EricLew | 9:5a860b9c8a6a | 540 | |
EricLew | 9:5a860b9c8a6a | 541 | m0 = t4[0] * twR; |
EricLew | 9:5a860b9c8a6a | 542 | m1 = t4[1] * twI; |
EricLew | 9:5a860b9c8a6a | 543 | m2 = t4[1] * twR; |
EricLew | 9:5a860b9c8a6a | 544 | m3 = t4[0] * twI; |
EricLew | 9:5a860b9c8a6a | 545 | |
EricLew | 9:5a860b9c8a6a | 546 | *p4++ = m0 + m1; |
EricLew | 9:5a860b9c8a6a | 547 | *p4++ = m2 - m3; |
EricLew | 9:5a860b9c8a6a | 548 | |
EricLew | 9:5a860b9c8a6a | 549 | // first col |
EricLew | 9:5a860b9c8a6a | 550 | arm_radix8_butterfly_f32( pCol1, L, (float32_t *) S->pTwiddle, 4u); |
EricLew | 9:5a860b9c8a6a | 551 | // second col |
EricLew | 9:5a860b9c8a6a | 552 | arm_radix8_butterfly_f32( pCol2, L, (float32_t *) S->pTwiddle, 4u); |
EricLew | 9:5a860b9c8a6a | 553 | // third col |
EricLew | 9:5a860b9c8a6a | 554 | arm_radix8_butterfly_f32( pCol3, L, (float32_t *) S->pTwiddle, 4u); |
EricLew | 9:5a860b9c8a6a | 555 | // fourth col |
EricLew | 9:5a860b9c8a6a | 556 | arm_radix8_butterfly_f32( pCol4, L, (float32_t *) S->pTwiddle, 4u); |
EricLew | 9:5a860b9c8a6a | 557 | } |
EricLew | 9:5a860b9c8a6a | 558 | |
EricLew | 9:5a860b9c8a6a | 559 | /** |
EricLew | 9:5a860b9c8a6a | 560 | * @addtogroup ComplexFFT |
EricLew | 9:5a860b9c8a6a | 561 | * @{ |
EricLew | 9:5a860b9c8a6a | 562 | */ |
EricLew | 9:5a860b9c8a6a | 563 | |
EricLew | 9:5a860b9c8a6a | 564 | /** |
EricLew | 9:5a860b9c8a6a | 565 | * @details |
EricLew | 9:5a860b9c8a6a | 566 | * @brief Processing function for the floating-point complex FFT. |
EricLew | 9:5a860b9c8a6a | 567 | * @param[in] *S points to an instance of the floating-point CFFT structure. |
EricLew | 9:5a860b9c8a6a | 568 | * @param[in, out] *p1 points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place. |
EricLew | 9:5a860b9c8a6a | 569 | * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. |
EricLew | 9:5a860b9c8a6a | 570 | * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. |
EricLew | 9:5a860b9c8a6a | 571 | * @return none. |
EricLew | 9:5a860b9c8a6a | 572 | */ |
EricLew | 9:5a860b9c8a6a | 573 | |
EricLew | 9:5a860b9c8a6a | 574 | void arm_cfft_f32( |
EricLew | 9:5a860b9c8a6a | 575 | const arm_cfft_instance_f32 * S, |
EricLew | 9:5a860b9c8a6a | 576 | float32_t * p1, |
EricLew | 9:5a860b9c8a6a | 577 | uint8_t ifftFlag, |
EricLew | 9:5a860b9c8a6a | 578 | uint8_t bitReverseFlag) |
EricLew | 9:5a860b9c8a6a | 579 | { |
EricLew | 9:5a860b9c8a6a | 580 | uint32_t L = S->fftLen, l; |
EricLew | 9:5a860b9c8a6a | 581 | float32_t invL, * pSrc; |
EricLew | 9:5a860b9c8a6a | 582 | |
EricLew | 9:5a860b9c8a6a | 583 | if(ifftFlag == 1u) |
EricLew | 9:5a860b9c8a6a | 584 | { |
EricLew | 9:5a860b9c8a6a | 585 | /* Conjugate input data */ |
EricLew | 9:5a860b9c8a6a | 586 | pSrc = p1 + 1; |
EricLew | 9:5a860b9c8a6a | 587 | for(l=0; l<L; l++) |
EricLew | 9:5a860b9c8a6a | 588 | { |
EricLew | 9:5a860b9c8a6a | 589 | *pSrc = -*pSrc; |
EricLew | 9:5a860b9c8a6a | 590 | pSrc += 2; |
EricLew | 9:5a860b9c8a6a | 591 | } |
EricLew | 9:5a860b9c8a6a | 592 | } |
EricLew | 9:5a860b9c8a6a | 593 | |
EricLew | 9:5a860b9c8a6a | 594 | switch (L) |
EricLew | 9:5a860b9c8a6a | 595 | { |
EricLew | 9:5a860b9c8a6a | 596 | case 16: |
EricLew | 9:5a860b9c8a6a | 597 | case 128: |
EricLew | 9:5a860b9c8a6a | 598 | case 1024: |
EricLew | 9:5a860b9c8a6a | 599 | arm_cfft_radix8by2_f32 ( (arm_cfft_instance_f32 *) S, p1); |
EricLew | 9:5a860b9c8a6a | 600 | break; |
EricLew | 9:5a860b9c8a6a | 601 | case 32: |
EricLew | 9:5a860b9c8a6a | 602 | case 256: |
EricLew | 9:5a860b9c8a6a | 603 | case 2048: |
EricLew | 9:5a860b9c8a6a | 604 | arm_cfft_radix8by4_f32 ( (arm_cfft_instance_f32 *) S, p1); |
EricLew | 9:5a860b9c8a6a | 605 | break; |
EricLew | 9:5a860b9c8a6a | 606 | case 64: |
EricLew | 9:5a860b9c8a6a | 607 | case 512: |
EricLew | 9:5a860b9c8a6a | 608 | case 4096: |
EricLew | 9:5a860b9c8a6a | 609 | arm_radix8_butterfly_f32( p1, L, (float32_t *) S->pTwiddle, 1); |
EricLew | 9:5a860b9c8a6a | 610 | break; |
EricLew | 9:5a860b9c8a6a | 611 | } |
EricLew | 9:5a860b9c8a6a | 612 | |
EricLew | 9:5a860b9c8a6a | 613 | // if( bitReverseFlag ) |
EricLew | 9:5a860b9c8a6a | 614 | // arm_bitreversal_32((uint32_t*)p1,S->bitRevLength,S->pBitRevTable); |
EricLew | 9:5a860b9c8a6a | 615 | |
EricLew | 9:5a860b9c8a6a | 616 | if(ifftFlag == 1u) |
EricLew | 9:5a860b9c8a6a | 617 | { |
EricLew | 9:5a860b9c8a6a | 618 | invL = 1.0f/(float32_t)L; |
EricLew | 9:5a860b9c8a6a | 619 | /* Conjugate and scale output data */ |
EricLew | 9:5a860b9c8a6a | 620 | pSrc = p1; |
EricLew | 9:5a860b9c8a6a | 621 | for(l=0; l<L; l++) |
EricLew | 9:5a860b9c8a6a | 622 | { |
EricLew | 9:5a860b9c8a6a | 623 | *pSrc++ *= invL ; |
EricLew | 9:5a860b9c8a6a | 624 | *pSrc = -(*pSrc) * invL; |
EricLew | 9:5a860b9c8a6a | 625 | pSrc++; |
EricLew | 9:5a860b9c8a6a | 626 | } |
EricLew | 9:5a860b9c8a6a | 627 | } |
EricLew | 9:5a860b9c8a6a | 628 | } |
EricLew | 9:5a860b9c8a6a | 629 | |
EricLew | 9:5a860b9c8a6a | 630 | /** |
EricLew | 9:5a860b9c8a6a | 631 | * @} end of ComplexFFT group |
EricLew | 9:5a860b9c8a6a | 632 | */ |