

   FFaasstt DDiissccrreettee FFoouurriieerr TTrraannssffoorrmm

        fft(z, inverse = FALSE)
        mvfft(z, inverse = FALSE)

   AArrgguummeennttss::

          z: a real or complex array containing the values to
             be transformed

    inverse: if `TRUE', the unnormalized inverse transform is
             computed (the inverse has a `+' in the exponent of
             e, but here, we do not divide by `1/length(x)').

   VVaalluuee::

        When `z' is a vector, the value computed and returned
        by `fft' is the unnormalized univariate Fourier trans-
        form of the sequence of values in `z'.  When `z' con-
        tains an array, `fft' computes and returns the multi-
        variate (spatial) transform.  If `inverse' is `TRUE',
        the (unnormalized) inverse Fourier transform is
        returned, i.e., if `y <- fft(z)', then `z' is `fft(y,
        inv=TRUE) / length(y)'.

        By contrast, `mvfft' takes a real or complex matrix as
        argument, and returns a similar shaped matrix, but with
        each column replaced by its discrete Fourier transform.
        This is useful for analyzing vector-valued series.

        The FFT is fastest when the length of of the series
        being transformed is highly composite (i.e. has many
        factors).  If this is not the case, the transform may
        take a long time to compute and will use a large amount
        of memory.

   RReeffeerreenncceess::

        Singleton, R. C. (1979).  Mixed Radix Fast Fourier
        Transforms, in Programs for Digital Signal Processing,
        IEEE Digital Signal Processing Committee eds.  IEEE
        Press.

   SSeeee AAllssoo::

        `convolve', `nextn'.

   EExxaammpplleess::

        x <- 1:4
        fft(x)
        all(fft(fft(x), inverse = TRUE)/(x*length(x)) == 1+0i)
        ## In general, not exactly, but still:
        x <- rnorm(100)
        all(Mod(fft(fft(x), inverse=TRUE)/(x*length(x)) - 1) < 1e-12)

        plot(fft(c(9:0,0:13, numeric(301))), type = "l")
        periodogram <- function(x) { # simple periodogram
          n <- length(x)
          Mod(fft(unclass(x)))[1:(n%/%2 + 1)]^2 / (2*pi*n)
        }
        data(sunspots)
        plot(10*log10(periodogram(sunspots)), type = "b", col = "blue")

