mbed-os 6.10 versione
cmsis_dsp/TransformFunctions/arm_cfft_radix2_f32.c@3:7a284390b0ce, 2013-11-08 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Nov 08 13:45:10 2013 +0000
- Revision:
- 3:7a284390b0ce
- Parent:
- 2:da51fb522205
Synchronized with git revision e69956aba2f68a2a26ac26b051f8d349deaa1ce8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:fdd22bb7aa52 | 1 | /* ---------------------------------------------------------------------- |
mbed_official | 3:7a284390b0ce | 2 | * Copyright (C) 2010-2013 ARM Limited. All rights reserved. |
emilmont | 1:fdd22bb7aa52 | 3 | * |
mbed_official | 3:7a284390b0ce | 4 | * $Date: 17. January 2013 |
mbed_official | 3:7a284390b0ce | 5 | * $Revision: V1.4.1 |
emilmont | 1:fdd22bb7aa52 | 6 | * |
emilmont | 2:da51fb522205 | 7 | * Project: CMSIS DSP Library |
emilmont | 2:da51fb522205 | 8 | * Title: arm_cfft_radix2_f32.c |
emilmont | 1:fdd22bb7aa52 | 9 | * |
emilmont | 2:da51fb522205 | 10 | * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Floating point processing function |
emilmont | 1:fdd22bb7aa52 | 11 | * |
emilmont | 1:fdd22bb7aa52 | 12 | * |
emilmont | 1:fdd22bb7aa52 | 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emilmont | 1:fdd22bb7aa52 | 14 | * |
mbed_official | 3:7a284390b0ce | 15 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 3:7a284390b0ce | 16 | * modification, are permitted provided that the following conditions |
mbed_official | 3:7a284390b0ce | 17 | * are met: |
mbed_official | 3:7a284390b0ce | 18 | * - Redistributions of source code must retain the above copyright |
mbed_official | 3:7a284390b0ce | 19 | * notice, this list of conditions and the following disclaimer. |
mbed_official | 3:7a284390b0ce | 20 | * - Redistributions in binary form must reproduce the above copyright |
mbed_official | 3:7a284390b0ce | 21 | * notice, this list of conditions and the following disclaimer in |
mbed_official | 3:7a284390b0ce | 22 | * the documentation and/or other materials provided with the |
mbed_official | 3:7a284390b0ce | 23 | * distribution. |
mbed_official | 3:7a284390b0ce | 24 | * - Neither the name of ARM LIMITED nor the names of its contributors |
mbed_official | 3:7a284390b0ce | 25 | * may be used to endorse or promote products derived from this |
mbed_official | 3:7a284390b0ce | 26 | * software without specific prior written permission. |
mbed_official | 3:7a284390b0ce | 27 | * |
mbed_official | 3:7a284390b0ce | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
mbed_official | 3:7a284390b0ce | 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
mbed_official | 3:7a284390b0ce | 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
mbed_official | 3:7a284390b0ce | 31 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
mbed_official | 3:7a284390b0ce | 32 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
mbed_official | 3:7a284390b0ce | 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
mbed_official | 3:7a284390b0ce | 34 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
mbed_official | 3:7a284390b0ce | 35 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 3:7a284390b0ce | 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
mbed_official | 3:7a284390b0ce | 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
mbed_official | 3:7a284390b0ce | 38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 3:7a284390b0ce | 39 | * POSSIBILITY OF SUCH DAMAGE. |
emilmont | 1:fdd22bb7aa52 | 40 | * -------------------------------------------------------------------- */ |
emilmont | 1:fdd22bb7aa52 | 41 | |
emilmont | 1:fdd22bb7aa52 | 42 | #include "arm_math.h" |
emilmont | 1:fdd22bb7aa52 | 43 | |
mbed_official | 3:7a284390b0ce | 44 | void arm_radix2_butterfly_f32( |
mbed_official | 3:7a284390b0ce | 45 | float32_t * pSrc, |
mbed_official | 3:7a284390b0ce | 46 | uint32_t fftLen, |
mbed_official | 3:7a284390b0ce | 47 | float32_t * pCoef, |
mbed_official | 3:7a284390b0ce | 48 | uint16_t twidCoefModifier); |
mbed_official | 3:7a284390b0ce | 49 | |
mbed_official | 3:7a284390b0ce | 50 | void arm_radix2_butterfly_inverse_f32( |
mbed_official | 3:7a284390b0ce | 51 | float32_t * pSrc, |
mbed_official | 3:7a284390b0ce | 52 | uint32_t fftLen, |
mbed_official | 3:7a284390b0ce | 53 | float32_t * pCoef, |
mbed_official | 3:7a284390b0ce | 54 | uint16_t twidCoefModifier, |
mbed_official | 3:7a284390b0ce | 55 | float32_t onebyfftLen); |
mbed_official | 3:7a284390b0ce | 56 | |
mbed_official | 3:7a284390b0ce | 57 | extern void arm_bitreversal_f32( |
mbed_official | 3:7a284390b0ce | 58 | float32_t * pSrc, |
mbed_official | 3:7a284390b0ce | 59 | uint16_t fftSize, |
mbed_official | 3:7a284390b0ce | 60 | uint16_t bitRevFactor, |
mbed_official | 3:7a284390b0ce | 61 | uint16_t * pBitRevTab); |
mbed_official | 3:7a284390b0ce | 62 | |
emilmont | 1:fdd22bb7aa52 | 63 | /** |
mbed_official | 3:7a284390b0ce | 64 | * @ingroup groupTransforms |
mbed_official | 3:7a284390b0ce | 65 | */ |
mbed_official | 3:7a284390b0ce | 66 | |
mbed_official | 3:7a284390b0ce | 67 | /** |
mbed_official | 3:7a284390b0ce | 68 | * @addtogroup ComplexFFT |
mbed_official | 3:7a284390b0ce | 69 | * @{ |
mbed_official | 3:7a284390b0ce | 70 | */ |
emilmont | 1:fdd22bb7aa52 | 71 | |
emilmont | 1:fdd22bb7aa52 | 72 | /** |
mbed_official | 3:7a284390b0ce | 73 | * @details |
mbed_official | 3:7a284390b0ce | 74 | * @brief Radix-2 CFFT/CIFFT. |
mbed_official | 3:7a284390b0ce | 75 | * @deprecated Do not use this function. It has been superceded by \ref arm_cfft_f32 and will be removed |
mbed_official | 3:7a284390b0ce | 76 | * in the future. |
mbed_official | 3:7a284390b0ce | 77 | * @param[in] *S points to an instance of the floating-point Radix-2 CFFT/CIFFT structure. |
mbed_official | 3:7a284390b0ce | 78 | * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place. |
mbed_official | 3:7a284390b0ce | 79 | * @return none. |
mbed_official | 3:7a284390b0ce | 80 | */ |
emilmont | 1:fdd22bb7aa52 | 81 | |
emilmont | 1:fdd22bb7aa52 | 82 | void arm_cfft_radix2_f32( |
mbed_official | 3:7a284390b0ce | 83 | const arm_cfft_radix2_instance_f32 * S, |
mbed_official | 3:7a284390b0ce | 84 | float32_t * pSrc) |
emilmont | 1:fdd22bb7aa52 | 85 | { |
emilmont | 1:fdd22bb7aa52 | 86 | |
mbed_official | 3:7a284390b0ce | 87 | if(S->ifftFlag == 1u) |
mbed_official | 3:7a284390b0ce | 88 | { |
mbed_official | 3:7a284390b0ce | 89 | /* Complex IFFT radix-2 */ |
mbed_official | 3:7a284390b0ce | 90 | arm_radix2_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle, |
mbed_official | 3:7a284390b0ce | 91 | S->twidCoefModifier, S->onebyfftLen); |
mbed_official | 3:7a284390b0ce | 92 | } |
mbed_official | 3:7a284390b0ce | 93 | else |
mbed_official | 3:7a284390b0ce | 94 | { |
mbed_official | 3:7a284390b0ce | 95 | /* Complex FFT radix-2 */ |
mbed_official | 3:7a284390b0ce | 96 | arm_radix2_butterfly_f32(pSrc, S->fftLen, S->pTwiddle, |
mbed_official | 3:7a284390b0ce | 97 | S->twidCoefModifier); |
mbed_official | 3:7a284390b0ce | 98 | } |
emilmont | 1:fdd22bb7aa52 | 99 | |
mbed_official | 3:7a284390b0ce | 100 | if(S->bitReverseFlag == 1u) |
mbed_official | 3:7a284390b0ce | 101 | { |
mbed_official | 3:7a284390b0ce | 102 | /* Bit Reversal */ |
mbed_official | 3:7a284390b0ce | 103 | arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); |
mbed_official | 3:7a284390b0ce | 104 | } |
emilmont | 1:fdd22bb7aa52 | 105 | |
emilmont | 1:fdd22bb7aa52 | 106 | } |
emilmont | 1:fdd22bb7aa52 | 107 | |
emilmont | 1:fdd22bb7aa52 | 108 | |
emilmont | 1:fdd22bb7aa52 | 109 | /** |
mbed_official | 3:7a284390b0ce | 110 | * @} end of ComplexFFT group |
mbed_official | 3:7a284390b0ce | 111 | */ |
emilmont | 1:fdd22bb7aa52 | 112 | |
emilmont | 1:fdd22bb7aa52 | 113 | |
emilmont | 1:fdd22bb7aa52 | 114 | |
emilmont | 1:fdd22bb7aa52 | 115 | /* ---------------------------------------------------------------------- |
emilmont | 1:fdd22bb7aa52 | 116 | ** Internal helper function used by the FFTs |
emilmont | 1:fdd22bb7aa52 | 117 | ** ------------------------------------------------------------------- */ |
emilmont | 1:fdd22bb7aa52 | 118 | |
emilmont | 1:fdd22bb7aa52 | 119 | /* |
mbed_official | 3:7a284390b0ce | 120 | * @brief Core function for the floating-point CFFT butterfly process. |
mbed_official | 3:7a284390b0ce | 121 | * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. |
mbed_official | 3:7a284390b0ce | 122 | * @param[in] fftLen length of the FFT. |
mbed_official | 3:7a284390b0ce | 123 | * @param[in] *pCoef points to the twiddle coefficient buffer. |
mbed_official | 3:7a284390b0ce | 124 | * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
mbed_official | 3:7a284390b0ce | 125 | * @return none. |
mbed_official | 3:7a284390b0ce | 126 | */ |
emilmont | 1:fdd22bb7aa52 | 127 | |
emilmont | 1:fdd22bb7aa52 | 128 | void arm_radix2_butterfly_f32( |
mbed_official | 3:7a284390b0ce | 129 | float32_t * pSrc, |
mbed_official | 3:7a284390b0ce | 130 | uint32_t fftLen, |
mbed_official | 3:7a284390b0ce | 131 | float32_t * pCoef, |
mbed_official | 3:7a284390b0ce | 132 | uint16_t twidCoefModifier) |
emilmont | 1:fdd22bb7aa52 | 133 | { |
emilmont | 1:fdd22bb7aa52 | 134 | |
mbed_official | 3:7a284390b0ce | 135 | uint32_t i, j, k, l; |
mbed_official | 3:7a284390b0ce | 136 | uint32_t n1, n2, ia; |
mbed_official | 3:7a284390b0ce | 137 | float32_t xt, yt, cosVal, sinVal; |
mbed_official | 3:7a284390b0ce | 138 | float32_t p0, p1, p2, p3; |
mbed_official | 3:7a284390b0ce | 139 | float32_t a0, a1; |
emilmont | 1:fdd22bb7aa52 | 140 | |
mbed_official | 3:7a284390b0ce | 141 | #ifndef ARM_MATH_CM0_FAMILY |
emilmont | 1:fdd22bb7aa52 | 142 | |
mbed_official | 3:7a284390b0ce | 143 | /* Initializations for the first stage */ |
mbed_official | 3:7a284390b0ce | 144 | n2 = fftLen >> 1; |
mbed_official | 3:7a284390b0ce | 145 | ia = 0; |
mbed_official | 3:7a284390b0ce | 146 | i = 0; |
emilmont | 1:fdd22bb7aa52 | 147 | |
mbed_official | 3:7a284390b0ce | 148 | // loop for groups |
mbed_official | 3:7a284390b0ce | 149 | for (k = n2; k > 0; k--) |
mbed_official | 3:7a284390b0ce | 150 | { |
emilmont | 1:fdd22bb7aa52 | 151 | cosVal = pCoef[ia * 2]; |
emilmont | 1:fdd22bb7aa52 | 152 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 153 | |
mbed_official | 3:7a284390b0ce | 154 | /* Twiddle coefficients index modifier */ |
mbed_official | 3:7a284390b0ce | 155 | ia += twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 156 | |
mbed_official | 3:7a284390b0ce | 157 | /* index calculation for the input as, */ |
mbed_official | 3:7a284390b0ce | 158 | /* pSrc[i + 0], pSrc[i + fftLen/1] */ |
mbed_official | 3:7a284390b0ce | 159 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 160 | |
mbed_official | 3:7a284390b0ce | 161 | /* Butterfly implementation */ |
mbed_official | 3:7a284390b0ce | 162 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 163 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 164 | |
mbed_official | 3:7a284390b0ce | 165 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 166 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 167 | |
mbed_official | 3:7a284390b0ce | 168 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 169 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 170 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 171 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 172 | |
mbed_official | 3:7a284390b0ce | 173 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 174 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 175 | |
mbed_official | 3:7a284390b0ce | 176 | pSrc[2 * l] = p0 + p1; |
mbed_official | 3:7a284390b0ce | 177 | pSrc[2 * l + 1] = p2 - p3; |
mbed_official | 3:7a284390b0ce | 178 | |
mbed_official | 3:7a284390b0ce | 179 | i++; |
mbed_official | 3:7a284390b0ce | 180 | } // groups loop end |
emilmont | 1:fdd22bb7aa52 | 181 | |
mbed_official | 3:7a284390b0ce | 182 | twidCoefModifier <<= 1u; |
emilmont | 1:fdd22bb7aa52 | 183 | |
mbed_official | 3:7a284390b0ce | 184 | // loop for stage |
mbed_official | 3:7a284390b0ce | 185 | for (k = n2; k > 2; k = k >> 1) |
mbed_official | 3:7a284390b0ce | 186 | { |
mbed_official | 3:7a284390b0ce | 187 | n1 = n2; |
mbed_official | 3:7a284390b0ce | 188 | n2 = n2 >> 1; |
mbed_official | 3:7a284390b0ce | 189 | ia = 0; |
emilmont | 1:fdd22bb7aa52 | 190 | |
mbed_official | 3:7a284390b0ce | 191 | // loop for groups |
mbed_official | 3:7a284390b0ce | 192 | j = 0; |
mbed_official | 3:7a284390b0ce | 193 | do |
mbed_official | 3:7a284390b0ce | 194 | { |
mbed_official | 3:7a284390b0ce | 195 | cosVal = pCoef[ia * 2]; |
mbed_official | 3:7a284390b0ce | 196 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 197 | ia += twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 198 | |
mbed_official | 3:7a284390b0ce | 199 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 200 | i = j; |
mbed_official | 3:7a284390b0ce | 201 | do |
mbed_official | 3:7a284390b0ce | 202 | { |
mbed_official | 3:7a284390b0ce | 203 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 204 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 205 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 206 | |
mbed_official | 3:7a284390b0ce | 207 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 208 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 209 | |
mbed_official | 3:7a284390b0ce | 210 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 211 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 212 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 213 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 214 | |
mbed_official | 3:7a284390b0ce | 215 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 216 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 217 | |
mbed_official | 3:7a284390b0ce | 218 | pSrc[2 * l] = p0 + p1; |
mbed_official | 3:7a284390b0ce | 219 | pSrc[2 * l + 1] = p2 - p3; |
mbed_official | 3:7a284390b0ce | 220 | |
mbed_official | 3:7a284390b0ce | 221 | i += n1; |
mbed_official | 3:7a284390b0ce | 222 | } while( i < fftLen ); // butterfly loop end |
mbed_official | 3:7a284390b0ce | 223 | j++; |
mbed_official | 3:7a284390b0ce | 224 | } while( j < n2); // groups loop end |
mbed_official | 3:7a284390b0ce | 225 | twidCoefModifier <<= 1u; |
mbed_official | 3:7a284390b0ce | 226 | } // stages loop end |
emilmont | 1:fdd22bb7aa52 | 227 | |
mbed_official | 3:7a284390b0ce | 228 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 229 | for (i = 0; i < fftLen; i += 2) |
mbed_official | 3:7a284390b0ce | 230 | { |
mbed_official | 3:7a284390b0ce | 231 | a0 = pSrc[2 * i] + pSrc[2 * i + 2]; |
mbed_official | 3:7a284390b0ce | 232 | xt = pSrc[2 * i] - pSrc[2 * i + 2]; |
emilmont | 1:fdd22bb7aa52 | 233 | |
mbed_official | 3:7a284390b0ce | 234 | yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; |
mbed_official | 3:7a284390b0ce | 235 | a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 236 | |
mbed_official | 3:7a284390b0ce | 237 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 238 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 239 | pSrc[2 * i + 2] = xt; |
mbed_official | 3:7a284390b0ce | 240 | pSrc[2 * i + 3] = yt; |
mbed_official | 3:7a284390b0ce | 241 | } // groups loop end |
emilmont | 1:fdd22bb7aa52 | 242 | |
emilmont | 1:fdd22bb7aa52 | 243 | #else |
mbed_official | 3:7a284390b0ce | 244 | |
mbed_official | 3:7a284390b0ce | 245 | n2 = fftLen; |
emilmont | 1:fdd22bb7aa52 | 246 | |
mbed_official | 3:7a284390b0ce | 247 | // loop for stage |
mbed_official | 3:7a284390b0ce | 248 | for (k = fftLen; k > 1; k = k >> 1) |
mbed_official | 3:7a284390b0ce | 249 | { |
mbed_official | 3:7a284390b0ce | 250 | n1 = n2; |
mbed_official | 3:7a284390b0ce | 251 | n2 = n2 >> 1; |
mbed_official | 3:7a284390b0ce | 252 | ia = 0; |
emilmont | 1:fdd22bb7aa52 | 253 | |
mbed_official | 3:7a284390b0ce | 254 | // loop for groups |
mbed_official | 3:7a284390b0ce | 255 | j = 0; |
mbed_official | 3:7a284390b0ce | 256 | do |
mbed_official | 3:7a284390b0ce | 257 | { |
mbed_official | 3:7a284390b0ce | 258 | cosVal = pCoef[ia * 2]; |
mbed_official | 3:7a284390b0ce | 259 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 260 | ia += twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 261 | |
mbed_official | 3:7a284390b0ce | 262 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 263 | i = j; |
mbed_official | 3:7a284390b0ce | 264 | do |
mbed_official | 3:7a284390b0ce | 265 | { |
mbed_official | 3:7a284390b0ce | 266 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 267 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 268 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 269 | |
mbed_official | 3:7a284390b0ce | 270 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 271 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 272 | |
mbed_official | 3:7a284390b0ce | 273 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 274 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 275 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 276 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 277 | |
mbed_official | 3:7a284390b0ce | 278 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 279 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 280 | |
mbed_official | 3:7a284390b0ce | 281 | pSrc[2 * l] = p0 + p1; |
mbed_official | 3:7a284390b0ce | 282 | pSrc[2 * l + 1] = p2 - p3; |
mbed_official | 3:7a284390b0ce | 283 | |
mbed_official | 3:7a284390b0ce | 284 | i += n1; |
mbed_official | 3:7a284390b0ce | 285 | } while(i < fftLen); |
mbed_official | 3:7a284390b0ce | 286 | j++; |
mbed_official | 3:7a284390b0ce | 287 | } while(j < n2); |
mbed_official | 3:7a284390b0ce | 288 | twidCoefModifier <<= 1u; |
mbed_official | 3:7a284390b0ce | 289 | } |
emilmont | 1:fdd22bb7aa52 | 290 | |
mbed_official | 3:7a284390b0ce | 291 | #endif // #ifndef ARM_MATH_CM0_FAMILY |
emilmont | 1:fdd22bb7aa52 | 292 | |
emilmont | 1:fdd22bb7aa52 | 293 | } |
emilmont | 1:fdd22bb7aa52 | 294 | |
emilmont | 1:fdd22bb7aa52 | 295 | |
emilmont | 1:fdd22bb7aa52 | 296 | void arm_radix2_butterfly_inverse_f32( |
mbed_official | 3:7a284390b0ce | 297 | float32_t * pSrc, |
mbed_official | 3:7a284390b0ce | 298 | uint32_t fftLen, |
mbed_official | 3:7a284390b0ce | 299 | float32_t * pCoef, |
mbed_official | 3:7a284390b0ce | 300 | uint16_t twidCoefModifier, |
mbed_official | 3:7a284390b0ce | 301 | float32_t onebyfftLen) |
emilmont | 1:fdd22bb7aa52 | 302 | { |
emilmont | 1:fdd22bb7aa52 | 303 | |
mbed_official | 3:7a284390b0ce | 304 | uint32_t i, j, k, l; |
mbed_official | 3:7a284390b0ce | 305 | uint32_t n1, n2, ia; |
mbed_official | 3:7a284390b0ce | 306 | float32_t xt, yt, cosVal, sinVal; |
mbed_official | 3:7a284390b0ce | 307 | float32_t p0, p1, p2, p3; |
mbed_official | 3:7a284390b0ce | 308 | float32_t a0, a1; |
emilmont | 1:fdd22bb7aa52 | 309 | |
mbed_official | 3:7a284390b0ce | 310 | #ifndef ARM_MATH_CM0_FAMILY |
emilmont | 1:fdd22bb7aa52 | 311 | |
mbed_official | 3:7a284390b0ce | 312 | n2 = fftLen >> 1; |
mbed_official | 3:7a284390b0ce | 313 | ia = 0; |
emilmont | 1:fdd22bb7aa52 | 314 | |
mbed_official | 3:7a284390b0ce | 315 | // loop for groups |
mbed_official | 3:7a284390b0ce | 316 | for (i = 0; i < n2; i++) |
mbed_official | 3:7a284390b0ce | 317 | { |
emilmont | 1:fdd22bb7aa52 | 318 | cosVal = pCoef[ia * 2]; |
emilmont | 1:fdd22bb7aa52 | 319 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 320 | ia += twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 321 | |
mbed_official | 3:7a284390b0ce | 322 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 323 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 324 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 325 | |
mbed_official | 3:7a284390b0ce | 326 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 327 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 328 | |
mbed_official | 3:7a284390b0ce | 329 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 330 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 331 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 332 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 333 | |
mbed_official | 3:7a284390b0ce | 334 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 335 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 336 | |
mbed_official | 3:7a284390b0ce | 337 | pSrc[2 * l] = p0 - p1; |
mbed_official | 3:7a284390b0ce | 338 | pSrc[2 * l + 1] = p2 + p3; |
mbed_official | 3:7a284390b0ce | 339 | } // groups loop end |
emilmont | 1:fdd22bb7aa52 | 340 | |
mbed_official | 3:7a284390b0ce | 341 | twidCoefModifier <<= 1u; |
emilmont | 1:fdd22bb7aa52 | 342 | |
mbed_official | 3:7a284390b0ce | 343 | // loop for stage |
mbed_official | 3:7a284390b0ce | 344 | for (k = fftLen / 2; k > 2; k = k >> 1) |
mbed_official | 3:7a284390b0ce | 345 | { |
mbed_official | 3:7a284390b0ce | 346 | n1 = n2; |
mbed_official | 3:7a284390b0ce | 347 | n2 = n2 >> 1; |
mbed_official | 3:7a284390b0ce | 348 | ia = 0; |
emilmont | 1:fdd22bb7aa52 | 349 | |
mbed_official | 3:7a284390b0ce | 350 | // loop for groups |
mbed_official | 3:7a284390b0ce | 351 | j = 0; |
mbed_official | 3:7a284390b0ce | 352 | do |
mbed_official | 3:7a284390b0ce | 353 | { |
mbed_official | 3:7a284390b0ce | 354 | cosVal = pCoef[ia * 2]; |
mbed_official | 3:7a284390b0ce | 355 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 356 | ia += twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 357 | |
mbed_official | 3:7a284390b0ce | 358 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 359 | i = j; |
mbed_official | 3:7a284390b0ce | 360 | do |
mbed_official | 3:7a284390b0ce | 361 | { |
mbed_official | 3:7a284390b0ce | 362 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 363 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 364 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 365 | |
mbed_official | 3:7a284390b0ce | 366 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 367 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 368 | |
mbed_official | 3:7a284390b0ce | 369 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 370 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 371 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 372 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 373 | |
mbed_official | 3:7a284390b0ce | 374 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 375 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 376 | |
mbed_official | 3:7a284390b0ce | 377 | pSrc[2 * l] = p0 - p1; |
mbed_official | 3:7a284390b0ce | 378 | pSrc[2 * l + 1] = p2 + p3; |
emilmont | 1:fdd22bb7aa52 | 379 | |
mbed_official | 3:7a284390b0ce | 380 | i += n1; |
mbed_official | 3:7a284390b0ce | 381 | } while( i < fftLen ); // butterfly loop end |
mbed_official | 3:7a284390b0ce | 382 | j++; |
mbed_official | 3:7a284390b0ce | 383 | } while(j < n2); // groups loop end |
mbed_official | 3:7a284390b0ce | 384 | |
mbed_official | 3:7a284390b0ce | 385 | twidCoefModifier <<= 1u; |
mbed_official | 3:7a284390b0ce | 386 | } // stages loop end |
emilmont | 1:fdd22bb7aa52 | 387 | |
mbed_official | 3:7a284390b0ce | 388 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 389 | for (i = 0; i < fftLen; i += 2) |
mbed_official | 3:7a284390b0ce | 390 | { |
mbed_official | 3:7a284390b0ce | 391 | a0 = pSrc[2 * i] + pSrc[2 * i + 2]; |
mbed_official | 3:7a284390b0ce | 392 | xt = pSrc[2 * i] - pSrc[2 * i + 2]; |
mbed_official | 3:7a284390b0ce | 393 | |
mbed_official | 3:7a284390b0ce | 394 | a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 395 | yt = pSrc[2 * i + 1] - pSrc[2 * i + 3]; |
mbed_official | 3:7a284390b0ce | 396 | |
mbed_official | 3:7a284390b0ce | 397 | p0 = a0 * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 398 | p2 = xt * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 399 | p1 = a1 * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 400 | p3 = yt * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 401 | |
mbed_official | 3:7a284390b0ce | 402 | pSrc[2 * i] = p0; |
mbed_official | 3:7a284390b0ce | 403 | pSrc[2 * i + 1] = p1; |
mbed_official | 3:7a284390b0ce | 404 | pSrc[2 * i + 2] = p2; |
mbed_official | 3:7a284390b0ce | 405 | pSrc[2 * i + 3] = p3; |
mbed_official | 3:7a284390b0ce | 406 | } // butterfly loop end |
emilmont | 1:fdd22bb7aa52 | 407 | |
emilmont | 1:fdd22bb7aa52 | 408 | #else |
emilmont | 1:fdd22bb7aa52 | 409 | |
mbed_official | 3:7a284390b0ce | 410 | n2 = fftLen; |
emilmont | 1:fdd22bb7aa52 | 411 | |
mbed_official | 3:7a284390b0ce | 412 | // loop for stage |
mbed_official | 3:7a284390b0ce | 413 | for (k = fftLen; k > 2; k = k >> 1) |
mbed_official | 3:7a284390b0ce | 414 | { |
mbed_official | 3:7a284390b0ce | 415 | n1 = n2; |
mbed_official | 3:7a284390b0ce | 416 | n2 = n2 >> 1; |
mbed_official | 3:7a284390b0ce | 417 | ia = 0; |
emilmont | 1:fdd22bb7aa52 | 418 | |
mbed_official | 3:7a284390b0ce | 419 | // loop for groups |
mbed_official | 3:7a284390b0ce | 420 | j = 0; |
mbed_official | 3:7a284390b0ce | 421 | do |
emilmont | 1:fdd22bb7aa52 | 422 | { |
mbed_official | 3:7a284390b0ce | 423 | cosVal = pCoef[ia * 2]; |
mbed_official | 3:7a284390b0ce | 424 | sinVal = pCoef[(ia * 2) + 1]; |
mbed_official | 3:7a284390b0ce | 425 | ia = ia + twidCoefModifier; |
emilmont | 1:fdd22bb7aa52 | 426 | |
mbed_official | 3:7a284390b0ce | 427 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 428 | i = j; |
mbed_official | 3:7a284390b0ce | 429 | do |
mbed_official | 3:7a284390b0ce | 430 | { |
mbed_official | 3:7a284390b0ce | 431 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 432 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 433 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emilmont | 1:fdd22bb7aa52 | 434 | |
mbed_official | 3:7a284390b0ce | 435 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 436 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 437 | |
mbed_official | 3:7a284390b0ce | 438 | p0 = xt * cosVal; |
mbed_official | 3:7a284390b0ce | 439 | p1 = yt * sinVal; |
mbed_official | 3:7a284390b0ce | 440 | p2 = yt * cosVal; |
mbed_official | 3:7a284390b0ce | 441 | p3 = xt * sinVal; |
mbed_official | 3:7a284390b0ce | 442 | |
mbed_official | 3:7a284390b0ce | 443 | pSrc[2 * i] = a0; |
mbed_official | 3:7a284390b0ce | 444 | pSrc[2 * i + 1] = a1; |
mbed_official | 3:7a284390b0ce | 445 | |
mbed_official | 3:7a284390b0ce | 446 | pSrc[2 * l] = p0 - p1; |
mbed_official | 3:7a284390b0ce | 447 | pSrc[2 * l + 1] = p2 + p3; |
mbed_official | 3:7a284390b0ce | 448 | |
mbed_official | 3:7a284390b0ce | 449 | i += n1; |
mbed_official | 3:7a284390b0ce | 450 | } while( i < fftLen ); // butterfly loop end |
mbed_official | 3:7a284390b0ce | 451 | j++; |
mbed_official | 3:7a284390b0ce | 452 | } while( j < n2 ); // groups loop end |
emilmont | 1:fdd22bb7aa52 | 453 | |
mbed_official | 3:7a284390b0ce | 454 | twidCoefModifier = twidCoefModifier << 1u; |
mbed_official | 3:7a284390b0ce | 455 | } // stages loop end |
emilmont | 1:fdd22bb7aa52 | 456 | |
mbed_official | 3:7a284390b0ce | 457 | n1 = n2; |
mbed_official | 3:7a284390b0ce | 458 | n2 = n2 >> 1; |
emilmont | 1:fdd22bb7aa52 | 459 | |
mbed_official | 3:7a284390b0ce | 460 | // loop for butterfly |
mbed_official | 3:7a284390b0ce | 461 | for (i = 0; i < fftLen; i += n1) |
mbed_official | 3:7a284390b0ce | 462 | { |
mbed_official | 3:7a284390b0ce | 463 | l = i + n2; |
mbed_official | 3:7a284390b0ce | 464 | |
mbed_official | 3:7a284390b0ce | 465 | a0 = pSrc[2 * i] + pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 466 | xt = pSrc[2 * i] - pSrc[2 * l]; |
mbed_official | 3:7a284390b0ce | 467 | |
mbed_official | 3:7a284390b0ce | 468 | a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1]; |
mbed_official | 3:7a284390b0ce | 469 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
mbed_official | 3:7a284390b0ce | 470 | |
mbed_official | 3:7a284390b0ce | 471 | p0 = a0 * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 472 | p2 = xt * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 473 | p1 = a1 * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 474 | p3 = yt * onebyfftLen; |
mbed_official | 3:7a284390b0ce | 475 | |
mbed_official | 3:7a284390b0ce | 476 | pSrc[2 * i] = p0; |
mbed_official | 3:7a284390b0ce | 477 | pSrc[2u * l] = p2; |
mbed_official | 3:7a284390b0ce | 478 | |
mbed_official | 3:7a284390b0ce | 479 | pSrc[2 * i + 1] = p1; |
mbed_official | 3:7a284390b0ce | 480 | pSrc[2u * l + 1u] = p3; |
mbed_official | 3:7a284390b0ce | 481 | } // butterfly loop end |
emilmont | 1:fdd22bb7aa52 | 482 | |
mbed_official | 3:7a284390b0ce | 483 | #endif // #ifndef ARM_MATH_CM0_FAMILY |
emilmont | 1:fdd22bb7aa52 | 484 | |
emilmont | 1:fdd22bb7aa52 | 485 | } |