The routine may be called by the names m01djf or nagf_sort_realmat_rank_columns.
m01djf ranks columns n1 to n2 of a matrix, using the data in rows m1 to m2 of those columns. The ordering is determined by first ranking the data in row m1, then ranking any tied columns according to the data in row , and so on up to row m2.
m01djf 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 columns preserve their ordering in the input data.
Knuth D E (1973) The Art of Computer Programming (Volume 3) (2nd Edition) Addison–Wesley
1: – Real (Kind=nag_wp) arrayInput
On entry: rows
of columns n1 to n2 of rm must contain real data to be ranked.
2: – IntegerInput
On entry: the first dimension of the array rm as declared in the (sub)program from which m01djf is called.
3: – IntegerInput
On entry: the index of the first row of rm to be used.
4: – IntegerInput
On entry: the index of the last row of rm to be used.
5: – IntegerInput
On entry: the index of the first column of rm to be ranked.
6: – IntegerInput
On entry: the index of the last column of rm to be ranked.
7: – Character(1)Input
On entry: if , the columns will be ranked in ascending (i.e., nondecreasing) order.
If , into descending order.
8: – Integer arrayOutput
On exit: elements n1 to n2 of irank contain the ranks of the corresponding columns of rm. Note that the ranks are in the range n1 to n2: thus, if the th column of rm is the first in the rank order, is set to n1.
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).