CONVOLUTION - Compute z = x convolved with y
conv compute the convolution of two input vector arrays
Input:
lx length of x array
ifx sample index of first x
x array[lx] to be convolved with y
ly length of y array
ify sample index of first y
y array[ly] with which x is to be convolved
lz length of z array
ifz sample index of first z
Output:
z array[lz] containing x convolved with y
Function Prototype:
void conv (int lx, int ifx, float *x, int ly, int ify, float *y,
int lz, int ifz, float *z);
Notes:
The operation z = x convolved with y is defined to be
ifx+lx-1
z[i] = sum x[j]*y[i-j] ; i = ifz,...,ifz+lz-1
j=ifx
The x samples are contained in x[0], x[1], ..., x[lx-1]; likewise for
the y and z samples. The sample indices of the first x, y, and z values
determine the location of the origin for each array. For example, if
z is to be a weighted average of the nearest 5 samples of y, one might
use
...
x[0] = x[1] = x[2] = x[3] = x[4] = 1.0/5.0;
conv(5,-2,x,lx,0,y,ly,0,z);
...
In this example, the filter x is symmetric, with index of first sample = -2.
This function is optimized for architectures that can simultaneously perform
a multiply, add, and one load from memory; e.g., the IBM RISC System/6000.
Because, for each value of i, it accumulates the convolution sum z[i] in a
scalar, this function is not likely to be optimal for vector architectures.
Author: Dave Hale, Colorado School of Mines, 11/23/91