FFTW gives wrong results in comparison to MATLAB

245 views Asked by At

After analysing some signal data, I do some resynthesis. For analysing e.g. a wav-file I use CUDA-CUFFT for 1D-complex-FFT-transformation, after some signal processing operations (cutting pieces of signals,...) I do an IFFT-tranformation using FFTWF (FFTW=for float type).

On the CUDA-side I verified the FFT-transformation with MATLAB and get almost the same results (due to round-off errors it's not exactyl the same). After cutting the signal and performin the FFTShift-operation the signals seem to be almost equal. plot showing the difference of the magnitudes of the matlab values with my values after cutting the signal and performin the fftshift operation

But after the IFFT-operation I get complete different results (directly after the IFFT-operation I reverse the output, which I also do in MATLAB -> and finally I save the FFTW-output to a binary file for comparison)

P.S:(for additional information. after flipping the output I norm the results with sqrtf(FFTLEN); (on the CUDA-site I norm the output with 1/sqrtf(FFTLEN)

magnitude difference plot after the IFFT operation and performing the flipud/reverse in MATLAB and in my program

For the IFFT-transformation with FFTW I use the following syntax in the documentation: http://www.fftw.org/doc/Complex-One_002dDimensional-DFTs.html But instead of using the fftw_complex type I use the C++-complex-type and cast it to fftw_complex-type. The operation sign is FFTW_BACKWARD beacuse I use CUFFT_FORAWRD on the CUDA-site:

fftwf_plan localFFTPlan;
localFFTPlan = fftwf_plan_dft_1d((int)sFFTParams.uFFTLength, reinterpret_cast<fftwf_complex*>(&tFFTraw[0]), reinterpret_cast<fftwf_complex*>(&tFFTin[0]), FFTW_BACKWARD, FFTW_MEASURE);
fftwf_execute(localFFTPlan);
fftwf_destroy_plan(localFFTPlan);

In MATLAB the same operation is performed like this:

flipud(ifft(fftshift(st))

Can anyone help me, why the results get wrong directyl after the IFFT-transformation(as shown above, before the operation everything is fine)?

EDIT the array allocation looks like the following statement: TFFTContainer tFFTin(sFFTParams.uFFTLength, gComplexZero);

0

There are 0 answers