1

配列 {1,2,3,4,5,6} の FFT を fftw/C++ とオンライン計算機 ( http://calculator-fx.com/calculator/fast-fourier-transform-calculator-fft/ 1 次元離散フーリエ変換)。そして、結果は少し違ったように見えました。

ftw 出力:

0     21.000000      0.000000
1     -3.000000      5.196152
2     -3.000000      1.732051
3     -3.000000      0.000000
4      0.000000      0.000000
5      0.000000      0.000000

オンライン計算機の出力:

 21 + 0j
 -3 + 5.196152j
 -3 + 1.732051j
 -3 + 0j
 -3 - 1.732051j
 -3 - 5.196152j

上に示したように、fftw の後の 2 つの結果はゼロになりました。理由がわかりません。誰か助けてくれませんか?ありがとう。

[編集] cpp コード:

int main()
{
    fftw_complex *out;
    fftw_plan plan;

    double arr[]={1,2,3,4,5,6};
    int n = sizeof(arr)/sizeof(double);

    out = (fftw_complex*)fftw_malloc ( sizeof ( fftw_complex ) * n );
    plan = fftw_plan_dft_r2c_1d ( n, arr, out, FFTW_ESTIMATE );
    fftw_execute ( plan );

    for (int i = 0; i < n; i++ )
    {
        printf ( "  %3d  %12lf  %12lf\n", i, out[i][0], out[i][1] );
    }

    fftw_free(out);
    fftw_destroy_plan(plan);
    return 0;
}
4

1 に答える 1