Fast Convolution

Usage

convolve(x, y, conj = TRUE)

Arguments

x,y numeric sequences of the same length to be convolved.

Value

This function uses the Fast Fourier Transform to compute the (circular) convolution of the sequences given as its arguments. If r <- convolve(x,y) and n <- length(x), then

r[k] = sum(i=1,..,n; x[i] * y[k-i])

for k = 1,...,n, where y[j] == y[n+j] for j < 0.

The Fast Fourier Transform, fft, is used for efficiency.

References

Brillinger, D. R. (1981). Time Series: Data Analysis and Theory, Second Edition. San Francisco: Holden-Day.

See Also

fft, nextn.

Examples

x <- c(0,0,0,100,0,0,0)
y <- c(0,0,1, 2 ,1,0,0)/4
round(convolve(x,y), 7)# this is *NOT* what you first thought..
x <- rnorm(50);y <- rnorm(50)
all(convolve(x,y), convolve(y,x))
all(convolve(x,y, conj = FALSE), rev(convolve(y,x)))


[Package Contents]