These subroutines sort the elements of sequence x. The original positions of the elements in sequence x are returned in the indices array, INDX. Where equal elements occur in the input sequence, they do not necessarily remain in the same relative order in the output sequence.
x | Subroutine |
Integer | ISORTX |
Short-precision real | SSORTX |
Long-precision real | DSORTX |
Fortran | CALL ISORTX | SSORTX | DSORTX (x, incx, n, indx) |
C and C++ | isortx | ssortx | dsortx (x, incx, n, indx); |
PL/I | CALL ISORTX | SSORTX | DSORTX (x, incx, n, indx); |
Specified as: a fullword integer. It can have any value.
Returned as: a one-dimensional array of length n, containing fullword integers; 1 <= (INDX elements) <= n.
The elements of input sequence x are sorted into ascending order, in place and using a partition sort. The elements of output sequence x can be expressed as follows:
Where equal elements occur in the input sequence, they do not necessarily remain in the same relative order in the output sequence.
By specifying a negative stride for x, the elements of input sequence x are assumed to be reversed in the array, (xn, xn-1, ... , x1), thus producing a sort into descending order within the array.
In addition, the INDX array contains the n indices that indicate, for the elements in the sorted output sequence, the original positions of those elements in input sequence x. (These are not the positions in the array, but rather the positions in the sequence.) For each element xj in the input sequence, becoming element xxk in the output sequence, the elements in INDX are defined as follows:
To understand INDX when you specify a negative stride, you should remember that both the input and output sequences, x, are assumed to be in reverse order in array X, but INDX is not affected by stride. The sequence elements of x are assumed to be stored in your input array as follows:
The sequence elements of x are stored in your output array by ESSL as follows:
where the elements xxk are the elements xj, sorted into descending order in X. As an example of how INDX is calculated, if xx1 = xn-1, then INDX(1) = n-1.
If n is 0, no computation is performed. See reference [75].
Unable to allocate internal work area.
None
n < 0
This example shows how to sort a sequence x into ascending order by specifying a positive stride.
X INCX N INDX | | | | CALL ISORTX( X , 2 , 5 , INDX ) X = (2, . , -1, . , 5, . , 1, . , -2)
X = (-2, . , -1, . , 1, . , 2, . , 5) INDX = (5, 2, 4, 1, 3)
This example shows how to sort a sequence x into descending order by specifying a negative stride. Therefore, both the input and output sequences are assumed to be reversed in the array X. The input sequence is assumed to be stored as follows:
The output sequence is stored by ESSL as follows:
As a result, INDX is defined as follows:
For example, because output sequence element xx4 = 2 is input sequence element x5, then INDX(4) = 5.
X INCX N INDX | | | | CALL ISORTX( X , -1 , 5 , INDX ) X = (2, -1, 5, 1, -2)
X = (5, 2, 1, -1, -2) INDX = (1, 4, 2, 5, 3)