conv: Convolution

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/filter.R

Description

A Matlab/Octave compatible convolution function that uses the Fast Fourier Transform.

Usage

1
conv(x, y)

Arguments

x,y

numeric sequences to be convolved.

Details

The inputs x and y are post padded with zeros as follows:

ifft(fft(postpad(x, n) * fft(postpad(y, n))))

where n = length(x) + length(y) - 1

Value

An array of length equal to length(x) + length(y) - 1. If x and y are polynomial coefficient vectors, conv returns the coefficients of the product polynomial.

Author(s)

Original Octave version by Paul Kienzle pkienzle@user.sf.net. Conversion to R by Tom Short.

References

Octave Forge https://octave.sourceforge.io/

See Also

convolve, fft, ifft, fftfilt, poly

Examples

1
2
3
conv(c(1,2,3), c(1,2))
conv(c(1,2), c(1,2,3))
conv(c(1,-2), c(1,2))

Example output

Attaching package: 'signal'

The following objects are masked from 'package:stats':

    filter, poly

[1] 1 4 7 6
[1] 1 4 7 6
[1]  1.000000e+00 -2.960595e-16 -4.000000e+00

signal documentation built on May 25, 2021, 9:06 a.m.

Related to conv in signal...