init
This commit is contained in:
commit
2c2202e60d
2491 files changed
+1295990
No files matched your search
@@ -0,0 +1,134 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_bitreversal2.c
|
||||
* Description: Bitreversal functions
|
||||
*
|
||||
* $Date: 23 April 2021
|
||||
* $Revision: V1.9.0
|
||||
*
|
||||
* Target Processor: Cortex-M and Cortex-A cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2019 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dsp/transform_functions.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
|
||||
/**
|
||||
@brief In-place 64 bit reversal function.
|
||||
@param[in,out] pSrc points to in-place buffer of unknown 64-bit data type
|
||||
@param[in] bitRevLen bit reversal table length
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_64(
|
||||
uint64_t *pSrc,
|
||||
const uint16_t bitRevLen,
|
||||
const uint16_t *pBitRevTab)
|
||||
{
|
||||
uint64_t a, b, i, tmp;
|
||||
|
||||
for (i = 0; i < bitRevLen; )
|
||||
{
|
||||
a = pBitRevTab[i ] >> 2;
|
||||
b = pBitRevTab[i + 1] >> 2;
|
||||
|
||||
//real
|
||||
tmp = pSrc[a];
|
||||
pSrc[a] = pSrc[b];
|
||||
pSrc[b] = tmp;
|
||||
|
||||
//complex
|
||||
tmp = pSrc[a+1];
|
||||
pSrc[a+1] = pSrc[b+1];
|
||||
pSrc[b+1] = tmp;
|
||||
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief In-place 32 bit reversal function.
|
||||
@param[in,out] pSrc points to in-place buffer of unknown 32-bit data type
|
||||
@param[in] bitRevLen bit reversal table length
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_32(
|
||||
uint32_t *pSrc,
|
||||
const uint16_t bitRevLen,
|
||||
const uint16_t *pBitRevTab)
|
||||
{
|
||||
uint32_t a, b, i, tmp;
|
||||
|
||||
for (i = 0; i < bitRevLen; )
|
||||
{
|
||||
a = pBitRevTab[i ] >> 2;
|
||||
b = pBitRevTab[i + 1] >> 2;
|
||||
|
||||
//real
|
||||
tmp = pSrc[a];
|
||||
pSrc[a] = pSrc[b];
|
||||
pSrc[b] = tmp;
|
||||
|
||||
//complex
|
||||
tmp = pSrc[a+1];
|
||||
pSrc[a+1] = pSrc[b+1];
|
||||
pSrc[b+1] = tmp;
|
||||
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief In-place 16 bit reversal function.
|
||||
@param[in,out] pSrc points to in-place buffer of unknown 16-bit data type
|
||||
@param[in] bitRevLen bit reversal table length
|
||||
@param[in] pBitRevTab points to bit reversal table
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_bitreversal_16(
|
||||
uint16_t *pSrc,
|
||||
const uint16_t bitRevLen,
|
||||
const uint16_t *pBitRevTab)
|
||||
{
|
||||
uint16_t a, b, i, tmp;
|
||||
|
||||
for (i = 0; i < bitRevLen; )
|
||||
{
|
||||
a = pBitRevTab[i ] >> 2;
|
||||
b = pBitRevTab[i + 1] >> 2;
|
||||
|
||||
//real
|
||||
tmp = pSrc[a];
|
||||
pSrc[a] = pSrc[b];
|
||||
pSrc[b] = tmp;
|
||||
|
||||
//complex
|
||||
tmp = pSrc[a+1];
|
||||
pSrc[a+1] = pSrc[b+1];
|
||||
pSrc[b+1] = tmp;
|
||||
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,358 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cfft_init_f32.c
|
||||
* Description: Initialization function for cfft f32 instance
|
||||
*
|
||||
* $Date: 23 April 2021
|
||||
* $Revision: V1.9.0
|
||||
*
|
||||
* Target Processor: Cortex-M and Cortex-A cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define FFTINIT(EXT,SIZE) \
|
||||
S->bitRevLength = arm_cfft_sR_##EXT##_len##SIZE.bitRevLength; \
|
||||
S->pBitRevTable = arm_cfft_sR_##EXT##_len##SIZE.pBitRevTable; \
|
||||
S->pTwiddle = arm_cfft_sR_##EXT##_len##SIZE.pTwiddle;
|
||||
|
||||
/**
|
||||
@addtogroup ComplexFFT
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Initialization function for the cfft f32 function
|
||||
@param[in,out] S points to an instance of the floating-point CFFT structure
|
||||
@param[in] fftLen fft length (number of complex samples)
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
|
||||
@par Use of this function is mandatory only for the MVE version of the FFT.
|
||||
Other versions can still initialize directly the data structure using
|
||||
variables declared in arm_const_structs.h
|
||||
*/
|
||||
|
||||
#include "dsp/transform_functions.h"
|
||||
#include "arm_common_tables.h"
|
||||
#include "arm_const_structs.h"
|
||||
|
||||
#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
|
||||
|
||||
#include "arm_vec_fft.h"
|
||||
#include "arm_mve_tables.h"
|
||||
|
||||
arm_status arm_cfft_radix4by2_rearrange_twiddles_f32(arm_cfft_instance_f32 *S, int twidCoefModifier)
|
||||
{
|
||||
|
||||
switch (S->fftLen >> (twidCoefModifier - 1)) {
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) \
|
||||
|| defined(ARM_TABLE_TWIDDLECOEF_F32_4096)
|
||||
case 4096U:
|
||||
S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_4096_f32;
|
||||
S->rearranged_twiddle_stride1 = rearranged_twiddle_stride1_4096_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_4096_f32;
|
||||
S->rearranged_twiddle_stride2 = rearranged_twiddle_stride2_4096_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_4096_f32;
|
||||
S->rearranged_twiddle_stride3 = rearranged_twiddle_stride3_4096_f32;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) \
|
||||
|| defined(ARM_TABLE_TWIDDLECOEF_F32_1024) || defined(ARM_TABLE_TWIDDLECOEF_F32_2048)
|
||||
case 1024U:
|
||||
S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_1024_f32;
|
||||
S->rearranged_twiddle_stride1 = rearranged_twiddle_stride1_1024_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_1024_f32;
|
||||
S->rearranged_twiddle_stride2 = rearranged_twiddle_stride2_1024_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_1024_f32;
|
||||
S->rearranged_twiddle_stride3 = rearranged_twiddle_stride3_1024_f32;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) \
|
||||
|| defined(ARM_TABLE_TWIDDLECOEF_F32_256) || defined(ARM_TABLE_TWIDDLECOEF_F32_512)
|
||||
case 256U:
|
||||
S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_256_f32;
|
||||
S->rearranged_twiddle_stride1 = rearranged_twiddle_stride1_256_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_256_f32;
|
||||
S->rearranged_twiddle_stride2 = rearranged_twiddle_stride2_256_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_256_f32;
|
||||
S->rearranged_twiddle_stride3 = rearranged_twiddle_stride3_256_f32;
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) \
|
||||
|| defined(ARM_TABLE_TWIDDLECOEF_F32_64) || defined(ARM_TABLE_TWIDDLECOEF_F32_128)
|
||||
case 64U:
|
||||
S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_64_f32;
|
||||
S->rearranged_twiddle_stride1 = rearranged_twiddle_stride1_64_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_64_f32;
|
||||
S->rearranged_twiddle_stride2 = rearranged_twiddle_stride2_64_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_64_f32;
|
||||
S->rearranged_twiddle_stride3 = rearranged_twiddle_stride3_64_f32;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) \
|
||||
|| defined(ARM_TABLE_TWIDDLECOEF_F32_16) || defined(ARM_TABLE_TWIDDLECOEF_F32_32)
|
||||
case 16U:
|
||||
S->rearranged_twiddle_tab_stride1_arr = rearranged_twiddle_tab_stride1_arr_16_f32;
|
||||
S->rearranged_twiddle_stride1 = rearranged_twiddle_stride1_16_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride2_arr = rearranged_twiddle_tab_stride2_arr_16_f32;
|
||||
S->rearranged_twiddle_stride2 = rearranged_twiddle_stride2_16_f32;
|
||||
|
||||
S->rearranged_twiddle_tab_stride3_arr = rearranged_twiddle_tab_stride3_arr_16_f32;
|
||||
S->rearranged_twiddle_stride3 = rearranged_twiddle_stride3_16_f32;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return(ARM_MATH_ARGUMENT_ERROR);
|
||||
break;
|
||||
/* invalid sizes already filtered */
|
||||
}
|
||||
|
||||
return(ARM_MATH_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
arm_status arm_cfft_init_f32(
|
||||
arm_cfft_instance_f32 * S,
|
||||
uint16_t fftLen)
|
||||
{
|
||||
|
||||
/* Initialise the default arm status */
|
||||
arm_status status = ARM_MATH_SUCCESS;
|
||||
|
||||
/* Initialise the FFT length */
|
||||
S->fftLen = fftLen;
|
||||
|
||||
/* Initialise the Twiddle coefficient pointer */
|
||||
S->pTwiddle = NULL;
|
||||
|
||||
|
||||
/* Initializations of Instance structure depending on the FFT length */
|
||||
switch (S->fftLen) {
|
||||
/* Initializations of structure parameters for 4096 point FFT */
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_4096) && defined(ARM_TABLE_TWIDDLECOEF_F32_4096))
|
||||
case 4096U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_4096;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_4096;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_2048) && defined(ARM_TABLE_TWIDDLECOEF_F32_2048))
|
||||
/* Initializations of structure parameters for 2048 point FFT */
|
||||
case 2048U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_2048;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_2048;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_1024) && defined(ARM_TABLE_TWIDDLECOEF_F32_1024))
|
||||
/* Initializations of structure parameters for 1024 point FFT */
|
||||
case 1024U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_1024;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_1024;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_512) && defined(ARM_TABLE_TWIDDLECOEF_F32_512))
|
||||
/* Initializations of structure parameters for 512 point FFT */
|
||||
case 512U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_512;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_512;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_256) && defined(ARM_TABLE_TWIDDLECOEF_F32_256))
|
||||
case 256U:
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_256;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_256;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_128) && defined(ARM_TABLE_TWIDDLECOEF_F32_128))
|
||||
case 128U:
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_128;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_128;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_64) && defined(ARM_TABLE_TWIDDLECOEF_F32_64))
|
||||
case 64U:
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_64;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_64;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_32) && defined(ARM_TABLE_TWIDDLECOEF_F32_32))
|
||||
case 32U:
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_32;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_32;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 2);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_BITREVIDX_FXT_16) && defined(ARM_TABLE_TWIDDLECOEF_F32_16))
|
||||
case 16U:
|
||||
/* Initializations of structure parameters for 16 point FFT */
|
||||
S->bitRevLength = ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH;
|
||||
S->pBitRevTable = (uint16_t *)armBitRevIndexTable_fixed_16;
|
||||
S->pTwiddle = (float32_t *)twiddleCoef_16;
|
||||
status=arm_cfft_radix4by2_rearrange_twiddles_f32(S, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Reporting argument error if fftSize is not valid value */
|
||||
status = ARM_MATH_ARGUMENT_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return (status);
|
||||
}
|
||||
#else
|
||||
arm_status arm_cfft_init_f32(
|
||||
arm_cfft_instance_f32 * S,
|
||||
uint16_t fftLen)
|
||||
{
|
||||
/* Initialise the default arm status */
|
||||
arm_status status = ARM_MATH_SUCCESS;
|
||||
|
||||
/* Initialise the FFT length */
|
||||
S->fftLen = fftLen;
|
||||
|
||||
/* Initialise the Twiddle coefficient pointer */
|
||||
S->pTwiddle = NULL;
|
||||
|
||||
|
||||
/* Initializations of Instance structure depending on the FFT length */
|
||||
switch (S->fftLen) {
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_4096) && defined(ARM_TABLE_BITREVIDX_FLT_4096))
|
||||
/* Initializations of structure parameters for 4096 point FFT */
|
||||
case 4096U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
FFTINIT(f32,4096);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048))
|
||||
/* Initializations of structure parameters for 2048 point FFT */
|
||||
case 2048U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
FFTINIT(f32,2048);
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024))
|
||||
/* Initializations of structure parameters for 1024 point FFT */
|
||||
case 1024U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
FFTINIT(f32,1024);
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_BITREVIDX_FLT_512))
|
||||
/* Initializations of structure parameters for 512 point FFT */
|
||||
case 512U:
|
||||
/* Initialise the bit reversal table modifier */
|
||||
FFTINIT(f32,512);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256))
|
||||
case 256U:
|
||||
FFTINIT(f32,256);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_BITREVIDX_FLT_128))
|
||||
case 128U:
|
||||
FFTINIT(f32,128);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_BITREVIDX_FLT_64))
|
||||
case 64U:
|
||||
FFTINIT(f32,64);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_BITREVIDX_FLT_32))
|
||||
case 32U:
|
||||
FFTINIT(f32,32);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_BITREVIDX_FLT_16))
|
||||
case 16U:
|
||||
/* Initializations of structure parameters for 16 point FFT */
|
||||
FFTINIT(f32,16);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Reporting argument error if fftSize is not valid value */
|
||||
status = ARM_MATH_ARGUMENT_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return (status);
|
||||
}
|
||||
#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
|
||||
|
||||
/**
|
||||
@} end of ComplexFFT group
|
||||
*/
|
||||
@@ -0,0 +1,285 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_cfft_radix8_f32.c
|
||||
* Description: Radix-8 Decimation in Frequency CFFT & CIFFT Floating point processing function
|
||||
*
|
||||
* $Date: 23 April 2021
|
||||
* $Revision: V1.9.0
|
||||
*
|
||||
* Target Processor: Cortex-M and Cortex-A cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dsp/transform_functions.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Internal helper function used by the FFTs
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
brief Core function for the floating-point CFFT butterfly process.
|
||||
param[in,out] pSrc points to the in-place buffer of floating-point data type.
|
||||
param[in] fftLen length of the FFT.
|
||||
param[in] pCoef points to the twiddle coefficient buffer.
|
||||
param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
|
||||
return none
|
||||
*/
|
||||
|
||||
void arm_radix8_butterfly_f32(
|
||||
float32_t * pSrc,
|
||||
uint16_t fftLen,
|
||||
const float32_t * pCoef,
|
||||
uint16_t twidCoefModifier)
|
||||
{
|
||||
uint32_t ia1, ia2, ia3, ia4, ia5, ia6, ia7;
|
||||
uint32_t i1, i2, i3, i4, i5, i6, i7, i8;
|
||||
uint32_t id;
|
||||
uint32_t n1, n2, j;
|
||||
|
||||
float32_t r1, r2, r3, r4, r5, r6, r7, r8;
|
||||
float32_t t1, t2;
|
||||
float32_t s1, s2, s3, s4, s5, s6, s7, s8;
|
||||
float32_t p1, p2, p3, p4;
|
||||
float32_t co2, co3, co4, co5, co6, co7, co8;
|
||||
float32_t si2, si3, si4, si5, si6, si7, si8;
|
||||
const float32_t C81 = 0.70710678118f;
|
||||
|
||||
n2 = fftLen;
|
||||
|
||||
do
|
||||
{
|
||||
n1 = n2;
|
||||
n2 = n2 >> 3;
|
||||
i1 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
i2 = i1 + n2;
|
||||
i3 = i2 + n2;
|
||||
i4 = i3 + n2;
|
||||
i5 = i4 + n2;
|
||||
i6 = i5 + n2;
|
||||
i7 = i6 + n2;
|
||||
i8 = i7 + n2;
|
||||
r1 = pSrc[2 * i1] + pSrc[2 * i5];
|
||||
r5 = pSrc[2 * i1] - pSrc[2 * i5];
|
||||
r2 = pSrc[2 * i2] + pSrc[2 * i6];
|
||||
r6 = pSrc[2 * i2] - pSrc[2 * i6];
|
||||
r3 = pSrc[2 * i3] + pSrc[2 * i7];
|
||||
r7 = pSrc[2 * i3] - pSrc[2 * i7];
|
||||
r4 = pSrc[2 * i4] + pSrc[2 * i8];
|
||||
r8 = pSrc[2 * i4] - pSrc[2 * i8];
|
||||
t1 = r1 - r3;
|
||||
r1 = r1 + r3;
|
||||
r3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1] = r1 + r2;
|
||||
pSrc[2 * i5] = r1 - r2;
|
||||
r1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1];
|
||||
s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1];
|
||||
r2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1];
|
||||
s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1];
|
||||
s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1];
|
||||
s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1];
|
||||
r4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1];
|
||||
s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1];
|
||||
t2 = r1 - s3;
|
||||
r1 = r1 + s3;
|
||||
s3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1 + 1] = r1 + r2;
|
||||
pSrc[2 * i5 + 1] = r1 - r2;
|
||||
pSrc[2 * i3] = t1 + s3;
|
||||
pSrc[2 * i7] = t1 - s3;
|
||||
pSrc[2 * i3 + 1] = t2 - r3;
|
||||
pSrc[2 * i7 + 1] = t2 + r3;
|
||||
r1 = (r6 - r8) * C81;
|
||||
r6 = (r6 + r8) * C81;
|
||||
r2 = (s6 - s8) * C81;
|
||||
s6 = (s6 + s8) * C81;
|
||||
t1 = r5 - r1;
|
||||
r5 = r5 + r1;
|
||||
r8 = r7 - r6;
|
||||
r7 = r7 + r6;
|
||||
t2 = s5 - r2;
|
||||
s5 = s5 + r2;
|
||||
s8 = s7 - s6;
|
||||
s7 = s7 + s6;
|
||||
pSrc[2 * i2] = r5 + s7;
|
||||
pSrc[2 * i8] = r5 - s7;
|
||||
pSrc[2 * i6] = t1 + s8;
|
||||
pSrc[2 * i4] = t1 - s8;
|
||||
pSrc[2 * i2 + 1] = s5 - r7;
|
||||
pSrc[2 * i8 + 1] = s5 + r7;
|
||||
pSrc[2 * i6 + 1] = t2 - r8;
|
||||
pSrc[2 * i4 + 1] = t2 + r8;
|
||||
|
||||
i1 += n1;
|
||||
} while (i1 < fftLen);
|
||||
|
||||
if (n2 < 8)
|
||||
break;
|
||||
|
||||
ia1 = 0;
|
||||
j = 1;
|
||||
|
||||
do
|
||||
{
|
||||
/* index calculation for the coefficients */
|
||||
id = ia1 + twidCoefModifier;
|
||||
ia1 = id;
|
||||
ia2 = ia1 + id;
|
||||
ia3 = ia2 + id;
|
||||
ia4 = ia3 + id;
|
||||
ia5 = ia4 + id;
|
||||
ia6 = ia5 + id;
|
||||
ia7 = ia6 + id;
|
||||
|
||||
co2 = pCoef[2 * ia1];
|
||||
co3 = pCoef[2 * ia2];
|
||||
co4 = pCoef[2 * ia3];
|
||||
co5 = pCoef[2 * ia4];
|
||||
co6 = pCoef[2 * ia5];
|
||||
co7 = pCoef[2 * ia6];
|
||||
co8 = pCoef[2 * ia7];
|
||||
si2 = pCoef[2 * ia1 + 1];
|
||||
si3 = pCoef[2 * ia2 + 1];
|
||||
si4 = pCoef[2 * ia3 + 1];
|
||||
si5 = pCoef[2 * ia4 + 1];
|
||||
si6 = pCoef[2 * ia5 + 1];
|
||||
si7 = pCoef[2 * ia6 + 1];
|
||||
si8 = pCoef[2 * ia7 + 1];
|
||||
|
||||
i1 = j;
|
||||
|
||||
do
|
||||
{
|
||||
/* index calculation for the input */
|
||||
i2 = i1 + n2;
|
||||
i3 = i2 + n2;
|
||||
i4 = i3 + n2;
|
||||
i5 = i4 + n2;
|
||||
i6 = i5 + n2;
|
||||
i7 = i6 + n2;
|
||||
i8 = i7 + n2;
|
||||
r1 = pSrc[2 * i1] + pSrc[2 * i5];
|
||||
r5 = pSrc[2 * i1] - pSrc[2 * i5];
|
||||
r2 = pSrc[2 * i2] + pSrc[2 * i6];
|
||||
r6 = pSrc[2 * i2] - pSrc[2 * i6];
|
||||
r3 = pSrc[2 * i3] + pSrc[2 * i7];
|
||||
r7 = pSrc[2 * i3] - pSrc[2 * i7];
|
||||
r4 = pSrc[2 * i4] + pSrc[2 * i8];
|
||||
r8 = pSrc[2 * i4] - pSrc[2 * i8];
|
||||
t1 = r1 - r3;
|
||||
r1 = r1 + r3;
|
||||
r3 = r2 - r4;
|
||||
r2 = r2 + r4;
|
||||
pSrc[2 * i1] = r1 + r2;
|
||||
r2 = r1 - r2;
|
||||
s1 = pSrc[2 * i1 + 1] + pSrc[2 * i5 + 1];
|
||||
s5 = pSrc[2 * i1 + 1] - pSrc[2 * i5 + 1];
|
||||
s2 = pSrc[2 * i2 + 1] + pSrc[2 * i6 + 1];
|
||||
s6 = pSrc[2 * i2 + 1] - pSrc[2 * i6 + 1];
|
||||
s3 = pSrc[2 * i3 + 1] + pSrc[2 * i7 + 1];
|
||||
s7 = pSrc[2 * i3 + 1] - pSrc[2 * i7 + 1];
|
||||
s4 = pSrc[2 * i4 + 1] + pSrc[2 * i8 + 1];
|
||||
s8 = pSrc[2 * i4 + 1] - pSrc[2 * i8 + 1];
|
||||
t2 = s1 - s3;
|
||||
s1 = s1 + s3;
|
||||
s3 = s2 - s4;
|
||||
s2 = s2 + s4;
|
||||
r1 = t1 + s3;
|
||||
t1 = t1 - s3;
|
||||
pSrc[2 * i1 + 1] = s1 + s2;
|
||||
s2 = s1 - s2;
|
||||
s1 = t2 - r3;
|
||||
t2 = t2 + r3;
|
||||
p1 = co5 * r2;
|
||||
p2 = si5 * s2;
|
||||
p3 = co5 * s2;
|
||||
p4 = si5 * r2;
|
||||
pSrc[2 * i5] = p1 + p2;
|
||||
pSrc[2 * i5 + 1] = p3 - p4;
|
||||
p1 = co3 * r1;
|
||||
p2 = si3 * s1;
|
||||
p3 = co3 * s1;
|
||||
p4 = si3 * r1;
|
||||
pSrc[2 * i3] = p1 + p2;
|
||||
pSrc[2 * i3 + 1] = p3 - p4;
|
||||
p1 = co7 * t1;
|
||||
p2 = si7 * t2;
|
||||
p3 = co7 * t2;
|
||||
p4 = si7 * t1;
|
||||
pSrc[2 * i7] = p1 + p2;
|
||||
pSrc[2 * i7 + 1] = p3 - p4;
|
||||
r1 = (r6 - r8) * C81;
|
||||
r6 = (r6 + r8) * C81;
|
||||
s1 = (s6 - s8) * C81;
|
||||
s6 = (s6 + s8) * C81;
|
||||
t1 = r5 - r1;
|
||||
r5 = r5 + r1;
|
||||
r8 = r7 - r6;
|
||||
r7 = r7 + r6;
|
||||
t2 = s5 - s1;
|
||||
s5 = s5 + s1;
|
||||
s8 = s7 - s6;
|
||||
s7 = s7 + s6;
|
||||
r1 = r5 + s7;
|
||||
r5 = r5 - s7;
|
||||
r6 = t1 + s8;
|
||||
t1 = t1 - s8;
|
||||
s1 = s5 - r7;
|
||||
s5 = s5 + r7;
|
||||
s6 = t2 - r8;
|
||||
t2 = t2 + r8;
|
||||
p1 = co2 * r1;
|
||||
p2 = si2 * s1;
|
||||
p3 = co2 * s1;
|
||||
p4 = si2 * r1;
|
||||
pSrc[2 * i2] = p1 + p2;
|
||||
pSrc[2 * i2 + 1] = p3 - p4;
|
||||
p1 = co8 * r5;
|
||||
p2 = si8 * s5;
|
||||
p3 = co8 * s5;
|
||||
p4 = si8 * r5;
|
||||
pSrc[2 * i8] = p1 + p2;
|
||||
pSrc[2 * i8 + 1] = p3 - p4;
|
||||
p1 = co6 * r6;
|
||||
p2 = si6 * s6;
|
||||
p3 = co6 * s6;
|
||||
p4 = si6 * r6;
|
||||
pSrc[2 * i6] = p1 + p2;
|
||||
pSrc[2 * i6 + 1] = p3 - p4;
|
||||
p1 = co4 * t1;
|
||||
p2 = si4 * t2;
|
||||
p3 = co4 * t2;
|
||||
p4 = si4 * t1;
|
||||
pSrc[2 * i4] = p1 + p2;
|
||||
pSrc[2 * i4 + 1] = p3 - p4;
|
||||
|
||||
i1 += n1;
|
||||
} while (i1 < fftLen);
|
||||
|
||||
j++;
|
||||
} while (j < n2);
|
||||
|
||||
twidCoefModifier <<= 3;
|
||||
} while (n2 > 7);
|
||||
}
|
||||
@@ -0,0 +1,603 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_rfft_fast_f32.c
|
||||
* Description: RFFT & RIFFT Floating point process function
|
||||
*
|
||||
* $Date: 23 April 2021
|
||||
* $Revision: V1.9.0
|
||||
*
|
||||
* Target Processor: Cortex-M and Cortex-A cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dsp/transform_functions.h"
|
||||
|
||||
#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
|
||||
void stage_rfft_f32(
|
||||
const arm_rfft_fast_instance_f32 * S,
|
||||
float32_t * p,
|
||||
float32_t * pOut)
|
||||
{
|
||||
int32_t k; /* Loop Counter */
|
||||
float32_t twR, twI; /* RFFT Twiddle coefficients */
|
||||
const float32_t * pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
|
||||
float32_t *pA = p; /* increasing pointer */
|
||||
float32_t *pB = p; /* decreasing pointer */
|
||||
float32_t xAR, xAI, xBR, xBI; /* temporary variables */
|
||||
float32_t t1a, t1b; /* temporary variables */
|
||||
float32_t p0, p1, p2, p3; /* temporary variables */
|
||||
|
||||
float32x4x2_t tw,xA,xB;
|
||||
float32x4x2_t tmp1, tmp2, res;
|
||||
|
||||
uint32x4_t vecStridesFwd, vecStridesBkwd;
|
||||
|
||||
vecStridesFwd = vidupq_u32((uint32_t)0, 2);
|
||||
vecStridesBkwd = -vecStridesFwd;
|
||||
|
||||
int blockCnt;
|
||||
|
||||
|
||||
k = (S->Sint).fftLen - 1;
|
||||
|
||||
/* Pack first and last sample of the frequency domain together */
|
||||
|
||||
xBR = pB[0];
|
||||
xBI = pB[1];
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++ ;
|
||||
twI = *pCoeff++ ;
|
||||
|
||||
// U1 = XA(1) + XB(1); % It is real
|
||||
t1a = xBR + xAR ;
|
||||
|
||||
// U2 = XB(1) - XA(1); % It is imaginary
|
||||
t1b = xBI + xAI ;
|
||||
|
||||
// real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
|
||||
// imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
|
||||
*pOut++ = 0.5f * ( t1a + t1b );
|
||||
*pOut++ = 0.5f * ( t1a - t1b );
|
||||
|
||||
// XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) ));
|
||||
pB = p + 2*k;
|
||||
pA += 2;
|
||||
|
||||
blockCnt = k >> 2;
|
||||
while (blockCnt > 0)
|
||||
{
|
||||
/*
|
||||
function X = my_split_rfft(X, ifftFlag)
|
||||
% X is a series of real numbers
|
||||
L = length(X);
|
||||
XC = X(1:2:end) +i*X(2:2:end);
|
||||
XA = fft(XC);
|
||||
XB = conj(XA([1 end:-1:2]));
|
||||
TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
|
||||
for l = 2:L/2
|
||||
XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
|
||||
end
|
||||
XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
|
||||
X = XA;
|
||||
*/
|
||||
|
||||
|
||||
xA = vld2q_f32(pA);
|
||||
pA += 8;
|
||||
|
||||
xB = vld2q_f32(pB);
|
||||
|
||||
xB.val[0] = vldrwq_gather_shifted_offset_f32(pB, vecStridesBkwd);
|
||||
xB.val[1] = vldrwq_gather_shifted_offset_f32(&pB[1], vecStridesBkwd);
|
||||
|
||||
xB.val[1] = vnegq_f32(xB.val[1]);
|
||||
pB -= 8;
|
||||
|
||||
|
||||
tw = vld2q_f32(pCoeff);
|
||||
pCoeff += 8;
|
||||
|
||||
|
||||
tmp1.val[0] = vaddq_f32(xA.val[0],xB.val[0]);
|
||||
tmp1.val[1] = vaddq_f32(xA.val[1],xB.val[1]);
|
||||
|
||||
tmp2.val[0] = vsubq_f32(xB.val[0],xA.val[0]);
|
||||
tmp2.val[1] = vsubq_f32(xB.val[1],xA.val[1]);
|
||||
|
||||
res.val[0] = vmulq(tw.val[0], tmp2.val[0]);
|
||||
res.val[0] = vfmsq(res.val[0],tw.val[1], tmp2.val[1]);
|
||||
|
||||
res.val[1] = vmulq(tw.val[0], tmp2.val[1]);
|
||||
res.val[1] = vfmaq(res.val[1], tw.val[1], tmp2.val[0]);
|
||||
|
||||
res.val[0] = vaddq_f32(res.val[0],tmp1.val[0] );
|
||||
res.val[1] = vaddq_f32(res.val[1],tmp1.val[1] );
|
||||
|
||||
res.val[0] = vmulq_n_f32(res.val[0], 0.5f);
|
||||
res.val[1] = vmulq_n_f32(res.val[1], 0.5f);
|
||||
|
||||
|
||||
vst2q_f32(pOut, res);
|
||||
pOut += 8;
|
||||
|
||||
|
||||
blockCnt--;
|
||||
}
|
||||
|
||||
blockCnt = k & 3;
|
||||
while (blockCnt > 0)
|
||||
{
|
||||
/*
|
||||
function X = my_split_rfft(X, ifftFlag)
|
||||
% X is a series of real numbers
|
||||
L = length(X);
|
||||
XC = X(1:2:end) +i*X(2:2:end);
|
||||
XA = fft(XC);
|
||||
XB = conj(XA([1 end:-1:2]));
|
||||
TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
|
||||
for l = 2:L/2
|
||||
XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
|
||||
end
|
||||
XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
|
||||
X = XA;
|
||||
*/
|
||||
|
||||
xBI = pB[1];
|
||||
xBR = pB[0];
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++;
|
||||
twI = *pCoeff++;
|
||||
|
||||
t1a = xBR - xAR ;
|
||||
t1b = xBI + xAI ;
|
||||
|
||||
// real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
|
||||
// imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
|
||||
p0 = twR * t1a;
|
||||
p1 = twI * t1a;
|
||||
p2 = twR * t1b;
|
||||
p3 = twI * t1b;
|
||||
|
||||
*pOut++ = 0.5f * (xAR + xBR + p0 + p3 ); //xAR
|
||||
*pOut++ = 0.5f * (xAI - xBI + p1 - p2 ); //xAI
|
||||
|
||||
pA += 2;
|
||||
pB -= 2;
|
||||
blockCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepares data for inverse cfft */
|
||||
void merge_rfft_f32(
|
||||
const arm_rfft_fast_instance_f32 * S,
|
||||
float32_t * p,
|
||||
float32_t * pOut)
|
||||
{
|
||||
int32_t k; /* Loop Counter */
|
||||
float32_t twR, twI; /* RFFT Twiddle coefficients */
|
||||
const float32_t *pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
|
||||
float32_t *pA = p; /* increasing pointer */
|
||||
float32_t *pB = p; /* decreasing pointer */
|
||||
float32_t xAR, xAI, xBR, xBI; /* temporary variables */
|
||||
float32_t t1a, t1b, r, s, t, u; /* temporary variables */
|
||||
|
||||
float32x4x2_t tw,xA,xB;
|
||||
float32x4x2_t tmp1, tmp2, res;
|
||||
uint32x4_t vecStridesFwd, vecStridesBkwd;
|
||||
|
||||
vecStridesFwd = vidupq_u32((uint32_t)0, 2);
|
||||
vecStridesBkwd = -vecStridesFwd;
|
||||
|
||||
int blockCnt;
|
||||
|
||||
|
||||
k = (S->Sint).fftLen - 1;
|
||||
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
pCoeff += 2 ;
|
||||
|
||||
*pOut++ = 0.5f * ( xAR + xAI );
|
||||
*pOut++ = 0.5f * ( xAR - xAI );
|
||||
|
||||
pB = p + 2*k ;
|
||||
pA += 2 ;
|
||||
|
||||
blockCnt = k >> 2;
|
||||
while (blockCnt > 0)
|
||||
{
|
||||
/* G is half of the frequency complex spectrum */
|
||||
//for k = 2:N
|
||||
// Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
|
||||
xA = vld2q_f32(pA);
|
||||
pA += 8;
|
||||
|
||||
xB = vld2q_f32(pB);
|
||||
|
||||
xB.val[0] = vldrwq_gather_shifted_offset_f32(pB, vecStridesBkwd);
|
||||
xB.val[1] = vldrwq_gather_shifted_offset_f32(&pB[1], vecStridesBkwd);
|
||||
|
||||
xB.val[1] = vnegq_f32(xB.val[1]);
|
||||
pB -= 8;
|
||||
|
||||
|
||||
tw = vld2q_f32(pCoeff);
|
||||
tw.val[1] = vnegq_f32(tw.val[1]);
|
||||
pCoeff += 8;
|
||||
|
||||
|
||||
tmp1.val[0] = vaddq_f32(xA.val[0],xB.val[0]);
|
||||
tmp1.val[1] = vaddq_f32(xA.val[1],xB.val[1]);
|
||||
|
||||
tmp2.val[0] = vsubq_f32(xB.val[0],xA.val[0]);
|
||||
tmp2.val[1] = vsubq_f32(xB.val[1],xA.val[1]);
|
||||
|
||||
res.val[0] = vmulq(tw.val[0], tmp2.val[0]);
|
||||
res.val[0] = vfmsq(res.val[0],tw.val[1], tmp2.val[1]);
|
||||
|
||||
res.val[1] = vmulq(tw.val[0], tmp2.val[1]);
|
||||
res.val[1] = vfmaq(res.val[1], tw.val[1], tmp2.val[0]);
|
||||
|
||||
res.val[0] = vaddq_f32(res.val[0],tmp1.val[0] );
|
||||
res.val[1] = vaddq_f32(res.val[1],tmp1.val[1] );
|
||||
|
||||
res.val[0] = vmulq_n_f32(res.val[0], 0.5f);
|
||||
res.val[1] = vmulq_n_f32(res.val[1], 0.5f);
|
||||
|
||||
|
||||
vst2q_f32(pOut, res);
|
||||
pOut += 8;
|
||||
|
||||
|
||||
blockCnt--;
|
||||
}
|
||||
|
||||
blockCnt = k & 3;
|
||||
while (blockCnt > 0)
|
||||
{
|
||||
/* G is half of the frequency complex spectrum */
|
||||
//for k = 2:N
|
||||
// Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
|
||||
xBI = pB[1] ;
|
||||
xBR = pB[0] ;
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++;
|
||||
twI = *pCoeff++;
|
||||
|
||||
t1a = xAR - xBR ;
|
||||
t1b = xAI + xBI ;
|
||||
|
||||
r = twR * t1a;
|
||||
s = twI * t1b;
|
||||
t = twI * t1a;
|
||||
u = twR * t1b;
|
||||
|
||||
// real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI);
|
||||
// imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI);
|
||||
*pOut++ = 0.5f * (xAR + xBR - r - s ); //xAR
|
||||
*pOut++ = 0.5f * (xAI - xBI + t - u ); //xAI
|
||||
|
||||
pA += 2;
|
||||
pB -= 2;
|
||||
blockCnt--;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
void stage_rfft_f32(
|
||||
const arm_rfft_fast_instance_f32 * S,
|
||||
float32_t * p,
|
||||
float32_t * pOut)
|
||||
{
|
||||
int32_t k; /* Loop Counter */
|
||||
float32_t twR, twI; /* RFFT Twiddle coefficients */
|
||||
const float32_t * pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
|
||||
float32_t *pA = p; /* increasing pointer */
|
||||
float32_t *pB = p; /* decreasing pointer */
|
||||
float32_t xAR, xAI, xBR, xBI; /* temporary variables */
|
||||
float32_t t1a, t1b; /* temporary variables */
|
||||
float32_t p0, p1, p2, p3; /* temporary variables */
|
||||
|
||||
|
||||
k = (S->Sint).fftLen - 1;
|
||||
|
||||
/* Pack first and last sample of the frequency domain together */
|
||||
|
||||
xBR = pB[0];
|
||||
xBI = pB[1];
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++ ;
|
||||
twI = *pCoeff++ ;
|
||||
|
||||
|
||||
// U1 = XA(1) + XB(1); % It is real
|
||||
t1a = xBR + xAR ;
|
||||
|
||||
// U2 = XB(1) - XA(1); % It is imaginary
|
||||
t1b = xBI + xAI ;
|
||||
|
||||
// real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
|
||||
// imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
|
||||
*pOut++ = 0.5f * ( t1a + t1b );
|
||||
*pOut++ = 0.5f * ( t1a - t1b );
|
||||
|
||||
// XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) ));
|
||||
pB = p + 2*k;
|
||||
pA += 2;
|
||||
|
||||
do
|
||||
{
|
||||
/*
|
||||
function X = my_split_rfft(X, ifftFlag)
|
||||
% X is a series of real numbers
|
||||
L = length(X);
|
||||
XC = X(1:2:end) +i*X(2:2:end);
|
||||
XA = fft(XC);
|
||||
XB = conj(XA([1 end:-1:2]));
|
||||
TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
|
||||
for l = 2:L/2
|
||||
XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
|
||||
end
|
||||
XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
|
||||
X = XA;
|
||||
*/
|
||||
|
||||
xBI = pB[1];
|
||||
xBR = pB[0];
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++;
|
||||
twI = *pCoeff++;
|
||||
|
||||
t1a = xBR - xAR ;
|
||||
t1b = xBI + xAI ;
|
||||
|
||||
// real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
|
||||
// imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
|
||||
p0 = twR * t1a;
|
||||
p1 = twI * t1a;
|
||||
p2 = twR * t1b;
|
||||
p3 = twI * t1b;
|
||||
|
||||
*pOut++ = 0.5f * (xAR + xBR + p0 + p3 ); //xAR
|
||||
*pOut++ = 0.5f * (xAI - xBI + p1 - p2 ); //xAI
|
||||
|
||||
|
||||
pA += 2;
|
||||
pB -= 2;
|
||||
k--;
|
||||
} while (k > 0);
|
||||
}
|
||||
|
||||
/* Prepares data for inverse cfft */
|
||||
void merge_rfft_f32(
|
||||
const arm_rfft_fast_instance_f32 * S,
|
||||
float32_t * p,
|
||||
float32_t * pOut)
|
||||
{
|
||||
int32_t k; /* Loop Counter */
|
||||
float32_t twR, twI; /* RFFT Twiddle coefficients */
|
||||
const float32_t *pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
|
||||
float32_t *pA = p; /* increasing pointer */
|
||||
float32_t *pB = p; /* decreasing pointer */
|
||||
float32_t xAR, xAI, xBR, xBI; /* temporary variables */
|
||||
float32_t t1a, t1b, r, s, t, u; /* temporary variables */
|
||||
|
||||
k = (S->Sint).fftLen - 1;
|
||||
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
pCoeff += 2 ;
|
||||
|
||||
*pOut++ = 0.5f * ( xAR + xAI );
|
||||
*pOut++ = 0.5f * ( xAR - xAI );
|
||||
|
||||
pB = p + 2*k ;
|
||||
pA += 2 ;
|
||||
|
||||
while (k > 0)
|
||||
{
|
||||
/* G is half of the frequency complex spectrum */
|
||||
//for k = 2:N
|
||||
// Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
|
||||
xBI = pB[1] ;
|
||||
xBR = pB[0] ;
|
||||
xAR = pA[0];
|
||||
xAI = pA[1];
|
||||
|
||||
twR = *pCoeff++;
|
||||
twI = *pCoeff++;
|
||||
|
||||
t1a = xAR - xBR ;
|
||||
t1b = xAI + xBI ;
|
||||
|
||||
r = twR * t1a;
|
||||
s = twI * t1b;
|
||||
t = twI * t1a;
|
||||
u = twR * t1b;
|
||||
|
||||
// real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI);
|
||||
// imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI);
|
||||
*pOut++ = 0.5f * (xAR + xBR - r - s ); //xAR
|
||||
*pOut++ = 0.5f * (xAI - xBI + t - u ); //xAI
|
||||
|
||||
pA += 2;
|
||||
pB -= 2;
|
||||
k--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
|
||||
|
||||
/**
|
||||
@ingroup groupTransforms
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup RealFFT Real FFT Functions
|
||||
|
||||
@par
|
||||
The CMSIS DSP library includes specialized algorithms for computing the
|
||||
FFT of real data sequences. The FFT is defined over complex data but
|
||||
in many applications the input is real. Real FFT algorithms take advantage
|
||||
of the symmetry properties of the FFT and have a speed advantage over complex
|
||||
algorithms of the same length.
|
||||
@par
|
||||
The Fast RFFT algorithm relays on the mixed radix CFFT that save processor usage.
|
||||
@par
|
||||
The real length N forward FFT of a sequence is computed using the steps shown below.
|
||||
@par
|
||||
\image html RFFT.gif "Real Fast Fourier Transform"
|
||||
@par
|
||||
The real sequence is initially treated as if it were complex to perform a CFFT.
|
||||
Later, a processing stage reshapes the data to obtain half of the frequency spectrum
|
||||
in complex format. Except the first complex number that contains the two real numbers
|
||||
X[0] and X[N/2] all the data is complex. In other words, the first complex sample
|
||||
contains two real values packed.
|
||||
@par
|
||||
The input for the inverse RFFT should keep the same format as the output of the
|
||||
forward RFFT. A first processing stage pre-process the data to later perform an
|
||||
inverse CFFT.
|
||||
@par
|
||||
\image html RIFFT.gif "Real Inverse Fast Fourier Transform"
|
||||
@par
|
||||
The algorithms for floating-point, Q15, and Q31 data are slightly different
|
||||
and we describe each algorithm in turn.
|
||||
@par Floating-point
|
||||
The main functions are \ref arm_rfft_fast_f32() and \ref arm_rfft_fast_init_f32().
|
||||
The older functions \ref arm_rfft_f32() and \ref arm_rfft_init_f32() have been deprecated
|
||||
but are still documented.
|
||||
@par
|
||||
The FFT of a real N-point sequence has even symmetry in the frequency domain.
|
||||
The second half of the data equals the conjugate of the first half flipped in frequency.
|
||||
Looking at the data, we see that we can uniquely represent the FFT using only N/2 complex numbers.
|
||||
These are packed into the output array in alternating real and imaginary components:
|
||||
@par
|
||||
X = { real[0], imag[0], real[1], imag[1], real[2], imag[2] ...
|
||||
real[(N/2)-1], imag[(N/2)-1 }
|
||||
@par
|
||||
It happens that the first complex number (real[0], imag[0]) is actually
|
||||
all real. real[0] represents the DC offset, and imag[0] should be 0.
|
||||
(real[1], imag[1]) is the fundamental frequency, (real[2], imag[2]) is
|
||||
the first harmonic and so on.
|
||||
@par
|
||||
The real FFT functions pack the frequency domain data in this fashion.
|
||||
The forward transform outputs the data in this form and the inverse
|
||||
transform expects input data in this form. The function always performs
|
||||
the needed bitreversal so that the input and output data is always in
|
||||
normal order. The functions support lengths of [32, 64, 128, ..., 4096]
|
||||
samples.
|
||||
@par Q15 and Q31
|
||||
The real algorithms are defined in a similar manner and utilize N/2 complex
|
||||
transforms behind the scenes.
|
||||
@par
|
||||
The complex transforms used internally include scaling to prevent fixed-point
|
||||
overflows. The overall scaling equals 1/(fftLen/2).
|
||||
Due to the use of complex transform internally, the source buffer is
|
||||
modified by the rfft.
|
||||
@par
|
||||
A separate instance structure must be defined for each transform used but
|
||||
twiddle factor and bit reversal tables can be reused.
|
||||
@par
|
||||
There is also an associated initialization function for each data type.
|
||||
The initialization function performs the following operations:
|
||||
- Sets the values of the internal structure fields.
|
||||
- Initializes twiddle factor table and bit reversal table pointers.
|
||||
- Initializes the internal complex FFT data structure.
|
||||
@par
|
||||
Use of the initialization function is optional **except for MVE versions where it is mandatory**.
|
||||
If you don't use the initialization functions, then the structures should be initialized with code
|
||||
similar to the one below:
|
||||
<pre>
|
||||
arm_rfft_instance_q31 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
|
||||
arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
|
||||
</pre>
|
||||
where <code>fftLenReal</code> is the length of the real transform;
|
||||
<code>fftLenBy2</code> length of the internal complex transform (fftLenReal/2).
|
||||
<code>ifftFlagR</code> Selects forward (=0) or inverse (=1) transform.
|
||||
<code>bitReverseFlagR</code> Selects bit reversed output (=0) or normal order
|
||||
output (=1).
|
||||
<code>twidCoefRModifier</code> stride modifier for the twiddle factor table.
|
||||
The value is based on the FFT length;
|
||||
<code>pTwiddleAReal</code>points to the A array of twiddle coefficients;
|
||||
<code>pTwiddleBReal</code>points to the B array of twiddle coefficients;
|
||||
<code>pCfft</code> points to the CFFT Instance structure. The CFFT structure
|
||||
must also be initialized.
|
||||
@par
|
||||
Note that with MVE versions you can't initialize instance structures directly and **must
|
||||
use the initialization function**.
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup RealFFT
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@brief Processing function for the floating-point real FFT.
|
||||
@param[in] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@param[in] p points to input buffer (Source buffer is modified by this function.)
|
||||
@param[in] pOut points to output buffer
|
||||
@param[in] ifftFlag
|
||||
- value = 0: RFFT
|
||||
- value = 1: RIFFT
|
||||
@return none
|
||||
*/
|
||||
|
||||
void arm_rfft_fast_f32(
|
||||
const arm_rfft_fast_instance_f32 * S,
|
||||
float32_t * p,
|
||||
float32_t * pOut,
|
||||
uint8_t ifftFlag)
|
||||
{
|
||||
const arm_cfft_instance_f32 * Sint = &(S->Sint);
|
||||
|
||||
/* Calculation of Real FFT */
|
||||
if (ifftFlag)
|
||||
{
|
||||
/* Real FFT compression */
|
||||
merge_rfft_f32(S, p, pOut);
|
||||
/* Complex radix-4 IFFT process */
|
||||
arm_cfft_f32( Sint, pOut, ifftFlag, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculation of RFFT of input */
|
||||
arm_cfft_f32( Sint, p, ifftFlag, 1);
|
||||
|
||||
/* Real FFT extraction */
|
||||
stage_rfft_f32(S, p, pOut);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} end of RealFFT group
|
||||
*/
|
||||
@@ -0,0 +1,352 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_rfft_fast_init_f32.c
|
||||
* Description: Split Radix Decimation in Frequency CFFT Floating point processing function
|
||||
*
|
||||
* $Date: 23 April 2021
|
||||
* $Revision: V1.9.0
|
||||
*
|
||||
* Target Processor: Cortex-M and Cortex-A cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dsp/transform_functions.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
/**
|
||||
@ingroup groupTransforms
|
||||
*/
|
||||
|
||||
/**
|
||||
@addtogroup RealFFT
|
||||
@{
|
||||
*/
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32))
|
||||
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 32pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_32_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),16);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
|
||||
S->fftLenRFFT = 32U;
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_32;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64))
|
||||
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 64pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_64_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),32);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 64U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_64;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128))
|
||||
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 128pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_128_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),64);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 128;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_128;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256))
|
||||
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 256pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_256_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),128);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 256U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_256;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512))
|
||||
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 512pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_512_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),256);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 512U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_512;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024))
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 1024pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_1024_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),512);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 1024U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_1024;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048))
|
||||
/**
|
||||
@private
|
||||
@brief Initialization function for the 2048pt floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
static arm_status arm_rfft_2048_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),1024);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 2048U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_2048;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096))
|
||||
/**
|
||||
@private
|
||||
* @brief Initialization function for the 4096pt floating-point real FFT.
|
||||
* @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
|
||||
*/
|
||||
|
||||
static arm_status arm_rfft_4096_fast_init_f32( arm_rfft_fast_instance_f32 * S ) {
|
||||
|
||||
arm_status status;
|
||||
|
||||
if( !S ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
|
||||
status=arm_cfft_init_f32(&(S->Sint),2048);
|
||||
if (status != ARM_MATH_SUCCESS)
|
||||
{
|
||||
return(status);
|
||||
}
|
||||
S->fftLenRFFT = 4096U;
|
||||
|
||||
S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_4096;
|
||||
|
||||
return ARM_MATH_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@brief Initialization function for the floating-point real FFT.
|
||||
@param[in,out] S points to an arm_rfft_fast_instance_f32 structure
|
||||
@param[in] fftLen length of the Real Sequence
|
||||
@return execution status
|
||||
- \ref ARM_MATH_SUCCESS : Operation successful
|
||||
- \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
|
||||
|
||||
@par Description
|
||||
The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
|
||||
Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
|
||||
@par
|
||||
This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
|
||||
*/
|
||||
|
||||
arm_status arm_rfft_fast_init_f32(
|
||||
arm_rfft_fast_instance_f32 * S,
|
||||
uint16_t fftLen)
|
||||
{
|
||||
typedef arm_status(*fft_init_ptr)( arm_rfft_fast_instance_f32 *);
|
||||
fft_init_ptr fptr = 0x0;
|
||||
|
||||
switch (fftLen)
|
||||
{
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096))
|
||||
case 4096U:
|
||||
fptr = arm_rfft_4096_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048))
|
||||
case 2048U:
|
||||
fptr = arm_rfft_2048_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_512) && defined(ARM_TABLE_BITREVIDX_FLT_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024))
|
||||
case 1024U:
|
||||
fptr = arm_rfft_1024_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512))
|
||||
case 512U:
|
||||
fptr = arm_rfft_512_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_128) && defined(ARM_TABLE_BITREVIDX_FLT_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256))
|
||||
case 256U:
|
||||
fptr = arm_rfft_256_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_64) && defined(ARM_TABLE_BITREVIDX_FLT_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128))
|
||||
case 128U:
|
||||
fptr = arm_rfft_128_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_32) && defined(ARM_TABLE_BITREVIDX_FLT_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64))
|
||||
case 64U:
|
||||
fptr = arm_rfft_64_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_16) && defined(ARM_TABLE_BITREVIDX_FLT_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32))
|
||||
case 32U:
|
||||
fptr = arm_rfft_32_fast_init_f32;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( ! fptr ) return ARM_MATH_ARGUMENT_ERROR;
|
||||
return fptr( S );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@} end of RealFFT group
|
||||
*/
|
||||
Reference in new issue
Block a user