Convolve two vectors using the FFT for computation.
fftconv(x, y, n =NULL)
Arguments
x, y: input vectors.
n: FFT length, specified as a positive integer. The FFT size must be an even power of 2 and must be greater than or equal to the length of filt. If the specified n does not meet these criteria, it is automatically adjusted to the nearest value that does. If n = NULL
(default), then the overlap-add method is not used.
Returns
Convoluted signal, specified as a a vector of length equal to length (x) + length (y) - 1. If x and y are the coefficient vectors of two polynomials, the returned value is the coefficient vector of the product polynomial.
Details
The computation uses the FFT by calling the function fftfilt. If the optional argument n is specified, an n-point overlap-add FFT is used.
Examples
u <- rep(1L,3)v <- c(1,1,0,0,0,1,1)w1 <- conv(u, v)# time-domain convolutionw2 <- fftconv(u, v)# frequency domain convolutionall.equal(w1, w2)# same results