1
2\function{rearrange}
3\synopsis{Rearrange the elements of a 1-d array or list.}
4\usage{rearrange (A, indices)}
5\description
6  This function performs an in-place rearrangment of the the elements
7  of an array according to the specified permutation, represented by
8  the \exmp{indices} argument.  The \exmp{indices} array is assumed to
9  contain unique integers in the range \exmp{[0,length(A)-1]}.
10\notes
11  The function modifies the elements of the \exmp{indices} array while
12  it performs the rearrangement.  The values will get restored upon
13  return from function.
14
15  The algorithm used was derived from the DPPERM function, which is
16  part of the SLATEC package.  See
17  \url{http://gams.nist.gov/cgi-bin/serve.cgi/Package/SLATEC}.
18\seealso{array_reverse, array_swap}
19\done
20
21\function{reverse}
22\synopsis{Reverse the elements of a 1-d array}
23\usage{Array_Type reverse (Array_Type A)}
24\description
25 The \sfun{reverse} function reverses the elements of a 1-d array and
26 returns the result.
27\seealso{shift}
28\done
29
30\function{shift}
31\synopsis{Shift the elements of a 1-d array}
32\usage{Array_Type shift (Array_Type A, Int_Type n)}
33\description
34 The \sfun{shift} function shifts the elements of an array by a specified amount
35 and returns the result.  If \exmp{n} is positive, the ith element of the array
36 will be shifted to the position \exmp{i-n} of the array.  Elements for
37 which \exmp{i-n} is less than 0 will be moved to the end of the array.
38\example
39#v+
40   A = [1,2,3,4,5,6,7,8,9];
41   B = shift (A, 3);          % ==> B = [4,5,6,7,8,9,1,2,3];
42   C = shift (A, -1);         % ==> C = [9,1,2,3,4,5,6,7,8];
43#v-
44\notes
45 It many ways \exmp{rotate} would be a better name for this function.
46\seealso{reverse, transpose}
47\done
48