Let us consider a 2D discrete fast Fourier transform of a separable function:
using FFTW xs = collect(0.0:0.1:0.9) ys = xs zs = cos.(xs).^2*sin.(ys') fzs = fft(zs)
The result of 2D DFF transform of
On the other hand, since the function is separable, we can compute 2D Fourier transform as a product of two 1D Fourier transforms:
fzs2 = fft(cos.(xs).^2)*fft(sin.(ys))'
This gives us
As we see, the two results do not exactly coincide. However, if we permute the columns of
fzs2, we actually obtain
fzs: we need to permute columns 2 and 10, 3 and 9, etc. If one does fft shift, it corresponds to exchanging columns corresponding to ky and -ky.
Can anyone explain why this happens?