HP MLIB User's Guide Vol. 2 7th Ed.

Chapter 6 Correlation and Convolution Subprograms 597
Correlation and convolution SCONV/DCONV
incy Increment for the array y, incy 0. is stored in
y((k1)×incy+1). incy will normally be positive whether
computing the correlation or the convolution. Use incy
= 1 if the vector y is stored contiguously in array y, that
is, if is stored in y(k). Refer to “Notes.
m The length of the y vector. m > 0.
n The length of the w vector. n > 0.
Output y The convolution or correlation vector y of length m.
leny = (m1)×|incy|+1.
Notes These subprograms do not use the BLAS indexing scheme described in “BLAS
indexing conventions” on page 35. Indexing works the same way as the BLAS
for a positive increment but, for a negative increment, these subprograms
access data backward from the beginning of the array passed to it rather than
from the end. To index backward through an array, as desired for a convolution,
the ending location of the array should be passed to the subprogram. Refer to
“Example 2” on page 598.
To compute the complete correlation or convolution vector, including both tails
as well as the fully engaged portion, append n1 zeros to each end of the x
vector. The fully engaged portion of the correlation or convolution of the
resulting vector is the complete correlation or convolution corresponding to the
original x vector. Refer to“Example 2” on page 598
Example 1 Compute the fully engaged portion of the discrete correlation of the REAL*4
vectors x = (4, 1, 3, 5, 2) and w = (2, 1) stored in arrays X and W,
respectively. In this instance, n = 2 and m+n1 = 5, so m =4.
INTEGER*4 INCX,INCW,INCY,M,N
REAL*4 X(5),W(2),Y(4)
DATA X / 4.0 , 1.0 , 3.0 , 5.0, 2.0 /
DATA W / 2.0 , 1.0 /
M = 4
N = 2
INCX = 1
INCW = 1
INCY = 1
CALL SCONV (X,INCX,W,INCW,Y,INCY,M,N)
The result is y = (9, 5, 11, 12).
y
˜
k
y
˜
k