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 |
3920
|
12 @deftypefn Constructor {} Array<T> (void) |
2333
|
13 Create an array with no elements. |
|
14 @end deftypefn |
|
15 |
3920
|
16 @deftypefn Constructor {} Array<T> (int @var{n} [, const T &@var{val}]) |
2333
|
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 |
3920
|
23 @deftypefn Constructor {} Array<T> (const Array<T> &@var{a}) |
2333
|
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 |
3920
|
29 @deftypeop Assignment Array<T> Array<T>& {operator =} (const Array<T> &@var{a}) |
2333
|
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. |
3920
|
33 @end deftypeop |
2333
|
34 |
3920
|
35 @deftypemethod Array<T> int capacity (void) const |
|
36 @deftypemethodx Array<T> int length (void) const |
2333
|
37 Return the length of the array. |
3920
|
38 @end deftypemethod |
2333
|
39 |
3920
|
40 @deftypemethod Array<T> T& elem (int @var{n}) |
|
41 @deftypemethodx Array<T> T& checkelem (int @var{n}) |
2333
|
42 If @var{n} is within the bounds of the array, return a reference to the |
|
43 element indexed by @var{n}; otherwise, the current error handler is |
|
44 invoked (@pxref{Error Handling}). |
3920
|
45 @end deftypemethod |
2333
|
46 |
3920
|
47 @deftypeop Indexing Array<T> T& {operator ()} (int @var{n}) |
|
48 @end deftypeop |
|
49 |
|
50 @deftypemethod Array<T> T elem (int @var{n}) const |
|
51 @deftypemethodx Array<T> T checkelem (int @var{n}) const |
2333
|
52 If @var{n} is within the bounds of the array, return the value indexed |
|
53 by @var{n}; otherwise, call the current error handler. |
|
54 @xref{Error Handling}. |
3920
|
55 @end deftypemethod |
2333
|
56 |
3920
|
57 @deftypeop Indexing Array<T> T {operator ()} (int @var{n}) const |
|
58 @end deftypeop |
|
59 |
|
60 @deftypemethod Array<T> T& xelem (int @var{n}) |
|
61 @deftypemethodx Array<T> T xelem (int @var{n}) const |
2333
|
62 Return a reference to, or the value of, the element indexed by @var{n}. |
|
63 These methods never perform bounds checking. |
3920
|
64 @end deftypemethod |
2333
|
65 |
3920
|
66 @deftypemethod Array<T> void resize {(int @var{n} [, const T &@var{val}])} |
2333
|
67 Change the size of the array to be @var{n} elements. All elements are |
|
68 unchanged, except that if @var{n} is greater than the current size and |
|
69 the optional argument @var{val} is provided, the additional elements are |
|
70 initialized to @var{val}; otherwise, any additional elements are left |
|
71 uninitialized. In the current implementation, if @var{n} is less than |
|
72 the current size, the length is updated but no memory is released. |
3920
|
73 @end deftypemethod |
2333
|
74 |
3920
|
75 @deftypemethod Array<T> {const T*} data (void) const |
|
76 @end deftypemethod |
2333
|
77 |
|
78 @c Should this be public? |
|
79 @c |
|
80 @c T *fortran_vec (void) |
|
81 |
3920
|
82 @deftypefn Constructor {} Array2<T> Array2<T> Array2 (void) |
|
83 @deftypefnx Constructor {} Array2<T> (int @var{n}, int @var{m}) |
|
84 @deftypefnx Constructor {} Array2<T> (int @var{n}, int @var{m}, const T &@var{val}) |
|
85 @deftypefnx Constructor {} Array2<T> (const Array2<T> &@var{a}) |
|
86 @deftypefnx Constructor {} Array2<T> (const DiagArray<T> &@var{a}) |
2333
|
87 @end deftypefn |
|
88 |
3920
|
89 @deftypeop Assignment Array2<T> Array2<T>& {operator =} (const Array2<T> &@var{a}) |
|
90 @end deftypeop |
|
91 |
|
92 @deftypemethod Array2<T> int dim1 (void) const |
|
93 @deftypemethodx Array2<T> int rows (void) const |
|
94 @end deftypemethod |
2333
|
95 |
3920
|
96 @deftypemethod Array2<T> int dim2 (void) const |
|
97 @deftypemethodx Array2<T> int cols (void) const |
|
98 @deftypemethodx Array2<T> int columns (void) const |
|
99 @end deftypemethod |
2333
|
100 |
3920
|
101 @deftypemethod Array2<T> T& elem (int @var{i}, int @var{j}) |
|
102 @deftypemethodx Array2<T> T& checkelem (int @var{i}, int @var{j}) |
|
103 @end deftypemethod |
|
104 |
|
105 @deftypeop Indexing Array2<T> T& {operator ()} (int @var{i}, int @var{j}) |
|
106 @end deftypeop |
2333
|
107 |
|
108 @c This needs to be fixed. |
|
109 @c |
|
110 @c T& xelem (int i, int j) |
|
111 @c |
|
112 @c T elem (int i, int j) const |
|
113 @c T checkelem (int i, int j) const |
|
114 @c T operator () (int i, int j) const |
|
115 |
3920
|
116 @deftypemethod Array2<T> void resize (int @var{n}, int @var{m}) |
|
117 @deftypemethodx Array2<T> void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
118 @end deftypemethod |
2333
|
119 |
3920
|
120 @deftypefn Constructor {} Array3<T> (void) |
|
121 @deftypefnx Constructor {} Array3<T> (int @var{n}, int @var{m}, int @var{k}) |
|
122 @deftypefnx Constructor {} Array3<T> (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
123 @deftypefnx Constructor {} Array3<T> (const Array3<T> &@var{a}) |
2333
|
124 @end deftypefn |
|
125 |
3920
|
126 @deftypeop Assignment Array3<T> Array3<T>& {operator =} (const Array3<T> &@var{a}) |
|
127 @end deftypeop |
2333
|
128 |
3920
|
129 @deftypemethod Array3<T> int dim1 (void) const |
|
130 @deftypemethodx Array3<T> int dim2 (void) const |
|
131 @deftypemethodx Array3<T> int dim3 (void) const |
|
132 @end deftypemethod |
2333
|
133 |
3920
|
134 @deftypemethod Array3<T> T& elem (int @var{i}, int @var{j}, int @var{k}) |
|
135 @deftypemethodx Array3<T> T& checkelem (int @var{i}, int @var{j}, int @var{k}) |
|
136 @end deftypemethod |
|
137 |
|
138 @deftypeop Indexing Array3<T> T& {operator ()} (int @var{i}, int @var{j}, int @var{k}) |
|
139 @end deftypeop |
2333
|
140 |
|
141 @c This needs to be fixed. |
|
142 @c |
|
143 @c T& xelem (int i, int j, int k) |
|
144 @c |
|
145 @c T elem (int i, int j, int k) const |
|
146 @c T checkelem (int i, int j, int k) const |
|
147 @c T operator () (int i, int j, int k) const |
|
148 |
3920
|
149 @deftypemethod Array3<T> void resize (int @var{n}, int @var{m}, int @var{k}) |
|
150 @deftypemethodx Array3<T> void resize (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
151 @end deftypemethod |
2333
|
152 |
3920
|
153 @deftypefn Constructor {} DiagArray<T> (void) |
|
154 @deftypefnx Constructor {} DiagArray<T> (int @var{n}) |
|
155 @deftypefnx Constructor {} DiagArray<T> (int @var{n}, const T &@var{val}) |
|
156 @deftypefnx Constructor {} DiagArray<T> (int @var{r}, int @var{c}) |
|
157 @deftypefnx Constructor {} DiagArray<T> (int @var{r}, int @var{c}, const T &@var{val}) |
|
158 @deftypefnx Constructor {} DiagArray<T> (const Array<T> &@var{a}) |
|
159 @deftypefnx Constructor {} DiagArray<T> (const DiagArray<T> &@var{a}) |
2333
|
160 @end deftypefn |
|
161 |
3920
|
162 @deftypeop {Assginment} DiagArray<T>& {operator =} (const DiagArray<T> &@var{a}) |
|
163 @end deftypeop |
2333
|
164 |
3920
|
165 @deftypemethod DiagArray<T> int dim1 (void) const |
|
166 @deftypemethodx DiagArray<T> int rows (void) const |
|
167 @end deftypemethod |
2333
|
168 |
3920
|
169 @deftypemethod DiagArray<T> int dim2 (void) const |
|
170 @deftypemethodx DiagArray<T> int cols (void) const |
|
171 @deftypemethodx DiagArray<T> int columns (void) const |
|
172 @end deftypemethod |
2333
|
173 |
3920
|
174 @deftypemethod DiagArray<T> T& elem (int @var{r}, int @var{c}) |
|
175 @deftypemethodx DiagArray<T> T& checkelem (int @var{r}, int @var{c}) |
|
176 @end deftypemethod |
|
177 |
|
178 @deftypeop Indexing DiagArray<T> T& {operator ()} (int @var{r}, int @var{c}) |
|
179 @end deftypeop |
2333
|
180 |
|
181 @c This needs to be fixed. |
|
182 @c |
|
183 @c T& xelem (int r, int c) |
|
184 @c |
|
185 @c T elem (int r, int c) const |
|
186 @c T checkelem (int r, int c) const |
|
187 @c T operator () (int r, int c) const |
|
188 |
3920
|
189 @deftypemethod DiagArray<T> void resize (int @var{n}, int @var{m}) |
|
190 @deftypemethodx DiagArray<T> void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
191 @end deftypemethod |