Loading LOADSUB ALL FROM "FFT.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB Convolve FROM "MATHLIB.HTS"
Usage INTEGER Logn
REAL A(*),B(*),C(*),S(*)
CALL Convolve(Logn,A(*),B(*),C(*),S(*))
Description
Convolve calculates the convolution of the sequences in the arrays A and B and places the result in the array C. Logn is the base-2 log of the number of points in the sequences to be convolved. The arrays A and B must have at least 2Logn elements and the arrays C and S must have at least 2Logn+1 elements; if they have more than the required number of elements, the extra elements are ignored and unmodified. S is a scratch array of at least the size C. It contains nothing useful after the function has run, but is needed to store intermediate results within the function. The number of elements in A and B denoted by each permitted value of Logn is shown in the table below:
Logn No. Elements (2Logn)
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
11 2048
12 4096
13 8192
14 16384
The number of elements required in C and S for each value of Logn is twice the value given in the table above. S is used internally by Convolve and contains no usefule data after Convolve has run.
If a(x) and b(x) are the functions being tested, if the interval of interest is x (0,T), and if a and b are zero outside this interval, the convolution of a and b, c(x), is defined by the relation \
Note that, while f(x) and b(x) are nonzero on the interval x (0,T), c(x) is nonzero on the interval x (0,2T).
If the functions a and b are only defined at regularly-spaced discrete points x = [k+½]T/N, k = {0,1,2,...,N-1}, the integration can be approximated by assuming that a(x) and b(x) are constant and equal to a([k+½]T/N) and b([k+½]T/N) between x = kT/N and x = (k+1)T/N. The expression above can then be replaced by
In this case, c([k+½]T/N) is defined for k = {0,...,2N-1}.
Convolve returns the values of c([k+½]T/N) in the array C.
Errors
Convolve causes an HTBasic error if its arguments are not of the types shown in the USAGE section, above, if Logn is not between 2 and 15, inclusive, or if the size of A, B, or C is smaller than the values described above.
See Also
Conv, Correlate, Filter, Fft, Power_spectrum
|