7018
|
1 @c Copyright (C) 1996, 1998, 2002, 2006, 2007 John W. Eaton |
|
2 @c |
|
3 @c This file is part of Octave. |
|
4 @c |
|
5 @c Octave is free software; you can redistribute it and/or modify it |
|
6 @c under the terms of the GNU General Public License as published by the |
|
7 @c Free Software Foundation; either version 3 of the License, or (at |
|
8 @c your option) any later version. |
|
9 @c |
|
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 @c for more details. |
|
14 @c |
|
15 @c You should have received a copy of the GNU General Public License |
|
16 @c along with Octave; see the file COPYING. If not, see |
|
17 @c <http://www.gnu.org/licenses/>. |
|
18 |
3178
|
19 @node Arrays, Matrix and Vector Operations, Introduction, Top |
2333
|
20 @chapter Arrays |
|
21 @cindex arrays |
|
22 |
|
23 @menu |
|
24 * Constructors and Assignment:: |
|
25 @end menu |
|
26 |
|
27 @node Constructors and Assignment, , Arrays, Arrays |
|
28 @section Constructors and Assignment |
|
29 |
3920
|
30 @deftypefn Constructor {} Array<T> (void) |
2333
|
31 Create an array with no elements. |
|
32 @end deftypefn |
|
33 |
3920
|
34 @deftypefn Constructor {} Array<T> (int @var{n} [, const T &@var{val}]) |
2333
|
35 Create an array with @var{n} elements. If the optional argument |
|
36 @var{val} is supplied, the elements are initialized to @var{val}; |
|
37 otherwise, they are left uninitialized. If @var{n} is less than zero, |
|
38 the current error handler is invoked (@pxref{Error Handling}). |
|
39 @end deftypefn |
|
40 |
3920
|
41 @deftypefn Constructor {} Array<T> (const Array<T> &@var{a}) |
2333
|
42 Create a copy of the @var{Array<T>} object @var{a}. Memory for the |
|
43 @var{Array<T>} class is managed using a reference counting scheme, so |
|
44 the cost of this operation is independent of the size of the array. |
|
45 @end deftypefn |
|
46 |
3920
|
47 @deftypeop Assignment Array<T> Array<T>& {operator =} (const Array<T> &@var{a}) |
2333
|
48 Assignment operator. Memory for the @var{Array<T>} class is managed |
|
49 using a reference counting scheme, so the cost of this operation is |
|
50 independent of the size of the array. |
3920
|
51 @end deftypeop |
2333
|
52 |
3920
|
53 @deftypemethod Array<T> int capacity (void) const |
|
54 @deftypemethodx Array<T> int length (void) const |
2333
|
55 Return the length of the array. |
3920
|
56 @end deftypemethod |
2333
|
57 |
3920
|
58 @deftypemethod Array<T> T& elem (int @var{n}) |
|
59 @deftypemethodx Array<T> T& checkelem (int @var{n}) |
2333
|
60 If @var{n} is within the bounds of the array, return a reference to the |
|
61 element indexed by @var{n}; otherwise, the current error handler is |
|
62 invoked (@pxref{Error Handling}). |
3920
|
63 @end deftypemethod |
2333
|
64 |
3920
|
65 @deftypeop Indexing Array<T> T& {operator ()} (int @var{n}) |
|
66 @end deftypeop |
|
67 |
|
68 @deftypemethod Array<T> T elem (int @var{n}) const |
|
69 @deftypemethodx Array<T> T checkelem (int @var{n}) const |
2333
|
70 If @var{n} is within the bounds of the array, return the value indexed |
|
71 by @var{n}; otherwise, call the current error handler. |
|
72 @xref{Error Handling}. |
3920
|
73 @end deftypemethod |
2333
|
74 |
3920
|
75 @deftypeop Indexing Array<T> T {operator ()} (int @var{n}) const |
|
76 @end deftypeop |
|
77 |
|
78 @deftypemethod Array<T> T& xelem (int @var{n}) |
|
79 @deftypemethodx Array<T> T xelem (int @var{n}) const |
2333
|
80 Return a reference to, or the value of, the element indexed by @var{n}. |
|
81 These methods never perform bounds checking. |
3920
|
82 @end deftypemethod |
2333
|
83 |
3920
|
84 @deftypemethod Array<T> void resize {(int @var{n} [, const T &@var{val}])} |
2333
|
85 Change the size of the array to be @var{n} elements. All elements are |
|
86 unchanged, except that if @var{n} is greater than the current size and |
|
87 the optional argument @var{val} is provided, the additional elements are |
|
88 initialized to @var{val}; otherwise, any additional elements are left |
|
89 uninitialized. In the current implementation, if @var{n} is less than |
|
90 the current size, the length is updated but no memory is released. |
3920
|
91 @end deftypemethod |
2333
|
92 |
3920
|
93 @deftypemethod Array<T> {const T*} data (void) const |
|
94 @end deftypemethod |
2333
|
95 |
|
96 @c Should this be public? |
|
97 @c |
|
98 @c T *fortran_vec (void) |
|
99 |
3920
|
100 @deftypefn Constructor {} Array2<T> Array2<T> Array2 (void) |
|
101 @deftypefnx Constructor {} Array2<T> (int @var{n}, int @var{m}) |
|
102 @deftypefnx Constructor {} Array2<T> (int @var{n}, int @var{m}, const T &@var{val}) |
|
103 @deftypefnx Constructor {} Array2<T> (const Array2<T> &@var{a}) |
|
104 @deftypefnx Constructor {} Array2<T> (const DiagArray<T> &@var{a}) |
2333
|
105 @end deftypefn |
|
106 |
3920
|
107 @deftypeop Assignment Array2<T> Array2<T>& {operator =} (const Array2<T> &@var{a}) |
|
108 @end deftypeop |
|
109 |
|
110 @deftypemethod Array2<T> int dim1 (void) const |
|
111 @deftypemethodx Array2<T> int rows (void) const |
|
112 @end deftypemethod |
2333
|
113 |
3920
|
114 @deftypemethod Array2<T> int dim2 (void) const |
|
115 @deftypemethodx Array2<T> int cols (void) const |
|
116 @deftypemethodx Array2<T> int columns (void) const |
|
117 @end deftypemethod |
2333
|
118 |
3920
|
119 @deftypemethod Array2<T> T& elem (int @var{i}, int @var{j}) |
|
120 @deftypemethodx Array2<T> T& checkelem (int @var{i}, int @var{j}) |
|
121 @end deftypemethod |
|
122 |
|
123 @deftypeop Indexing Array2<T> T& {operator ()} (int @var{i}, int @var{j}) |
|
124 @end deftypeop |
2333
|
125 |
|
126 @c This needs to be fixed. |
|
127 @c |
|
128 @c T& xelem (int i, int j) |
|
129 @c |
|
130 @c T elem (int i, int j) const |
|
131 @c T checkelem (int i, int j) const |
|
132 @c T operator () (int i, int j) const |
|
133 |
3920
|
134 @deftypemethod Array2<T> void resize (int @var{n}, int @var{m}) |
|
135 @deftypemethodx Array2<T> void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
136 @end deftypemethod |
2333
|
137 |
3920
|
138 @deftypefn Constructor {} Array3<T> (void) |
|
139 @deftypefnx Constructor {} Array3<T> (int @var{n}, int @var{m}, int @var{k}) |
|
140 @deftypefnx Constructor {} Array3<T> (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
141 @deftypefnx Constructor {} Array3<T> (const Array3<T> &@var{a}) |
2333
|
142 @end deftypefn |
|
143 |
3920
|
144 @deftypeop Assignment Array3<T> Array3<T>& {operator =} (const Array3<T> &@var{a}) |
|
145 @end deftypeop |
2333
|
146 |
3920
|
147 @deftypemethod Array3<T> int dim1 (void) const |
|
148 @deftypemethodx Array3<T> int dim2 (void) const |
|
149 @deftypemethodx Array3<T> int dim3 (void) const |
|
150 @end deftypemethod |
2333
|
151 |
3920
|
152 @deftypemethod Array3<T> T& elem (int @var{i}, int @var{j}, int @var{k}) |
|
153 @deftypemethodx Array3<T> T& checkelem (int @var{i}, int @var{j}, int @var{k}) |
|
154 @end deftypemethod |
|
155 |
|
156 @deftypeop Indexing Array3<T> T& {operator ()} (int @var{i}, int @var{j}, int @var{k}) |
|
157 @end deftypeop |
2333
|
158 |
|
159 @c This needs to be fixed. |
|
160 @c |
|
161 @c T& xelem (int i, int j, int k) |
|
162 @c |
|
163 @c T elem (int i, int j, int k) const |
|
164 @c T checkelem (int i, int j, int k) const |
|
165 @c T operator () (int i, int j, int k) const |
|
166 |
3920
|
167 @deftypemethod Array3<T> void resize (int @var{n}, int @var{m}, int @var{k}) |
|
168 @deftypemethodx Array3<T> void resize (int @var{n}, int @var{m}, int @var{k}, const T &@var{val}) |
|
169 @end deftypemethod |
2333
|
170 |
3920
|
171 @deftypefn Constructor {} DiagArray<T> (void) |
|
172 @deftypefnx Constructor {} DiagArray<T> (int @var{n}) |
|
173 @deftypefnx Constructor {} DiagArray<T> (int @var{n}, const T &@var{val}) |
|
174 @deftypefnx Constructor {} DiagArray<T> (int @var{r}, int @var{c}) |
|
175 @deftypefnx Constructor {} DiagArray<T> (int @var{r}, int @var{c}, const T &@var{val}) |
|
176 @deftypefnx Constructor {} DiagArray<T> (const Array<T> &@var{a}) |
|
177 @deftypefnx Constructor {} DiagArray<T> (const DiagArray<T> &@var{a}) |
2333
|
178 @end deftypefn |
|
179 |
5647
|
180 @deftypeop Assginment DiagArray<T>& {} {operator =} (const DiagArray<T> &@var{a}) |
3920
|
181 @end deftypeop |
2333
|
182 |
3920
|
183 @deftypemethod DiagArray<T> int dim1 (void) const |
|
184 @deftypemethodx DiagArray<T> int rows (void) const |
|
185 @end deftypemethod |
2333
|
186 |
3920
|
187 @deftypemethod DiagArray<T> int dim2 (void) const |
|
188 @deftypemethodx DiagArray<T> int cols (void) const |
|
189 @deftypemethodx DiagArray<T> int columns (void) const |
|
190 @end deftypemethod |
2333
|
191 |
3920
|
192 @deftypemethod DiagArray<T> T& elem (int @var{r}, int @var{c}) |
|
193 @deftypemethodx DiagArray<T> T& checkelem (int @var{r}, int @var{c}) |
|
194 @end deftypemethod |
|
195 |
|
196 @deftypeop Indexing DiagArray<T> T& {operator ()} (int @var{r}, int @var{c}) |
|
197 @end deftypeop |
2333
|
198 |
|
199 @c This needs to be fixed. |
|
200 @c |
|
201 @c T& xelem (int r, int c) |
|
202 @c |
|
203 @c T elem (int r, int c) const |
|
204 @c T checkelem (int r, int c) const |
|
205 @c T operator () (int r, int c) const |
|
206 |
3920
|
207 @deftypemethod DiagArray<T> void resize (int @var{n}, int @var{m}) |
|
208 @deftypemethodx DiagArray<T> void resize (int @var{n}, int @var{m}, const T &@var{val}) |
|
209 @end deftypemethod |