scaling factor for CUFFT
Asked Answered
G

2

6

I wrote a simple test program, where I was doing Complex to Complex FT's and I just generated some data 1..50 and stuck it in for the real and imaginary part for each index of the array.

When I do an operation like this IFFT(FFT(A)) = A

to test them out, I am getting different results for each library.

FFTW, I have to divide the output by len(A) to get back the original A

However, doing this forward then reverse FFT with CUFFT, it looks like I have to divide by (sqrt(2)*50) to get back to the original data.

Where is this extra square root factor coming from?

according to the CUFFT documentation: CUFFT performs un normalized FFTs; that is, performing a forward FFT on an input data set followed by an inverse FFT on the resulting set yields data that is equal to the input scaled by the number of elements. Scaling either transform by the reciprocal of the size of the data set is left for the user to perform as seen fit.

Thanks in Advance

Goatherd answered 9/3, 2011 at 21:56 Comment(3)
is it a 1D FFT function?Seethe
Can you mention the transforms you are performing ? the sqrt(2) does name make immediate sense.Jarnagin
That doesn't sound right. The CUDA documentation explicitly says that it should be scaled by the length of the array. Are you sure you are calculating the lengths correctly?Tammany
G
1

This ended up being a problem with the way the absolute values of the complex number was being calculated. in the std::complex library, it was computing the distance of the vector.

Goatherd answered 12/7, 2011 at 23:22 Comment(0)
F
7

CUFFT has the same behavior as FFTW, it computes unnormalized FFTs. IFFT(FFT(A))=n A where n is the length of the vector. The length n is in number of samples (not floats or bytes). There are some padding differences between FFTW and CUFFT with C2R and R2C that can screw up a simple comparison, but not for C2C. I would double-check your data setup and length calculations, and verify your plan in both FFTW and CUFFT.

Forecourt answered 23/6, 2011 at 21:28 Comment(0)
G
1

This ended up being a problem with the way the absolute values of the complex number was being calculated. in the std::complex library, it was computing the distance of the vector.

Goatherd answered 12/7, 2011 at 23:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.