naginterfaces.library.sort.realvec_rank¶
- naginterfaces.library.sort.realvec_rank(rv, m1, order)[source]¶
realvec_rank
ranks a vector of float numbers in ascending or descending order.For full information please refer to the NAG Library document for m01da
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/m01/m01daf.html
- Parameters
- rvfloat, array-like, shape
Elements to of must contain float values 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 element of to be ranked.
- orderstr, length 1
If , the values 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 elements of . Note that the ranks are in the range to : thus, if is the first element in the rank order, is set to .
- Raises
- NagValueError
- (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.
realvec_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 . The ranking is stable: equal elements preserve their ordering in the input data.
- References
Knuth, D E, 1973, The Art of Computer Programming (Volume 3), (2nd Edition), Addison–Wesley