These subroutines compute the convolution and correlation of a sequence with another sequence using a direct method. The input and output sequences contain short-precision real numbers.
Notes:
Fortran | CALL SCOND | SCORD (h, inch, x, incx, y, incy, nh, nx, iy0, ny) |
C and C++ | scond | scord (h, inch, x, incx, y, incy, nh, nx, iy0, ny); |
PL/I | CALL SCOND | SCORD (h, inch, x, incx, y, incy, nh, nx, iy0, ny); |
The convolution and correlation of a sequence in array H with a sequence in array X are expressed as follows:
Convolution for SCOND:
Correlation for SCORD:
for k = iy0, iy0+1, ..., iy0+Ny-1
where:
It is assumed that elements outside the range of definition are zero. See reference [4].
SCORD can also perform the functions of SCON and SACOR; that is, it can compute convolutions and autocorrelations. To compute a convolution, you must specify a negative stride for H (see Example 9). To compute the autocorrelation, you must specify the two input sequences to be the same (see Example 10). In fact, you can also compute the autoconvolution by using both of these techniques together, letting the two input sequences be the same, and specifying a negative stride for the first input sequence.
None
This example shows how to compute a convolution of a sequence in H with a sequence in X, where both sequences are ramp functions.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCOND( H , 1 , X , 1 , Y , 1 , 4 , 8 , 0 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (11.0, 34.0, 70.0, 120.0, 130.0, 140.0, 150.0, 160.0, 151.0, 122.0, 72.0)
This example shows how the output from Example 1 differs when the value for IY0 is -2 rather than 0, and NY is 15 rather than 11. The output has two zeros at the beginning and end of the sequence, for points outside the range of nonzero output.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCOND( H , 1 , X , 1 , Y , 1 , 4 , 8 , -2 , 15 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (0.0, 0.0, 11.0, 34.0, 70.0, 120.0, 130.0, 140.0, 150.0, 160.0, 151.0, 122.0, 72.0, 0.0, 0.0)
This example shows how the same output as Example 1 can be obtained when H and X are interchanged, because the convolution is symmetric in H and X. (The arguments are switched in the calling sequence.)
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCOND( X , 1 , H , 1 , Y , 1 , 4 , 8 , 0 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (11.0, 34.0, 70.0, 120.0, 130.0, 140.0, 150.0, 160.0, 151.0, 122.0, 72.0)
This example shows how the output from Example 1 differs when a negative stride is specified for the sequence in H. By reversing the H sequence, the correlation is computed.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCOND( H , -1 , X , 1 , Y , 1 , 4 , 8 , 0 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (44.0, 81.0, 110.0, 130.0, 140.0, 150.0, 160.0, 170.0, 104.0, 53.0, 18.0)
This example shows how to compute the autoconvolution of a sequence by letting the two input sequences for H and X be the same. (X is specified for both arguments in the calling sequence.)
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCOND( X , 1 , X , 1 , Y , 1 , 4 , 4 , 0 , 7 ) X = (11.0, 12.0, 13.0, 14.0)
Y = (121.0, 264.0, 430.0, 620.0, 505.0, 364.0, 196.0)
This example shows how to compute a correlation of a sequence in H with a sequence in X, where both sequences are ramp functions.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCORD( H , 1 , X , 1 , Y , 1 , 4 , 8 , -3 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (44.0, 81.0, 110.0, 130.0, 140.0, 150.0, 160.0, 170.0, 104.0, 53.0, 18.0)
This example shows how the output from Example 6 differs when the value for IY0 is -5 rather than -3 and NY is 15 rather than 11. The output has two zeros at the beginning and end of the sequence, for points outside the range of nonzero output.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCORD( H , 1 , X , 1 , Y , 1 , 4 , 8 , -5 , 15 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (0.0, 0.0, 44.0, 81.0, 110.0, 130.0, 140.0, 150.0, 160.0, 170.0, 104.0, 53.0, 18.0, 0.0, 0.0)
This example shows how the output from Example 6 differs when H and X are interchanged (in the calling sequence). The output sequence is the reverse of that in Example 6. To get the full range of output, IY0 is set to -NX+1.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCORD( X , 1 , H , 1 , Y , 1 , 4 , 8 , -7 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (18.0, 53.0, 104.0, 170.0, 160.0, 150.0, 140.0, 130.0, 110.0, 81.0, 44.0)
This example shows how the output from Example 6 differs when a negative stride is specified for the sequence in H. By reversing the H sequence, the convolution is computed.
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCORD( H , -1 , X , 1 , Y , 1 , 4 , 8 , -3 , 11 ) H = (1.0, 2.0, 3.0, 4.0) X = (11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0)
Y = (11.0, 34.0, 70.0, 120.0, 130.0, 140.0, 150.0, 160.0, 151.0, 122.0, 72.0)
This example shows how to compute the autocorrelation of a sequence by letting the two input sequences for H and X be the same. (X is specified for both arguments in the calling sequence.)
H INCH X INCX Y INCY NH NX IY0 NY | | | | | | | | | | CALL SCORD( X , 1 , X , 1 , Y , 1 , 4 , 4 , -3 , 7 ) X = (11.0, 12.0, 13.0, 14.0)
Y = (154.0, 311.0, 470.0, 630.0, 470.0, 311.0, 154.0)