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
|
# DP_RECTIFY -- Shuffle a real vector based upon an input index vector using
# dynamic memory.
procedure dp_rectify (x, index, nitem)
real x[ARB]
int index[ARB]
int nitem
pointer sp, hold
begin
call smark (sp)
call salloc (hold, nitem, TY_REAL)
call dp_dorect (x, Memr[hold], index, nitem)
call sfree (sp)
end
# DP_IRECTIFY -- Shuffle an integer vector based upon an input index vector
# using dynamic memory.
procedure dp_irectify (x, index, nitem)
int x[ARB]
int index[ARB]
int nitem
pointer sp, hold
begin
call smark (sp)
call salloc (hold, nitem, TY_INT)
call dp_idorect (x, Memi[hold], index, nitem)
call sfree (sp)
end
# DP_DORECT -- Shuffle a vector based upon an input index vector using
# a preallocated dummy array.
procedure dp_dorect (x, hold, index, nitem)
real x[ARB]
real hold[ARB]
int index[ARB]
int nitem
int i
begin
call amovr (x, hold, nitem)
do i = 1, nitem
x[i] = hold[index[i]]
end
# DP_IDORECT -- Shuffle an integer vector based upon an input index vector
# using a preallocated dummy array.
procedure dp_idorect (x, hold, index, nitem)
int x[ARB]
int hold[ARB]
int index[ARB]
int nitem
int i
begin
call amovi (x, hold, nitem)
do i = 1, nitem
x[i] = hold[index[i]]
end
|