| conv {gsignal} | R Documentation | 
Convolution and polynomial multiplication
Description
Convolve two vectors a and b.
Usage
conv(a, b, shape = c("full", "same", "valid"))
Arguments
| a,b | Input, coerced to vectors, can be different lengths or data types. | 
| shape | Subsection of convolution, partially matched to  | 
Details
The convolution of two vectors, a and b, represents the area of
overlap under the points as B slides across a. Algebraically,
convolution is the same operation as multiplying polynomials whose
coefficients are the elements of a and b.
The function conv uses the filter function, NOT
fft, which may be faster for large vectors.
Value
Output vector with length equal to length (a) + length (b) -
  1. When the parameter shape is set to "valid", the length of
the output is max(length(a) - length(b) + 1, 0), except when
length(b) is zero. In that case, the length of the output vector equals
length(a).
When a and b are the coefficient vectors of two polynomials,
the convolution represents the coefficient vector of the product
polynomial.
Author(s)
Tony Richardson, arichard@stark.cc.oh.us, adapted by John W.
Eaton.
 Conversion to R by Geert van Boxtel,
G.J.M.vanBoxtel@gmail.com.
Examples
u <- rep(1L, 3)
v <- c(1, 1, 0, 0, 0, 1, 1)
w <- conv(u, v)
## Create vectors u and v containing the coefficients of the polynomials
## x^2 + 1 and 2x + 7.
u <- c(1, 0, 1)
v <- c(2, 7)
## Use convolution to multiply the polynomials.
w <- conv(u, v)
## w contains the polynomial coefficients for 2x^3 + 7x^2 + 2x + 7.
## Central part of convolution
u <- c(-1, 2, 3, -2, 0, 1, 2)
v <- c(2, 4, -1, 1)
w <- conv(u, v, 'same')