There are two common ways of describing a permutation using an integer vector
iperm. The first uses ranks:
holds the position to which the
th
data element should be moved in order to sort the data; in other words its rank in the sorted order. The second uses indices:
holds the
current position
of the data element which would occur in
th
position in sorted order. For example, given the values
to be sorted in ascending order, the ranks would be
and the indices would be
The routines
m01daf,
m01dbf,
m01dcf,
m01def,
m01dff,
m01djf,
m01dkf and
m01dzf generate ranks, and the routines
m01eaf,
m01ebf,
m01ecf and
m01edf require ranks to be supplied to specify the reordering. However if it is desired simply to refer to the data in sorted order without actually reordering them, indices are more convenient than ranks.
None.
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Not applicable.
Background information to multithreading can be found in the
Multithreading documentation.
None.
This example reads a matrix of real numbers and prints its rows
in ascending order as ranked by
m01def.
The program first calls
m01def
to rank the rows, and then calls
m01zaf to convert the rank vector to an index vector, which is used to refer to the rows in sorted order.