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