conv
Convolution and polynomial multiplication.
| Library |
|
Syntax
Function call
-
w = conv(u,v,shape)— returns the part of the convolution specified by the parametershape. For example,conv(u,v,'same')returns only the central part of the convolution of the same size asu, andconv(u,v,'valid')returns only the part of the convolution calculated without the borders padded with zeros.
Arguments
Input arguments
# u is the input vector
+
vector
Details
The input vector, specified as a row vector or column vector. Vectors u and v they can have different length and data type.
If u has a type Float32, then the output data is also of type Float32. Otherwise, the function conv converts the input data to a type Float64 and returns the type Float64.
| Data types |
|
| Support for complex numbers |
Yes |
# v is the input vector
+
vector
Details
The input vector, specified as a row vector or column vector. Vectors u and v they can have different length and data type.
If v has a type Float32, then the output data is also of type Float32. Otherwise, the function conv converts the input data to a type Float64 and returns the type Float64.
| Data types |
|
| Support for complex numbers |
Yes |
# shape — the convolution subsection
+
'full' (by default) | 'same' | 'valid'
Details
The convolution subsection, defined as 'full', 'same' or 'valid'.
|
Full convolution (by default). |
|
The central part of the convolution is the same size as |
|
Only those parts of the convolution that are calculated without zero-padded borders. When using this option |
Additional Info
Convolution
Convolution of two vectors u and v it represents the area of overlap under the points when sliding v by u. From an algebraic point of view, convolution is the same operation as multiplying polynomials whose coefficients are elements. u and v.
Let m = length(u) and n = length(v). Then w — length vector m+n-1, `k`the th element of which is equal to
The sum is taken for all values j which lead to valid indexes for u(j) and v(k-j+1), namely j=max(1,k+1-n):1:min(k,m). By m=n this gives:
w(1) = u(1)*v(1)
w(2) = u(1)*v(2)+u(2)*v(1)
w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1)
...
w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)
...
w(2*n-1) = u(n)*v(n)
Using this definition, the function conv calculates a direct convolution of two vectors, not an FFT-based convolution.