| 查看: 529 | 回复: 4 | |||
[交流]
【求助】帮忙看看程序!谢谢了【已完结】 已有2人参与
|
|
这是fft的程序 运行中出了问题 不知哪的错误 #include #include #include #define N 1000 typedef struct { double real; double img; } complex; void fft(); //快速傅里叶变换 void initw(); void change(); void add(complex,complex,complex *); void mul(complex,complex,complex *); void sub(complex,complex,complex *); void output(); complex x(N),*w; int size_x=0; double PI; int main() { int i,method; void fft(); void initw(); void change(); void add(complex,complex,complex *); void mul(complex,complex,complex *); void sub(complex,complex,complex *); void divi(complex,complex,complex *); PI=atan(1)*4; printf("please input the size of x:\n" ;scanf("%d",&size_x); printf("please input the date in x(N):\n" ;for(i=0;i initw(); output(); return 0; } void fft() { int i=0,j=0,k=0,l=0; complex up,down,product; change(); for(i=0;i l=1< for(j=0;j for(k=0;k mul(x[j+k+l],w[size_x*k/2/l],&product); add(x[j+k],product,&up); sub(x[j+k],product,&down); x[j+k]=up; x[j+k+l]=down; } } } } void initw() { int i; w=(complex *)malloc(sizeof(complex)*size_x); for(i=0;i w.real=cos(2*PI/size_x*i); w.img=-1*sin(2*PI/size_x*i); } } void change() { complex temp; unsigned short i=0,j=0,k=0; double t; for(i=0;i k=1;j=0; t=(log(size_x)/log(2)); while((t--)>0) {j=j<<1;j|=(k&1);k=k>>1;} if(j>1) {temp=x;x=x[j];x[j]=temp;} } } void output() { int i; printf("the result are as follows \n" ;for(i=0;i printf("%.4f",x.real); if(x.img>=0.0001) printf("+%.4f\n",x.img); else if(fabs(x.img)<0.0001) printf("\n" ;else printf("%.4f\n",x.img); } } void add(complex a,complex b,complex *c) { c->real=a.real+b.real; c->img=a.img+b.img; } void mul(complex a,complex b,complex *c) { c->real=a.real*b.real-a.img*b.img; c->img=a.real*b.img+a.img*b.real; } void sub(complex a,complex b,complex *c) { c->real=a.real-b.real; c->img=a.img-b.img; } [ Last edited by 余泽成 on 2010-6-2 at 16:23 ] |
» 猜你喜欢
假如你的研究生提出不合理要求
已经有8人回复
萌生出自己或许不适合搞科研的想法,现在跑or等等看?
已经有4人回复
Materials Today Chemistry审稿周期
已经有4人回复
参与限项
已经有3人回复
实验室接单子
已经有4人回复
全日制(定向)博士
已经有4人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
» 本主题相关价值贴推荐,对您同样有帮助:
拜托大家帮忙看个简单程序
已经有11人回复
请帮忙看看外导信的意思,谢谢!
已经有10人回复
MC一个简单的程序,运行不了,哪位大侠帮看看怎么回事。多谢!
已经有7人回复
请各位大侠帮忙看看:煤堆自燃边界条件设置问题。谢谢!
已经有6人回复
帮忙看一段程序
已经有3人回复
求助DSC图,不会分析啊,大家帮忙看看,谢谢!!
已经有11人回复
投稿有答复了,些许激动请大家帮忙看看,谢谢大家!(在13楼增加第二封审稿意见)
已经有32人回复
小弟研一,女友目前保研,想一起出去,大家帮忙看下,谢谢。。。
已经有20人回复
帮忙看看这个程序吧
已经有4人回复
【求助】中毒了,大家帮忙看看。谢谢
已经有40人回复
大家帮忙看看,怎么回答,谢谢。
已经有11人回复
【求助】帮忙改写展宽程序
已经有11人回复

2楼2010-06-01 14:36:21
3楼2010-06-02 14:43:06
|
ompiling... fft.cpp D:\vc\FFT\fft.cpp(22) : error C2440: 'initializing' : cannot convert from 'const int' to 'complex' No constructor could take the source type, or constructor overload resolution was ambiguous D:\vc\FFT\fft.cpp(42) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(42) : error C2228: left of '.real' must have class/struct/union type D:\vc\FFT\fft.cpp(42) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(42) : error C2228: left of '.img' must have class/struct/union type D:\vc\FFT\fft.cpp(60) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(61) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(62) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(63) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(64) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(93) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(103) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(103) : error C2228: left of '.real' must have class/struct/union type D:\vc\FFT\fft.cpp(104) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(104) : error C2228: left of '.img' must have class/struct/union type D:\vc\FFT\fft.cpp(105) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(105) : error C2228: left of '.img' must have class/struct/union type D:\vc\FFT\fft.cpp(106) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(106) : error C2228: left of '.img' must have class/struct/union type D:\vc\FFT\fft.cpp(108) : error C2676: binary '[' : 'complex' does not define this operator or a conversion to a type acceptable to the predefined operator D:\vc\FFT\fft.cpp(108) : error C2228: left of '.img' must have class/struct/union type 执行 cl.exe 时出错. FFT.exe - 1 error(s), 0 warning(s) 这个错误! |
4楼2010-06-02 14:44:12
5楼2010-06-02 14:57:36












;
回复此楼