naginterfaces.library.sort.charvec_rank¶
- naginterfaces.library.sort.charvec_rank(ch, m1, l1, l2, order)[source]¶
charvec_rank
ranks a vector of character data in ASCII or reverse ASCII order of a specified substring.For full information please refer to the NAG Library document for m01dc
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/m01/m01dcf.html
- Parameters
- chstr, array-like, shape
Elements to of must contain character 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 element of to be ranked.
- l1int
Only the substring (:) of each element of is to be used in determining the rank order.
- l2int
Only the substring (:) of each element of is to be used in determining the rank order.
- orderstr, length 1
If , the values will be ranked in ASCII order.
If , in reverse ASCII 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, 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: .
- (errno )
On entry, .
Constraint: .
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
charvec_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.Only the substring (:) of each element of the array is used to determine the rank order.
- References
Knuth, D E, 1973, The Art of Computer Programming (Volume 3), (2nd Edition), Addison–Wesley