DSP_sp_fftSPxSP 函数中旋转矩阵是如何计算的?DSPLIB 3.4.0.0的历程是不是算错了?

TI的工程师 你们好:

我在6678上用单核计算 a=0:255 共256点的FFT 使用历程为DSPLIB 3.4.0.0 中的FFT_SP_Example_66_LE_ELF

得到的结果同matlab进行比较 发现得出的数据中 数字是对的  但是有的实部虚部与Matlab是反的 所以想问下是不是历程中的旋转矩阵计算有问题

下面是历程中旋转矩阵计算的代码 和我修改后的代码:

#define N 256
/* Number of unique sine waves in input data */
#define NUM_SIN_WAVES 4

/* Align the tables that we have to use */
#pragma DATA_ALIGN(x_ref, 8);
float   x_ref [2*N];

#pragma DATA_ALIGN(x_sp, 8);
float   x_sp [2*N];
#pragma DATA_ALIGN(y_sp, 8);
float   y_sp [2*N];
#pragma DATA_ALIGN(w_sp, 8);
float   w_sp [2*N];

void gen_twiddle_fft_sp (float *w, int n)
{
    int i, j, k;
    double x_t, y_t, theta1, theta2, theta3;
    const double PI = 3.141592654;

    for (j = 1, k = 0; j <= n >> 2; j = j << 2)
    {
        for (i = 0; i < n >> 2; i += j)
        {
            theta1 = 2 * PI * i / n;
            x_t = cos (theta1);
            y_t = sin (theta1);
            w[k] = (float) x_t;
            w[k + 1] = (float) y_t;

            theta2 = 4 * PI * i / n;
            x_t = cos (theta2);
            y_t = sin (theta2);
            w[k + 2] = (float) x_t;
            w[k + 3] = (float) y_t;

            theta3 = 6 * PI * i / n;
            x_t = cos (theta3);
            y_t = sin (theta3);
            w[k + 4] = (float) x_t;
            w[k + 5] = (float) y_t;
            k += 6;
        }
    }
}


void gen_twiddle_fft_sp_self (float *w, int n)
{
    int i, j, k;
    double x_t, y_t, theta1, theta2, theta3;
    const double PI = 3.141592654;

    for (j = 1, k = 0; j <= n >> 2; j = j << 2)
    {
        for (i = 0; i < n >> 2; i += j)
        {
            theta1 = 2 * PI * i / n;
            y_t = cos (theta1);
            x_t = sin (theta1);
            w[k] = (float) x_t;
            w[k + 1] = (float) y_t;

            theta2 = 4 * PI * i / n;
            y_t = cos (theta2);
            x_t = sin (theta2);
            w[k + 2] = (float) x_t;
            w[k + 3] = (float) y_t;

            theta3 = 6 * PI * i / n;
            y_t = cos (theta3);
            x_t = sin (theta3);
            w[k + 4] = (float) x_t;
            w[k + 5] = (float) y_t;
            k += 6;
        }
    }
}

红色是我修改之后的代码 只是把x_t 和 y_t 对换了一下 不过这回输出的结果就与Matlab一致了

在这想问下 我的修改是不是正确的 还是我忽略了什么东西!

4 个回复