The routine may be called by the names m01dff or nagf_sort_intmat_rank_rows.
m01dff ranks rows m1 to m2 of a matrix, using the data in columns n1 to n2 of those rows. The ordering is determined by first ranking the data in column n1, then ranking any tied rows according to the data in column , and so on up to column n2.
m01dff uses a variant of list-merging, as described on pages 165–166 in Knuth (1973). The routine takes advantage of natural ordering in the data, and uses a simple list insertion in a preparatory pass to generate ordered lists of length at least . The ranking is stable: equal rows preserve their ordering in the input data.
Knuth D E (1973) The Art of Computer Programming (Volume 3) (2nd Edition) Addison–Wesley
1: – Integer arrayInput
On entry: columns n1 to n2 of rows
of im must contain integer data to be ranked.
2: – IntegerInput
On entry: the first dimension of the array im as declared in the (sub)program from which m01dff is called.
3: – IntegerInput
On entry: the index of the first row of im to be ranked.
4: – IntegerInput
On entry: the index of the last row of im to be ranked.
5: – IntegerInput
On entry: the index of the first column of im to be used.
6: – IntegerInput
On entry: the index of the last column of im to be used.
7: – Character(1)Input
On entry: if , the rows will be ranked in ascending (i.e., nondecreasing) order.
If , into descending order.
8: – Integer arrayOutput
On exit: elements
of irank contain the ranks of the corresponding rows of im. Note that the ranks are in the range m1 to m2: thus, if the th row of im is the first in the rank order, is set to m1.
9: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).