The S3L_grade family of functions computes the grade of the elements of a parallel array A. Grading is done in either descending or ascending order and is done either across the whole array or along a specified axis. The graded elements are stored in array G, using zero-based indexing when called from a C or C++ program and one-based indexing when called from an F77 or F90 program.
These two functions grade the elements across the entire array A and store the indices of the elements in descending or ascending order (S3L_grade_down or S3L_grade_up, respectively).
If A is an array of rank n and the product of its extents is l, G is a two-dimensional array whose extents are n x l.
Upon return of the function, every j-th column of array G is set to the indices of the j-th smallest (S3L_grade_down) or largest (S3L_grade_up) element of array A.
For example, if A is the 3 x 3 array
_ _ | 6 2 4 | | | | 1 3 8 | | | | 9 7 5 | - - |
and S3L_grade_down is called from a C program, it will store the following values in G.
_ _ | 2 1 2 0 2 0 1 0 1 | | | | 0 2 1 0 2 2 1 1 0 | - - |
For the same array A, S3L_grade_up would store the following values in G (again, using zero-based indexing).
_ _ | 1 0 1 0 2 0 2 1 2 | | | | 0 1 1 2 2 0 1 2 0 | - - |
When called by a Fortran program (F77/F90) each value in G would be one greater. For example, S3L_grade_up would store the following set of values.
_ _ | 2 1 2 1 3 1 3 2 3 | | | | 1 2 2 3 3 1 2 3 1 | - - |
The S3L_grade_detailed_down and S3L_grade_detailed_up functions differ from S3L_grade_down and S3L_grade_up in two respects:
Both grade along a single axis of A, as specified by the axis argument.
Both store a set of indices, but these indices do not indicate element positions directly. Instead, each stored index indicates the index of the corresponding element of A that has either
The j-th smallest value along the specified axis - S3L_grade_detailed_down
The j-th largest value along the specified axis - S3L_grade_detailed_up
This means G is an integer array whose rank and extents are the same as those of A.
Repeating the 3 x 3 sample array shown above,
_ _ | 6 2 4 | | | | 1 3 8 | | | | 9 7 5 | - - |
if S3_grade_detailed_down is called from a C program with the axis argument = 0, upon completion, G will contain the following values:
_ _ | 1 2 2 | | | | 2 1 0 | | | | 0 0 1 | - - |
If, instead, axis = 1, G will contain
_ _ | 0 2 1 | | | | 2 1 0 | | | | 0 1 2 | - - |
If S3L_grade_detailed_up is called from a C program with axis = 0, G will contain
_ _ | 1 0 0 | | | | 0 1 2 | | | | 2 2 1 | - - |
If S3L_grade_detailed_up is called from a C program with axis = 1, G will contain
_ _ | 2 0 1 | | | | 0 1 2 | | | | 2 1 0 | - - |
For F77 or F90 calls, each index value in these examples, including the axis argument, would be increased by 1.