1) Do I have the sequence correct [R2C], C2C, [C2R]?
No, there are two domains in Fourier transform: space and frequency. A transform goes from space to frequency with CUFFT_FORWARD
and frequency to space with CUFFT_INVERSE
.
2) Should I run C2C in one direction once ?
Depending on the usage of Hermitian symmetry you dont necessarily need C2C
(see below).
3) Which direction should I use (forward or backward)?
If you want to apply an image processing filter, your output is most likely in the same space as your input, hence you have to apply as one forward transformation and one inverse transformation.
Notes on data layout and R2C
/ C2R
optimizations
When using C2R
or R2C
transforms, cufft
is making use of the Hermitian symmetry of the frequency-space vector, hence solely storing the first half of the vector (the remaining part is not even touched):
Apart from the general complex-to-complex (C2C) transform, cuFFT implements efficiently two other types: real-to-complex (R2C) and complex-to-real (C2R). In many practical applications the input vector is real-valued. It can be easily shown that in this case the output satisfies Hermitian symmetry ( X k = X N − k ∗ , where the star denotes complex conjugation). The converse is also true: for complex-Hermitian input the inverse transform will be purely real-valued. cuFFT takes advantage of this redundancy and works only on the first half of the Hermitian vector.
If the operation you are performing in frequency domain does not have the same Hermitian symmetry, the optimization is not true anymore, and the C2R
operation would not provide you the the expected result.
Also note the data requirements and layout of the approach which is a bit different than the one for C2C
.