📄 cfft_simd.c
字号:
/*******************************************************************************
*
* Function: cfft_simd_twiddle_calc - Calculate cfft_simd twiddle factors
*
* Synopsis: #include "cfft_simd.h"
*
*
*
// prototype
//==================================================================================
//void cfft_simd_twiddle_calc(Tcfft_simd pm *pfft); // pointer to fft object
//
//==================================================================================
* Description:
* This function calculates twiddle factors that are used by the cfft_simd
* routine. Two arrays are filled pfft->twid_real and pfft->twid_imag.
* pfft->N/2 factors for each array are calculated according to the
* following equations:
* pfft->twid_real[k] = cos(2*pi/pfft->N*k);
* pfft->twid_real[k] = -sin(2*pi/pfft->N*k); // k=0:N/2-1
* Caution:
* The function cfft_simd_init must be called before calling this function.
* Other wise this function will not have a valid pointer to the arrays
* where the twiddle factors are stored.
*
* Author: Darrel Judd
* Judd Labs, Inc.
* 801-756-2057
* drjudd@ieee.org
*
* Revisions:
* Created June, 2003 - Darrel Judd
************************************************************************************/
#include "cfft_simd.h"
#define pi (3.141592654)
void cosf_sinf_simd(float *x,float *y);
void cfft_simd_twiddle_calc(Tcfft_simd pm *pfft) // pointer to fft object
{
U32 i;
float x[2]; // inputs to cosf_sinf_simd routine
float y[2]; // outputs to cosf_sinf_simd routine
float c = 2*pi/(float) pfft->N;
float k;
// calculate twiddle factors
#pragma SIMD_for
for(i=0;i<pfft->N/2;i++)
{
k=(float) i;
// 2*pi/N * k :k=0-N/2-1
x[0]=k*c;
x[1]=-k*c;
// calculate cosine and sine in parallel
cosf_sinf_simd(x,y);
// store results
pfft->twid_real[i]=y[0];
pfft->twid_imag[i]=y[1];
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -