fft4g模块解析-rdft

cdft(LEN,1,databuf,ip,wfft)

简介:

-------- Complex DFT (Discrete Fourier Transform) --------
    [definition]
        <case1>
            X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k<n
        <case2>
            X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k<n
        (notes: sum_j=0^n-1 is a summation from j=0 to n-1)
    [usage]
        <case1>
            ip[0] = 0; // first time only
            cdft(2*n, 1, a, ip, w);
        <case2>
            ip[0] = 0; // first time only
            cdft(2*n, -1, a, ip, w);
    [parameters]
        2*n            :data length (int)
                        n >= 1, n = power of 2
        a[0...2*n-1]   :input/output data (double *)
                        input data
                            a[2*j] = Re(x[j]), 
                            a[2*j+1] = Im(x[j]), 0<=j<n
                        output data
                            a[2*k] = Re(X[k]), 
                            a[2*k+1] = Im(X[k]), 0<=k<n
        ip[0...*]      :work area for bit reversal (int *)
                        length of ip >= 2+sqrt(n)
                        strictly, 
                        length of ip >= 
                            2+(1<<(int)(log(n+0.5)/log(2))/2).
                        ip[0],ip[1] are pointers of the cos/sin table.
        w[0...n/2-1]   :cos/sin table (double *)
                        w[],ip[] are initialized if ip[0] == 0.

 

使用方法:

    for(i = 0; i < LEN;i++)
        databuf[i] =i;
    double wfft[LEN];
    double tmpp;
//正向变换 cdft(LEN,
1,databuf,ip,wfft); for(i = 0; i < LEN;i+=2) printf("%f %f\n",databuf[i],databuf[i+1]); //反向变换 cdft(LEN,-1,databuf,ip,wfft); for(i = 0; i < LEN;i++) printf("%f ",databuf[i]*2.0/LEN);

 

databuf:原始数组

ip:存储位翻转中用到的反向值

wfft:存储三角函数值(cos/sin)

输出(输入则相反):

正向rdft:databuf[2k]:cos值(实部) databuf[2k+1]:sin值(虚部)

反向rdft:databuf 原始数据集   

rdft后的长度为原来的1/2

 

posted @ 2022-09-26 16:34  Aemnprsu_wx  阅读(382)  评论(0编辑  收藏  举报