欢迎来到天天文库
浏览记录
ID:54765308
大小:16.50 KB
页数:3页
时间:2020-04-21
《fft快速傅里叶变换-c语言实现.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include#include#defineN1000/*定义复数类型*/typedefstruct{doublereal;doubleimg;}complex;complexx[N],*W;/*输入序列,变换核*/intsize_x=0;/*输入序列的大小,在本程序中仅限2的次幂*/doublePI;/*圆周率*/voidfft();/*快速傅里叶变换*/voidinitW();/*初始化变换核*/voidchange();/*变址*
2、/voidadd(complex,complex,complex*);/*复数加法*/voidmul(complex,complex,complex*);/*复数乘法*/voidsub(complex,complex,complex*);/*复数减法*/voidoutput();intmain(){inti;/*输出结果*/system("cls");PI=atan(1)*4;printf("Pleaseinputthesizeofx:");scanf("%d",&size_x);printf("Ple
3、aseinputthedatainx[N]:");for(i=0;i4、;j+=2*l){/*一组蝶形运算*/for(k=0;k5、[i].real=cos(2*PI/size_x*i);W[i].img=-1*sin(2*PI/size_x*i);}}/*变址计算,将x(n)码位倒置*/voidchange(){complextemp;unsignedshorti=0,j=0,k=0;doublet;for(i=0;i0){j=j<<1;j6、=(k&1);k=k>>1;}if(j>i){temp=x[i];x[i]=x[j]7、;x[j]=temp;}}}/*输出傅里叶变换的结果*/voidoutput(){inti;printf("Theresultareasfollows");for(i=0;i=0.0001)printf("+%.4fj",x[i].img);elseif(fabs(x[i].img)<0.0001)printf("");elseprintf("%.4fj",x[i].img);}}voidad8、d(complexa,complexb,complex*c){c->real=a.real+b.real;c->img=a.img+b.img;}voidmul(complexa,complexb,complex*c){c->real=a.real*b.real-a.img*b.img;c->img=a.real*b.img+a.img*b.real;}voidsub(complexa,complexb,complex*c){c->real=a.real-b.real;c->img=a.img-b.img;9、}
4、;j+=2*l){/*一组蝶形运算*/for(k=0;k5、[i].real=cos(2*PI/size_x*i);W[i].img=-1*sin(2*PI/size_x*i);}}/*变址计算,将x(n)码位倒置*/voidchange(){complextemp;unsignedshorti=0,j=0,k=0;doublet;for(i=0;i0){j=j<<1;j6、=(k&1);k=k>>1;}if(j>i){temp=x[i];x[i]=x[j]7、;x[j]=temp;}}}/*输出傅里叶变换的结果*/voidoutput(){inti;printf("Theresultareasfollows");for(i=0;i=0.0001)printf("+%.4fj",x[i].img);elseif(fabs(x[i].img)<0.0001)printf("");elseprintf("%.4fj",x[i].img);}}voidad8、d(complexa,complexb,complex*c){c->real=a.real+b.real;c->img=a.img+b.img;}voidmul(complexa,complexb,complex*c){c->real=a.real*b.real-a.img*b.img;c->img=a.real*b.img+a.img*b.real;}voidsub(complexa,complexb,complex*c){c->real=a.real-b.real;c->img=a.img-b.img;9、}
5、[i].real=cos(2*PI/size_x*i);W[i].img=-1*sin(2*PI/size_x*i);}}/*变址计算,将x(n)码位倒置*/voidchange(){complextemp;unsignedshorti=0,j=0,k=0;doublet;for(i=0;i0){j=j<<1;j
6、=(k&1);k=k>>1;}if(j>i){temp=x[i];x[i]=x[j]
7、;x[j]=temp;}}}/*输出傅里叶变换的结果*/voidoutput(){inti;printf("Theresultareasfollows");for(i=0;i=0.0001)printf("+%.4fj",x[i].img);elseif(fabs(x[i].img)<0.0001)printf("");elseprintf("%.4fj",x[i].img);}}voidad
8、d(complexa,complexb,complex*c){c->real=a.real+b.real;c->img=a.img+b.img;}voidmul(complexa,complexb,complex*c){c->real=a.real*b.real-a.img*b.img;c->img=a.real*b.img+a.img*b.real;}voidsub(complexa,complexb,complex*c){c->real=a.real-b.real;c->img=a.img-b.img;
9、}
此文档下载收益归作者所有