3178
|
1 @node Arrays, Matrix and Vector Operations, Introduction, Top |
2333
|
2 @chapter Arrays |
|
3 @cindex arrays |
|
4 |
|
5 @menu |
|
6 * Constructors and Assignment:: |
|
7 @end menu |
|
8 |
|
9 @node Constructors and Assignment, , Arrays, Arrays |
|
10 @section Constructors and Assignment |
|
11 |
|
12 @deftypefn Constructor {} Array<T>::Array (void) |
|
13 Create an array with no elements. |
|
14 @end deftypefn |
|
15 |
|
16 @deftypefn Constructor {} Array<T>::Array (int @var{n} [, const T &@var{val}]) |
|
17 Create an array with @var{n} elements. If the optional argument |
|
18 @var{val} is supplied, the elements are initialized to @var{val}; |
|
19 otherwise, they are left uninitialized. If @var{n} is less than zero, |
|
20 the current error handler is invoked (@pxref{Error Handling}). |
|
21 @end deftypefn |
|
22 |
|
23 @deftypefn Constructor {} Array<T>::Array (const Array<T> &@var{a}) |
|
24 Create a copy of the @var{Array<T>} object @var{a}. Memory for the |
|
25 @var{Array<T>} class is managed using a reference counting scheme, so |
|
26 the cost of this operation is independent of the size of the array. |
|
27 @end deftypefn |
|
28 |
|
29 @deftypefn Operator Array<T>& {Array<T>::operator =} (const Array<T> &@var{a}) |
|
30 Assignment operator. Memory for the @var{Array<T>} class is managed |
|
31 using a reference counting scheme, so the cost of this operation is |
|
32 independent of the size of the array. |
|
33 @end deftypefn |
|
34 |
|
35 @deftypefn Method int Array<T>::capacity (void) const |
|
36 @deftypefnx Method int Array<T>::length (void) const |
|
37 Return the length of the array. |
|
38 @end deftypefn |
|
39 |
|
40 @deftypefn Method T& Array<T>::elem (int @var{n}) |
|
41 @deftypefnx Method T& Array<T>::checkelem (int @var{n}) |
|
42 @deftypefnx Method T& {Array<T>::operator ()} (int @var{n}) |
|
43 If @var{n} is within the bounds of the array, return a reference to the |
|
44 element indexed by @var{n}; otherwise, the current error handler is |
|
45 invoked (@pxref{Error Handling}). |
|
46 @end deftypefn |
|
47 |
|
48 @deftypefn Method T Array<T>::elem (int @var{n}) const |
|
49 @deftypefnx Method T Array<T>::checkelem (int @var{n}) const |
|
50 @deftypefnx Method T Array<T>::operator () (int @var{n}) const |
|
51 If @var{n} is within the bounds of the array, return the value indexed |
|
52 by @var{n}; otherwise, call the current error handler. |
|
53 @xref{Error Handling}. |
|
54 @end deftypefn |
|
55 |
|
56 @deftypefn Method T& Array<T>::xelem (int @var{n}) |
|
57 @deftypefnx Method T Array<T>::xelem (int @var{n}) const |
|
58 Return a reference to, or the value of, the element indexed by @var{n}. |
|
59 These methods never perform bounds checking. |
|
60 @end deftypefn |
|
61 |
|
62 @deftypefn Method void Array<T>::resize (int @var{n} [, const T &@var{val}]) |
|
63 Change the size of the array to be @var{n} elements. All elements are |
|
64 unchanged, except that if @var{n} is greater than the current size and |
|
65 the optional argument @var{val} is provided, the additional elements are |
|
66 initialized to @var{val}; otherwise, any additional elements are left |
|
67 uninitialized. In the current implementation, if @var{n} is less than |
|
68 the current size, the length is updated but no memory is released. |
|
69 @end deftypefn |
|
70 |
|
71 @deftypefn Method {const T*} Array<T>::data (void) const |
|
72 @end deftypefn |
|
73 |
|
74 @c Should this be public? |
|
75 @c |
|
76 @c T *fortran_vec (void) |
|
77 |
|
78 @deftypefn {} {} Array2 (void) |
|
79 @deftypefnx {} {} Array2 (int @var{n}, int @var{m}) |
|
80 @deftypefnx {} {} Array2 (int @var{n}, int @var{m}, const T &@var{val}) |
|
81 @deftypefnx {} {} Array2 (const Array2<T> &@var{a}) |
|
82 @deftypefnx {} {} Array2 (const DiagArray<T> &@var{a}) |
|
83 @end deftypefn |
|
84 |
|
85 @deftypefn {} Array2<T>& {operator =} (const Array2<T> &@var{a}) |
|
86 @end deftypefn |
|
87 |
|
88 @deftypefn {} int dim1 (void) const |
|
89 @deftypefnx {} int rows (void) const |
|
90 @end deftypefn |
|
91 |
|
92 @deftypefn {} int dim2 (void) const |
|
93 @deftypefnx {} int cols (void) const |
|
94 @deftypefnx {} int columns (void) const |
|
95 @end deftypefn |
|
96 |
|
97 @deftypefn {} T& elem (int @var{i}, int @var{j}) |
|
98 @deftypefnx {} T& checkelem (int @var{i}, int @var{j}) |
|
99 @deftypefnx {} T& {operator ()} (int @var{i}, int @var{j}) |
|
100 @end deftypefn |
|
101 |
|
102 @c This needs to be fixed. |
|
103 @c |
|
104 @c T& xelem (int i, int j) |
|
105 @c |
|
106 @c T elem (int i, int j) const |
|
107 @c T checkelem (int i, int j) const |
|
108 @c T operator () (int i, int j) const |
|
109 |
|
110 @deftypefn {} void resize (int @var{n}, int @var{m}) |
|
111 @deftypefnx {} void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
112 @end deftypefn |
|
113 |
|
114 @deftypefn {} Array3 (void) |
|
115 @deftypefnx {} Array3 (int @var{n}, int @var{m}, int @var{k}) |
|
116 @deftypefnx {} Array3 (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
117 @deftypefnx {} Array3 (const Array3<T> &@var{a}) |
|
118 @end deftypefn |
|
119 |
|
120 @deftypefn {} Array3<T>& {operator =} (const Array3<T> &@var{a}) |
|
121 @end deftypefn |
|
122 |
|
123 @deftypefn {} int dim1 (void) const |
|
124 @deftypefnx {} int dim2 (void) const |
|
125 @deftypefnx {} int dim3 (void) const |
|
126 @end deftypefn |
|
127 |
|
128 @deftypefn {} T& elem (int @var{i}, int @var{j}, int @var{k}) |
|
129 @deftypefnx {} T& checkelem (int @var{i}, int @var{j}, int @var{k}) |
|
130 @deftypefnx {} T& {operator ()} (int @var{i}, int @var{j}, int @var{k}) |
|
131 @end deftypefn |
|
132 |
|
133 @c This needs to be fixed. |
|
134 @c |
|
135 @c T& xelem (int i, int j, int k) |
|
136 @c |
|
137 @c T elem (int i, int j, int k) const |
|
138 @c T checkelem (int i, int j, int k) const |
|
139 @c T operator () (int i, int j, int k) const |
|
140 |
|
141 @deftypefn {} void resize (int @var{n}, int @var{m}, int @var{k}) |
|
142 @deftypefnx {} void resize (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
143 @end deftypefn |
|
144 |
|
145 @deftypefn {} {}DiagArray (void) |
|
146 @deftypefnx {} {}DiagArray (int @var{n}) |
|
147 @deftypefnx {} {}DiagArray (int @var{n}, const T &@var{val}) |
|
148 @deftypefnx {} {}DiagArray (int @var{r}, int @var{c}) |
|
149 @deftypefnx {} {}DiagArray (int @var{r}, int @var{c}, const T &@var{val}) |
|
150 @deftypefnx {} {}DiagArray (const Array<T> &@var{a}) |
|
151 @deftypefnx {} {}DiagArray (const DiagArray<T> &@var{a}) |
|
152 @end deftypefn |
|
153 |
|
154 @deftypefn {} DiagArray<T>& {operator =} (const DiagArray<T> &@var{a}) |
|
155 @end deftypefn |
|
156 |
|
157 @deftypefn {} int dim1 (void) const |
|
158 @deftypefnx {} int rows (void) const |
|
159 @end deftypefn |
|
160 |
|
161 @deftypefn {} int dim2 (void) const |
|
162 @deftypefnx {} int cols (void) const |
|
163 @deftypefnx {} int columns (void) const |
|
164 @end deftypefn |
|
165 |
|
166 @deftypefn {} T& elem (int @var{r}, int @var{c}) |
|
167 @deftypefnx {} T& checkelem (int @var{r}, int @var{c}) |
|
168 @deftypefnx {} T& {operator ()} (int @var{r}, int @var{c}) |
|
169 @end deftypefn |
|
170 |
|
171 @c This needs to be fixed. |
|
172 @c |
|
173 @c T& xelem (int r, int c) |
|
174 @c |
|
175 @c T elem (int r, int c) const |
|
176 @c T checkelem (int r, int c) const |
|
177 @c T operator () (int r, int c) const |
|
178 |
|
179 @deftypefn {} void resize (int @var{n}, int @var{m}) |
|
180 @deftypefnx {} void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
181 @end deftypefn |