1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
//$Procedure IOVCMP ( Inverse order vector with compressed range )
pub fn IOVCMP(DARRAY: &[f64], NDIM: i32, IORDER: &mut [i32], INVORD: &mut [i32], RNGMAX: &mut i32) {
let DARRAY = DummyArray::new(DARRAY, 1..);
let mut IORDER = DummyArrayMut::new(IORDER, 1..);
let mut INVORD = DummyArrayMut::new(INVORD, 1..);
let mut NUPRED: i32 = 0;
//
// Local variables
//
//
// First step: create an order vector for DARRAY.
//
spicelib::ORDERD(DARRAY.as_slice(), NDIM, IORDER.as_slice_mut());
//
// Produce the corresponding inverse order vector.
//
for I in 1..=NDIM {
INVORD[IORDER[I]] = I;
}
//
// Step through the order vector, keeping track of the count of
// unique predecessors, in the array that would be produced by
// sorting DARRAY, of each element pointed to by an element of the
// order vector.
//
// The element of DARRAY at index IORDER(1) has no predecessors,
// and the element INVORD( IORDER(1) ) is already correct. So
// we start at the second element of IORDER (if it exists).
//
// Initialize NUPRED to the number of unique predecessors of
// the first value.
//
NUPRED = 0;
for I in 2..=NDIM {
//
// At this point, NUPRED is the number of unique predecessors of
// DARRAY(I). I is greater than or equal to 2.
//
if (DARRAY[IORDER[I]] > DARRAY[IORDER[(I - 1)]]) {
//
// DARRAY( IORDER(I) ) is strictly greater than, and hence not
// a copy of, its predecessor. It has NUPRED + 1 unique
// predecessors in the array produced by sorting DARRAY.
//
NUPRED = (NUPRED + 1);
//
// The position of DARRAY( IORDER(I) ) in the sorted,
// compressed set derived from DARRAY is one more than the
// count of unique predecessors.
//
INVORD[IORDER[I]] = (NUPRED + 1);
} else {
//
// DARRAY( IORDER(I) ) is a duplicate. Its position in the
// sorted, compressed array derived from DARRAY is the same
// as that of DARRAY( IORDER(I-1) ).
//
INVORD[IORDER[I]] = INVORD[IORDER[(I - 1)]];
}
}
//
// INVORD has been updated so that its elements belong to the
// set { 1 : NUPRED+1 }.
//
// Set the maximum range value of INVORD.
//
*RNGMAX = (NUPRED + 1);
}