Performing 2D fast fourier transform in R

fft, r

Solution

As pointed out in the comments, `fft` can handle single or multi-dimensional input. From the docs:

When z is a vector, the value computed and returned by fft is the unnormalized univariate Fourier transform of the sequence of values in z. When z contains an array, fft computes and returns the multivariate (spatial) transform.

I think this documentation is confusing the terms (since an R array can have 1, 2, or more dimensions), but what they are trying to say is fairly clear.

Problem

I want to know how to perform 2D fft in R. I can see the function `fft` only but I want to do that in 2D. Is there a function available like `fft2` in matlab?

Original source