Learn R Programming

gsignal (version 0.3-1)

fftconv: FFT-based convolution

Description

Convolve two vectors using the FFT for computation.

Usage

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.

Value

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.

See Also

conv, conv2

Examples

Run this code
# NOT RUN {
u <- rep(1L, 3)
v <- c(1, 1, 0, 0, 0, 1, 1)
w1 <- conv(u, v)              # time-domain convolution
w2 <- fftconv(u, v)           # frequency domain convolution
all.equal(w1, w2)             # same results

# }

Run the code above in your browser using DataLab