由于要用到信号处理,在vc中用到傅立叶变换,开始考虑用matkcom转换直接转换matlab工具箱工具,后来发现,后台要调用matlab,资源耗费太大,放弃了。继而考虑直接做。感到有点麻烦,因为要用到复数,本人看了一点资料,vc中可以定义复数,但不知道能不能定义复数数组。不知各位有没有做好的,傅立叶变换程序。谢了!!!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/2791/2791147.xml?temp=.3039667
      

  2.   

    ////////////////////////////////////////////////////////////////////////////////
    /*
       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;
    }