fftconv: FFT-based convolution

View source: R/fftconv.R

fftconvR Documentation

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.

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.

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.

Author(s)

Kurt Hornik, Kurt.Hornik@wu-wien.ac.at,
adapted by John W. Eaton.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

See Also

conv, conv2

Examples


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


gjmvanboxtel/gsignal documentation built on Nov. 22, 2023, 8:19 p.m.