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
M01D
routines generate ranks, and the
M01E
routines 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 (see the example in
Section 10).
None.
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
If
or
, elements
m1 to
m2 of
iperm do not contain a permutation of the integers
m1 to
m2; on exit these elements are usually corrupted. To check the validity of a permutation without the risk of corrupting it, use
m01zbf.
Not applicable.
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.