These subroutines perform a sequential search for the locations of the
elements of sequence x in another sequence y.
Depending on the sign of the idir argument, the search direction
indicator, the location of either the first or last occurrence of each element
is indicated in the resulting indices array INDX. When an
exact match between elements is not found, the position is indicated as
0.
x, y | Subroutine |
Integer | ISSRCH |
Short-precision real | SSSRCH |
Long-precision real | DSSRCH |
Fortran | CALL ISSRCH | SSSRCH | DSSRCH (x, incx, n, y, incy, m, idir, indx) |
C and C++ | issrch | sssrch | dssrch (x, incx, n, y, incy, m, idir, indx); |
PL/I | CALL ISSRCH | SSSRCH | DSSRCH (x, incx, n, y, incy, m, idir, indx); |
Specified as: a one-dimensional array of (at least) length 1+(m-1)|incy|, containing numbers of the data type indicated in Table 153.
If idir >= 0, sequence y is searched from the first element to the last (1, n), thus finding the first occurrence of the element in the sequence.
If idir < 0, sequence y is searched from the last element to the first (n, 1), thus finding the last occurrence of the element in the sequence.
Specified as: a fullword integer. It can have any value.
If idir >= 0, the first occurrence of the element found in sequence y is indicated in array INDX.
If idir < 0, the last occurrence of the element found in sequence y is indicated in array INDX.
In all cases, if no match is found, 0 is indicated in array INDX.
Returned as: a one-dimensional array of length n, containing fullword integers; 0 <= (INDX elements) <= m.
These subroutines perform a sequential search for the first occurrence (or last occurrence, using a negative idir) of the locations of the elements of sequence x in another sequence y. The results of the sequential searches are returned in the indices array INDX, indicating the positions of the elements of sequence x in sequence y. The positions indicated in array INDX are calculated relative to the first sequence element position--that is, the position of y1. When an exact match between values of elements in sequences x and y is not found, 0 is indicated in array INDX for that position.
The results returned in array INDX are expressed as follows:
where:
See reference [75]. If n is 0, no search is performed.
It is important to note that a negative stride for sequence y reverses the direction of the search, because the order of the sequence elements is reversed in the array.
None
This example shows a search where sequences x and y have positive strides, and the search direction indicator, idir, is positive.
X INCX N Y INCY M IDIR INDX | | | | | | | | CALL ISSRCH( X , 1 , 3 , Y , 2 , 8 , 1 , INDX ) X = (0, 12, 3) Y = (0, . , 8, . , 12, . , 0, . , 1, . , 4, . , 0, . , 2)
INDX = (1, 3, 0)
This example shows a search where sequences x and y have positive strides, and the search direction indicator, idir, is negative.
X INCX N Y INCY M IDIR INDX | | | | | | | | CALL ISSRCH( X , 2 , 3 , Y , 2 , 8 , -1 , INDX ) X = (0, . , 12, . , 3) Y = (0, . , 8, . , 12, . , 0, . , 1, . , 4, . , 0, . , 2)
INDX = (7, 3, 0)
This example shows a search where sequences x and y have negative strides, and the search direction indicator, idir, is positive.
X INCX N Y INCY M IDIR INDX | | | | | | | | CALL ISSRCH( X , -1 , 3 , Y , -2 , 8 , 1 , INDX ) X = (0, 12, 3) Y = (0, . , 8, . , 12, . , 0, . , 1, . , 4, . , 0, . , 2)
INDX = (0, 6, 2)
This example shows a search where sequences x and y have negative strides, and the search direction indicator, idir, is negative.
X INCX N Y INCY M IDIR INDX | | | | | | | | CALL ISSRCH( X , -2 , 3 , Y , -1 , 8 , -1 , INDX ) X = (0, . , 12, . , 3) Y = (0, 8, 12, 0, 1, 4, 0, 2)
INDX = (0, 6, 8)