fft
Fast Fourier Transform

Description

Performs the fast Fourier transform on a vector or an array of either numeric or complex values.

Usage

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

Arguments

z a numeric or complex vector, matrix, or array. Can only be a matrix for mvfft.
inverse a logical flag. If TRUE, the inverse of the transform is computed. The default is FALSE.

Details

Applies the fast Fourier transform algorithm. No padding of the input data is done. If possible, length(z) is factored, and the factorization is used in the algorithm. Therefore, if length(z) is prime, there is no advantage in using fft over computing the transform explicitly.
If z is an array, fft returns the multi-dimensional unnormalized discrete Fourier transform of z, which is a complex array with the same shape as z. Therefore, if you want to compute the time transform on a multivariate time series, you must use mvfft.
The discrete Fourier transform is used to compute an approximation to the continuous Fourier transform of a periodic function F. In the usual definition, n points are sampled from F symmetrically around 0. That is, the domain of the sampled points is [-N/2,N/2], where N is the period of F. However this algorithm assumes the n points are sampled from the interval [0,N]. When this convention is followed, the resulting frequencies are shifted.
For example, let j be the index of the sampled points and suppose n is even. In this algorithm, the zero frequency corresponds to j=1, the positive frequencies correspond to 2 <= j <= n/2, the negative frequencies correspond to n/2+2 <= j <= n, and the Nyquist critical frequency corresponds to j = n/2+1. The definitions are analogous if n is odd. For more details, see Press et al. (1996).
Value
fftreturns the unnormalized discrete Fourier transform of the input data z, or the inverse transform if inverse=TRUE. This is of mode "complex". Because the unnormalized transform is computed, the commands fft(fft(z), inverse = TRUE) and fft(fft(z, inverse=TRUE)) return nz for an n-dimensional vector z. If you require Fourier coefficients, you should divide the value that fft returns by the length of the input vector.
mvfftreturns a matrix similar to the input argument z, but with each column replaced by its discrete Fourier transform or inverse discrete transform if inverse=TRUE.
References
Becker, R. A., Chambers, J. M., and Wilks, A. R. 1988. The New S Language: A Programming Environment for Data Analysis and Graphics. Pacific Grove, CA: Wadsworth & Brooks/Cole Advanced Books and Software.
Bloomfield, P. 1976. Fourier Analysis of Time Series: An Introduction. New York, NY: Wiley.
Press, W. H., et al. 1996. Numerical Recipes in Fortran 77: The Art of Scientific Computing.
Singleton, R. C. 1979. Mixed Radix Fast Fourier Transforms. Programs for Digital Signal Processing. IEEE Digital Signal Processing Committee, eds. IEEE Press.
See Also
spectrum.
Examples
x <- matrix(c(1, 2, 3, 2, 20, 26, 3, 26, 38), nrow = 3)
fft(x)
fft(x, inverse = TRUE)
mvfft(x)
Package stats version 6.0.0-69
Package Index