naginterfaces.library.sort.intmat_​rank_​rows

naginterfaces.library.sort.intmat_rank_rows(im, m1, n1, order)[source]

intmat_rank_rows ranks the rows of a matrix of integer numbers in ascending or descending order.

For full information please refer to the NAG Library document for m01df

https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/m01/m01dff.html

Parameters
imint, array-like, shape

Columns to of rows to of must contain int data to be ranked.

m1int

Note: this argument represents an array index; the value you supply must be base-1 for compatibility with the NAG Engine.

The index of the first row of to be ranked.

n1int

The index of the first column of to be used.

orderstr, length 1

If , the rows will be ranked in ascending (i.e., nondecreasing) order.

If , into descending order.

Returns
irankint, ndarray, shape

Elements to of contain the ranks of the corresponding rows of . Note that the ranks are in the range to : thus, if the th row of is the first in the rank order, is set to .

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, has an illegal value: .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

intmat_rank_rows ranks rows to of a matrix, using the data in columns to of those rows. The ordering is determined by first ranking the data in column , then ranking any tied rows according to the data in column , and so on up to column .

intmat_rank_rows uses a variant of list-merging, as described on pages 165–166 in Knuth (1973). The function 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.

References

Knuth, D E, 1973, The Art of Computer Programming (Volume 3), (2nd Edition), Addison–Wesley