由于要用到信号处理,在vc中用到傅立叶变换,开始考虑用matkcom转换直接转换matlab工具箱工具,后来发现,后台要调用matlab,资源耗费太大,放弃了。继而考虑直接做。感到有点麻烦,因为要用到复数,本人看了一点资料,vc中可以定义复数,但不知道能不能定义复数数组。不知各位有没有做好的,傅立叶变换程序。谢了!!!
解决方案 »
- 求助:sendinput函数无效
- listbox control控件,m_list_info.AddString(strMsg);多行当中怎么才能添加到第一行?
- 100分!求在PC上通过手机USB数据线发送短信的VC++源码 哪位大侠帮帮忙
- VC2005动态文本框与变量关联
- 关于CFile的奇怪问题
- 请问,有人做过在richedit里面嵌入 gif 么?类似qq那样?(做过类似的进来聊聊)
- 怎么控制字符长度的输入
- Xtreme Toolkit中文问题
- 我的第一个windows程序——hellomsg有问题请帮我看看!!!
- 请问怎么自定义使用user32.dll里的windows API
- 求教get/writePrivateProfileString/int 32位环境中的用法
- 做过输入法的高手请进来(高分相赠!!!)
/*
This computes an in-place complex-to-complex FFT
x and y are the real and imaginary arrays of n=2^m points.
o(n)=n*log2(n)
dir = 1 gives forward transform
dir = -1 gives reverse transform
*/
bool FFT(int dir,int m,double *x,double *y)
{
long nn,i,i1,j,k,i2,l,l1,l2;
double c1,c2,tx,ty,t1,t2,u1,u2,z; /* Calculate the number of points */
nn = 1<<m; /* Do the bit reversal */
i2 = nn >> 1;
j = 0;
for (i=0;i<nn-1;i++) {
if (i < j) {
tx = x[i];
ty = y[i];
x[i] = x[j];
y[i] = y[j];
x[j] = tx;
y[j] = ty;
}
k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
} /* Compute the FFT */
c1 = -1.0;
c2 = 0.0;
l2 = 1;
for (l=0;l<m;l++) {
l1 = l2;
l2 <<= 1;
u1 = 1.0;
u2 = 0.0;
for (j=0;j<l1;j++) {
for (i=j;i<nn;i+=l2) {
i1 = i + l1;
t1 = u1 * x[i1] - u2 * y[i1];
t2 = u1 * y[i1] + u2 * x[i1];
x[i1] = x[i] - t1;
y[i1] = y[i] - t2;
x[i] += t1;
y[i] += t2;
}
z = u1 * c1 - u2 * c2;
u2 = u1 * c2 + u2 * c1;
u1 = z;
}
c2 = sqrt((1.0 - c1) / 2.0);
if (dir == 1)
c2 = -c2;
c1 = sqrt((1.0 + c1) / 2.0);
} /* Scaling for forward transform */
if (dir == 1) {
for (i=0;i<nn;i++) {
x[i] /= (double)nn;
y[i] /= (double)nn;
}
} return true;
}