欢迎来到天天文库
浏览记录
ID:59255264
大小:10.32 KB
页数:5页
时间:2020-09-08
《FFT算法的C语言编程.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include#include#definePI3./*ThisprogramisusedtoconductFFTorIFFTtransformbasedon2discompositiondatacanbeloadedbytypingonthekeyboardorfromfile.*/typedefstruct{doublereal;doubleimag;}complex;longNN;longt2t(longn,intM){longnn=0;for(inti=0;i2、M-1-i);n=n/2;}returnnn;}intdefM(longn){intM=0;while(pow(2,M)3、");for(i=0;getchar()!='*';i++)scanf("%lf%lf",&x[i].real,&x[i].imag);while(i4、);}i=0;while(!feof(fpi)){fscanf(fpi,"%lf",&a);fscanf(fpi,"%lf",&b);x[i].real=a;x[i].imag=b;i++;}fclose(fpi);while(i5、longi;longtemp;for(i=0;i6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
2、M-1-i);n=n/2;}returnnn;}intdefM(longn){intM=0;while(pow(2,M)3、");for(i=0;getchar()!='*';i++)scanf("%lf%lf",&x[i].real,&x[i].imag);while(i4、);}i=0;while(!feof(fpi)){fscanf(fpi,"%lf",&a);fscanf(fpi,"%lf",&b);x[i].real=a;x[i].imag=b;i++;}fclose(fpi);while(i5、longi;longtemp;for(i=0;i6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
3、");for(i=0;getchar()!='*';i++)scanf("%lf%lf",&x[i].real,&x[i].imag);while(i4、);}i=0;while(!feof(fpi)){fscanf(fpi,"%lf",&a);fscanf(fpi,"%lf",&b);x[i].real=a;x[i].imag=b;i++;}fclose(fpi);while(i5、longi;longtemp;for(i=0;i6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
4、);}i=0;while(!feof(fpi)){fscanf(fpi,"%lf",&a);fscanf(fpi,"%lf",&b);x[i].real=a;x[i].imag=b;i++;}fclose(fpi);while(i5、longi;longtemp;for(i=0;i6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
5、longi;longtemp;for(i=0;i6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
6、complexcom_mul(complexx1,complexx2){complexy;y.real=x1.real*x2.real-x1.imag*x2.imag;y.imag=x1.real*x2.imag+x2.real*x1.imag;returny;}complexcom_div(complexx1,complexx2){complexy;doubledown=x2.real*x2.real+x2.imag*x2.imag;y.real=(x1.real*x2.real+x1.imag*x2.imag)/down;y.imag=(x2.real*x1.imag-x1.rea
7、l*x2.imag)/down;returny;}voidfft(complexx[],longNN,intM){intm,i,j;longNw,Ni;complexWm,temp;for(m=0;m
此文档下载收益归作者所有