単一のデータ配列から多次元 FFT fftwf_plan_dft_r2c_2d を利用しようとしています。M 個のデータ ポイントが N 回あります。
float *input = (float*)malloc( M * N * sizeof( float ) );
// load M*N data points data
fftwf_complex *outputFFT = (fftwf_complex*)fftwf_malloc( N * ((M/2) + 1) * sizeof( fftwf_complex ) );
fftwf_plan forwardFFTPlan = fftwf_plan_dft_r2c_2d( N, M, input, outputFFT, FFTW_ESTIMATE );
fftwf_execute( forwardFFTPlan );
fftwf_destroy_plan( forwardFFTPlan );
// Plot M data points, ignore the rest. Plotting magnitude of the data sqrtf( ([REAL] * [REAL]) + ([IMAG] * [IMAG]) )
FFT の結果は正しくありません (MATLAB スクリプトの動作によって検証されています) が、M データ ポイントの 1D FFT を取得した場合:
for( int i = 0; i < N; i++ )
{
float *input = (float*)malloc( M * sizeof( float ) );
// load M data points
fftwf_complex *outputFFT = (fftwf_complex*)fftwf_malloc( ((M/2) + 1) * sizeof( fftwf_complex ) );
fftwf_plan forwardFFTPlan = fftwf_plan_dft_r2c_1d( M, input, outputFFT, FFTW_ESTIMATE );
fftwf_execute( forwardFFTPlan );
fftwf_destroy_plan( forwardFFTPlan );
}
// Plot M data points, ignore the rest. Plotting magnitude of the data sqrtf( ([REAL] * [REAL]) + ([IMAG] * [IMAG]) )
結果は正しいです。配列にロードされるデータは同じです。多次元 FFT について理解していないことは何ですか? ヘルプページを読んで、正しくやっていると「思った」のですが、明らかに何かが欠けています...