naginterfaces.library.sort.arbitrary_​rank

naginterfaces.library.sort.arbitrary_rank(compar, m1, m2, data=None)[source]

arbitrary_rank ranks arbitrary data according to a user-supplied comparison function.

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

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/m01/m01dzf.html

Parameters
comparcallable retval = compar(i, j, data=None)

must specify the relative ordering of any two data items; it must return if item must come strictly after item in the rank ordering.

Parameters
iint

and identify the data items to be compared.

jint

and identify the data items to be compared.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalbool

Must be if item must come strictly after item in the rank ordering.

m1int

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

must specify the lower bound of the range of data items to be ranked, and the range of ranks to be assigned. Specifically, arbitrary_rank ranks the data items identified by integers in the range to , and assigns ranks in the range to which are stored in elements to of .

m2int

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

must specify the upper bound of the range of data items to be ranked, and the range of ranks to be assigned. Specifically, arbitrary_rank ranks the data items identified by integers in the range to , and assigns ranks in the range to which are stored in elements to of .

dataarbitrary, optional

User-communication data for callback functions.

Returns
irankint, ndarray, shape

Elements to of contain the ranks of the data items to . Note that the ranks are in the range to : thus, if item is first in the rank ordering, contains .

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Notes

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

arbitrary_rank is a general purpose function for ranking arbitrary data. arbitrary_rank does not access the data directly; instead it calls to determine the relative ordering of any two data items. The data items are identified simply by an integer in the range to .

arbitrary_rank 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 .

References

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