DIY编程器网
标题:
用C语言实现FFT算法
[打印本页]
作者:
liyf
时间:
2011-4-25 23:40
标题:
用C语言实现FFT算法
用C语言实现FFT算法
/*****************fft programe*********************/
#include "typedef.h"
#include "math.h"
struct compx EE(struct compx b1,struct compx b2)
{
struct compx b3 ;
b3.real=b1.real*b2.real-b1.imag*b2.imag ;
b3.imag=b1.real*b2.imag+b1.imag*b2.real ;
return(b3);
}
void FFT(struct compx*xin,int N)
{
int f,m,nv2,nm1,i,k,j=1,l ;
/*int f,m,nv2,nm1,i,k,j=N/2,l;*/
struct compx v,w,t ;
nv2=N/2 ;
f=N ;
for(m=1;(f=f/2)!=1;m++)
{
;
}
nm1=N-1 ;
/*变址运算*/
for(i=1;i
#include
#include
#include "typedef.h"
float result[257];
struct compx s[257];
int Num=256 ;
const float pp=3.14159 ;
main()
{
int i=1 ;
for(;i<0x101;i++)
{
s[i].real=sin(pp*i/32);
s[i].imag=0 ;
}
FFT(s,Num);
for(i=1;i<0x101;i++)
{
result[i]=sqrt(pow(s[i].real,2)+pow(s[i].imag,2));
}
}
欢迎光临 DIY编程器网 (http://www.diybcq.com/)
Powered by Discuz! X3.2