资源描述:
《按时间抽取基2-FFT算法.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*按时间抽取基2-FFT算法点数不满足2^A次幂事,自动向上取,相差点数自动补零*/#include#include#include#include#defineN1200*1024typedefunsignedintuint;typedefstruct//定义复数{doublereal;doubleimag;}Plural;PluralX[N],*W;uintsize_N,C;doublePI=atan(1)*4;voidInit();/*初始化模块
2、*/voidprint();/*打印模块*/voidchange();/***倒序模块***/voidmyscanf();/*读取x(n)模块*/voidsum(Plurala,Pluralb,Plural*c);/*复数加减模块*/voidadd(Plurala,Pluralb,Plural*c);/*复数加模块*/voidmult(Plurala,Pluralb,Plural*c);/*复数乘模块*/voids(Plurala,Plural*c);voidfft();/***FFT模块***/voidifft();in
3、tmain(){doublestart,end,time;freopen("D:\360data\重要数据\桌面\11.txt","r",stdin);Pluralc;printf("输入N的个数:");scanf("%d",&size_N);printf("");myscanf();Init();start=clock();change();fft();print();end=clock();time=end-start;printf("time=%gms",time);start=clock();cha
4、nge();ifft();print();end=clock();time=end-start;printf("time=%gms",time);return0;}voidchange(){uintLH,N1,J,K,I;PluralT;LH=C/2;J=LH;N1=C-2;for(I=1;I=K){J=J-K;K=K/2;}J=J+K;}}voidmyscanf(){uinti;C=pow(2,(ceil)(
5、log(size_N)/log(2)));for(i=0;i6、.imag);}voidadd(Plurala,Pluralb,Plural*c){c->real=a.real+b.real;c->imag=a.imag+b.imag;}voidmult(Plurala,Pluralb,Plural*c){c->real=a.real*b.real-a.imag*b.imag;c->imag=a.real*b.imag+a.imag*b.real;}voidsum(Plurala,Pluralb,Plural*c){c->real=a.real-b.real;c->imag=a.ima
7、g-b.imag;}voids(Plural*c){c->real=c->real/2;;c->imag=c->imag/2;}voidfft(){charL,M;uintJ,B,K,P;Pluralt,*W,G;M=ceil(log(C)/log(2));W=(Plural*)malloc(sizeof(Plural)*(C/2));for(J=0;J8、%d",C);B=1;for(L=1;L<=M;L++)//第一重循环,级数{for(J=0;J