I am trying to utilize the multidimensional FFT fftwf_plan_dft_r2c_2d from a single array of data. I have a M data points, N number of times:
1 2 3 4 5 6 7 8 9
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]) )
The FFT results are not correct, but if I just take the FFT of M data points
1 2 3 4 5 6 7 8 9 10 11
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]) )
the result is correct. The data being loaded into the array is the same. What am I not understanding about multi-dimensional FFTs? I read through the help pages and I "thought" I was doing it right, but obviously I am missing something...
I was using the wrong plan: needed to use fftwf_plan_many_dft_r2c instead of a 2d. I missread the documentation that I was doing a 2 dimensional FFT (FFT rows then columns) instead of a one dimensional FFT across multiple "rows" of data.
Out of curiosity which FFT library are you using? As I have a audio matching program I must develop and I think FFT would be the way to go as there only small audio files