about IFFT?

Jul 27, 2012 at 1:58 PM

sorry for my poor English.

I have a IFFT question.My code like this:

            CudafyModule km = CudafyTranslator.Cudafy();

            GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target);
            gpu.LoadModule(km);

            ComplexD[] cm = new ComplexD[4];
            cm[0] = new ComplexD(1.5, 1);
            cm[1] = new ComplexD(2.5, 2);
            cm[2] = new ComplexD(3.5, 3);
            cm[3] = new ComplexD(4.5, 4);
            ComplexD[] dev_cm = gpu.CopyToDevice(cm);

            ComplexD[] ifftData = new ComplexD[4];
            ComplexD[] dev_ifftData = gpu.CopyToDevice(ifftData);

            Cudafy.Maths.FFT.GPGPUFFT gpuFFT = Cudafy.Maths.FFT.GPGPUFFT.Create(gpu);
            Cudafy.Maths.FFT.FFTPlan1D fft_1d = gpuFFT.Plan1D(Cudafy.Maths.FFT.eFFTType.Complex2Complex, Cudafy.Maths.FFT.eDataType.Double, 4, 1);

            fft_1d.Execute<ComplexD, ComplexD>(dev_cm, dev_ifftData, true);
            gpu.CopyFromDevice(dev_ifftData, ifftData);

            gpu.FreeAll();

 

The "cm" array is :

[0] {( 12, 10i )} Cudafy.Types.ComplexD

[1] {( -2.22044604925031E-16, -4i )} Cudafy.Types.ComplexD

[2] {( -2, -2i )} Cudafy.Types.ComplexD

[3] {( -4, 0i )} Cudafy.Types.ComplexD

 

But in MATLAB is :

[1]3.0 + 2.5i

[2]0.0 - 1.0i

[3]-0.5 - 0.5i

[4]-1.0 + 0.0i

 

Why?My code is wrong?

Thank you!

Coordinator
Aug 9, 2012 at 12:11 PM

Yes, MATLAB and FFTW or CUFFT give different results for inverse FFT. MATLAB scales the results while FFTW/CUFFT do not.

See http://objectmix.com/dsp/257091-ifft-conversion-using-fftw-libraries.html