📄 fft1k.c
字号:
#include <math.h>
/* COMPLEX STRUCTURE */
typedef struct {
float real, imag;
} COMPLEX;
void fft_c(int n, COMPLEX *x, COMPLEX *w);
#define PI 3.14159265358979323846
int n = 1024;
COMPLEX x[1024],w[1024];
void main()
{
int i;
x[0].real = 1.0;
fft_c(n,x,w);
}
void fft_c(int n,COMPLEX *x,COMPLEX *w)
{
COMPLEX u,temp,tm;
COMPLEX *xi,*xip,*wptr;
int i,j,le,windex;
/* start fft */
windex = 1;
for(le=n/2 ; le > 0 ; le/=2) {
wptr = w;
for (j = 0 ; j < le ; j++) {
u = *wptr;
for (i = j ; i < n ; i = i + 2*le) {
xi = x + i;
xip = xi + le;
temp.real = xi->real + xip->real;
temp.imag = xi->imag + xip->imag;
tm.real = xi->real - xip->real;
tm.imag = xi->imag - xip->imag;
xip->real = tm.real*u.real - tm.imag*u.imag;
xip->imag = tm.real*u.imag + tm.imag*u.real;
*xi = temp;
}
wptr = wptr + windex;
}
windex = 2*windex;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -