Mercurial > octave
annotate liboctave/array/dim-vector.h @ 22213:1723063e65f3
dim-vector: add missing, and remove unecessary, #includes.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sat, 06 Aug 2016 05:18:34 +0100 |
parents | 2b487dbe419d |
children | 8a50ab960ae6 |
rev | line source |
---|---|
4513 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19326
diff
changeset
|
3 Copyright (C) 2003-2015 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10498
diff
changeset
|
4 Copyirght (C) 2009, 2010 VZLU Prague |
4513 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
4513 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
4513 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20236
diff
changeset
|
24 #if ! defined (octave_dim_vector_h) |
4513 | 25 #define octave_dim_vector_h 1 |
26 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
28 |
4513 | 29 #include <cassert> |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
30 |
4543 | 31 #include <string> |
32 | |
6216 | 33 #include "lo-error.h" |
10419
afe44ee90cbd
implement generic macro magic for repeated decls
Jaroslav Hajek <highegg@gmail.com>
parents:
10418
diff
changeset
|
34 #include "lo-macros.h" |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
35 #include "oct-refcount.h" |
4513 | 36 |
20236
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
37 //! Vector representing the dimensions (size) of an Array. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
38 /*! |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
39 A dim_vector is used to represent dimensions of an Array. It is used |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
40 on its constructor to specify its size, or when reshaping it. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
41 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
42 @code{.cc} |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
43 // Matrix with 10 rows and 20 columns. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
44 Matrix m Matrix (dim_vector (10, 20)); |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
45 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
46 // Change its size to 5 rows and 40 columns. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
47 Matrix m2 = m.reshape (dim_vector (5, 40)); |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
48 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
49 // Five dimensional Array of length 10, 20, 3, 8, 7 on each dimension. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
50 NDArray a (dim_vector (10, 20, 3, 8, 7)); |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
51 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
52 // Uninitialized array of same size as other. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
53 NDArray b (a.dims ()); |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
54 @endcode |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
55 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
56 The main thing to understand about this class, is that methods such as |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
57 ndims() and numel(), return the value for an Array of these dimensions, |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
58 not the actual number of elements in the dim_vector. |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
59 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
60 @code{.cc} |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
61 dim_vector d (10, 5, 3); |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
62 octave_idx_type n = d.numel (); // returns 150 |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
63 octave_idx_type nd = d.ndims (); // returns 3 |
20236
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
64 @endcode |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
65 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
66 ## Implementation details ## |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
67 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
68 This implementation is more tricky than Array, but the big plus is that |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
69 dim_vector requires only one allocation instead of two. It is (slightly) |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
70 patterned after GCC's basic_string implementation. rep is a pointer to an |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
71 array of memory, comprising count, length, and the data: |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
72 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
73 @verbatim |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
74 <count> |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
75 <ndims> |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
76 rep --> <dims[0]> |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
77 <dims[1]> |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
78 ... |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
79 @endverbatim |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
80 |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
81 The inlines count(), ndims() recover this data from the rep. Note |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
82 that rep points to the beginning of dims to grant faster access |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
83 (reinterpret_cast is assumed to be an inexpensive operation). |
a3bf35bd5b44
doc: doxygen documentation for dim_vector header.
Carnë Draug <carandraug@octave.org>
parents:
20230
diff
changeset
|
84 */ |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
85 |
4513 | 86 class |
11173
298a75c128ad
Additional exported symbols [MSVC]
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10830
diff
changeset
|
87 OCTAVE_API |
4513 | 88 dim_vector |
89 { | |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
90 private: |
4513 | 91 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
92 octave_idx_type *rep; |
4548 | 93 |
10150 | 94 octave_idx_type& count (void) const { return rep[-2]; } |
4513 | 95 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
96 //! Construct a new rep with count = 1 and ndims given. |
10150 | 97 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
98 static octave_idx_type *newrep (int ndims) |
10150 | 99 { |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
14951
diff
changeset
|
100 octave_idx_type *r = new octave_idx_type [ndims + 2]; |
10150 | 101 |
102 *r++ = 1; | |
103 *r++ = ndims; | |
4513 | 104 |
10150 | 105 return r; |
106 } | |
107 | |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
108 //! Clone this->rep. |
10150 | 109 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
110 octave_idx_type *clonerep (void) |
10150 | 111 { |
112 int l = ndims (); | |
113 | |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
14951
diff
changeset
|
114 octave_idx_type *r = new octave_idx_type [l + 2]; |
10150 | 115 |
116 *r++ = 1; | |
117 *r++ = l; | |
4513 | 118 |
10150 | 119 for (int i = 0; i < l; i++) |
120 r[i] = rep[i]; | |
121 | |
122 return r; | |
123 } | |
124 | |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
125 //! Clone and resize this->rep to length n, filling by given value. |
10150 | 126 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
127 octave_idx_type *resizerep (int n, octave_idx_type fill_value) |
10150 | 128 { |
129 int l = ndims (); | |
130 | |
131 if (n < 2) | |
132 n = 2; | |
133 | |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
14951
diff
changeset
|
134 octave_idx_type *r = new octave_idx_type [n + 2]; |
10150 | 135 |
136 *r++ = 1; | |
137 *r++ = n; | |
138 | |
139 if (l > n) | |
140 l = n; | |
4673 | 141 |
10150 | 142 int j; |
143 for (j = 0; j < l; j++) | |
144 r[j] = rep[j]; | |
145 for (; j < n; j++) | |
146 r[j] = fill_value; | |
147 | |
148 return r; | |
149 } | |
150 | |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
151 //! Free the rep. |
10150 | 152 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
153 void freerep (void) |
10150 | 154 { |
155 assert (count () == 0); | |
156 delete [] (rep - 2); | |
157 } | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
158 |
4548 | 159 void make_unique (void) |
160 { | |
10150 | 161 if (count () > 1) |
4548 | 162 { |
14445 | 163 octave_idx_type *new_rep = clonerep (); |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
164 |
14445 | 165 if (OCTREFCOUNT_ATOMIC_DECREMENT(&(count())) == 0) |
166 freerep (); | |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
167 |
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
168 rep = new_rep; |
4548 | 169 } |
170 } | |
171 | |
172 public: | |
173 | |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
174 //! Construct dim_vector for a N dimensional array. |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
175 /*! |
10419
afe44ee90cbd
implement generic macro magic for repeated decls
Jaroslav Hajek <highegg@gmail.com>
parents:
10418
diff
changeset
|
176 |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
177 Each argument to constructor defines the length of an additional |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
178 dimension. A dim_vector always represents a minimum of 2 dimensions |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
179 (just like an Array has at least 2 dimensions) and there is no |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
180 upper limit on the number of dimensions. |
20208
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
181 |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
182 @code{.cc} |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
183 dim_vector dv (7, 5); |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
184 Matrix mat (dv); |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
185 @endcode |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
186 |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
187 The constructed dim_vector @c dv will have two elements, @f$[7, 5]@f$, |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
188 one for each dimension. It can then be used to construct a Matrix |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
189 with such dimensions, i.e., 7 rows and 5 columns. |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
190 |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
191 @code{.cc} |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
192 NDArray x (dim_vector (7, 5, 10)); |
20208
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
193 @endcode |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
194 |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
195 This will construct a 3 dimensional NDArray of lengths 7, 5, and 10, |
20208
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
196 on the first, second, and third dimension (rows, columns, and pages) |
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
197 respectively. |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
198 |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
199 Note that that there is no constructor that accepts only one |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
200 dimension length to avoid confusion. The source for such confusion |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
201 is that constructor could mean: |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
202 - a column vector, i.e., assume @f$[N, 1]@f$; |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
203 - a square matrix, i.e., as is common in Octave interpreter; |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
204 - support for a 1 dimensional Array (does not exist); |
20208
f638a61af5a8
doxygen: improve dim_vector constructor documentation (bug #45105)
Piotr Held <pjheld@gmail.com>
parents:
19861
diff
changeset
|
205 */ |
22059
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
206 template <typename... Ints> |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
207 dim_vector (const octave_idx_type r, const octave_idx_type c, |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
208 Ints... lengths) : rep (newrep (2 + sizeof... (Ints))) |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
209 { |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
210 // Using r, c, and lengths, makes sure that there's always a min of |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
211 // 2 dimensions specified, and that lengths are ints (since otherwise |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
212 // they can't form a list. |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
213 for (const auto l: {r, c, lengths...}) |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
214 *rep++ = l; |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
215 rep -= (2 + sizeof... (Ints)); |
b1256fb38777
dim_vector: replace 7 constructors with single variadic template (patch #9030).
Carnë Draug <carandraug@octave.org>
parents:
22022
diff
changeset
|
216 } |
10419
afe44ee90cbd
implement generic macro magic for repeated decls
Jaroslav Hajek <highegg@gmail.com>
parents:
10418
diff
changeset
|
217 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
218 octave_idx_type& elem (int i) |
10150 | 219 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
220 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK) |
10150 | 221 assert (i >= 0 && i < ndims ()); |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
222 #endif |
10150 | 223 make_unique (); |
224 return rep[i]; | |
225 } | |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
226 |
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
227 octave_idx_type elem (int i) const |
10150 | 228 { |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
229 #if defined (OCTAVE_ENABLE_BOUNDS_CHECK) |
10150 | 230 assert (i >= 0 && i < ndims ()); |
10366
e5ae13b8b2c2
improve Array indexing error messages
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
231 #endif |
10150 | 232 return rep[i]; |
233 } | |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
234 |
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
235 void chop_trailing_singletons (void) |
10150 | 236 { |
237 int l = ndims (); | |
238 if (l > 2 && rep[l-1] == 1) | |
239 { | |
240 make_unique (); | |
241 do | |
242 l--; | |
243 while (l > 2 && rep[l-1] == 1); | |
22212
2b487dbe419d
dim-vector.h (ndims): do not return a reference to the rep.
Carnë Draug <carandraug@octave.org>
parents:
22059
diff
changeset
|
244 rep[-1] = l; |
10150 | 245 } |
246 } | |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
247 |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
248 void chop_all_singletons (void); |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
249 |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
250 // WARNING: Only call by jit |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
251 octave_idx_type *to_jit (void) const |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
252 { |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
253 return rep; |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
254 } |
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
255 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
256 private: |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
257 |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20208
diff
changeset
|
258 static octave_idx_type *nil_rep (void); |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
259 |
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
260 public: |
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
261 |
10830
b4ebfd675321
avoid static initialization disaster in dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
10810
diff
changeset
|
262 static octave_idx_type dim_max (void); |
10810
6683f0c9d742
make the maximum extent externally accessible
Jaroslav Hajek <highegg@gmail.com>
parents:
10715
diff
changeset
|
263 |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
264 explicit dim_vector (void) : rep (nil_rep ()) |
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
265 { OCTREFCOUNT_ATOMIC_INCREMENT (&(count())); } |
4548 | 266 |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
267 dim_vector (const dim_vector& dv) : rep (dv.rep) |
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
268 { OCTREFCOUNT_ATOMIC_INCREMENT (&(count())); } |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
269 |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
270 // FIXME: Should be private, but required by array constructor for jit |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
271 explicit dim_vector (octave_idx_type *r) : rep (r) { } |
14951
4c9fd3e31436
Start of jit support for double matricies
Max Brister <max@2bass.com>
parents:
14625
diff
changeset
|
272 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
273 static dim_vector alloc (int n) |
10150 | 274 { |
275 return dim_vector (newrep (n < 2 ? 2 : n)); | |
276 } | |
4548 | 277 |
278 dim_vector& operator = (const dim_vector& dv) | |
279 { | |
280 if (&dv != this) | |
281 { | |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
282 if (OCTREFCOUNT_ATOMIC_DECREMENT (&(count())) == 0) |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
283 freerep (); |
4548 | 284 |
10150 | 285 rep = dv.rep; |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
286 OCTREFCOUNT_ATOMIC_INCREMENT (&(count())); |
4548 | 287 } |
288 | |
289 return *this; | |
290 } | |
291 | |
292 ~dim_vector (void) | |
293 { | |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
294 if (OCTREFCOUNT_ATOMIC_DECREMENT (&(count())) == 0) |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
295 freerep (); |
4548 | 296 } |
297 | |
21509
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
298 //! Number of dimensions. |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
299 /*! |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
300 Returns the number of dimensions of the dim_vector. This is number of |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
301 elements in the dim_vector including trailing singetons. It is also |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
302 the number of dimensions an Array with this dim_vector would have. |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
303 */ |
22212
2b487dbe419d
dim-vector.h (ndims): do not return a reference to the rep.
Carnë Draug <carandraug@octave.org>
parents:
22059
diff
changeset
|
304 octave_idx_type ndims (void) const { return rep[-1]; } |
21509
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
305 |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
306 //! Number of dimensions. |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
307 //! Synonymous with ndims(). |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
308 /*! |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
309 While this method is not officially deprecated, consider using ndims() |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
310 instead to avoid confusion. Array does not have length because of its |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
311 odd definition as length of the longest dimension. |
dcee67d28570
doc: doxygen documentation for dim_vector::ndims and dim_vector::length.
Carnë Draug <carandraug@octave.org>
parents:
21244
diff
changeset
|
312 */ |
10150 | 313 int length (void) const { return ndims (); } |
4513 | 314 |
5275 | 315 octave_idx_type& operator () (int i) { return elem (i); } |
4513 | 316 |
5275 | 317 octave_idx_type operator () (int i) const { return elem (i); } |
4513 | 318 |
4887 | 319 void resize (int n, int fill_value = 0) |
4548 | 320 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
321 int len = ndims (); |
4513 | 322 |
4548 | 323 if (n != len) |
324 { | |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
325 octave_idx_type *r = resizerep (n, fill_value); |
4513 | 326 |
13985
43cc49c7abd1
Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11586
diff
changeset
|
327 if (OCTREFCOUNT_ATOMIC_DECREMENT (&(count())) == 0) |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
328 freerep (); |
4513 | 329 |
9507
b096d11237be
dim_vector improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9420
diff
changeset
|
330 rep = r; |
4548 | 331 } |
332 } | |
4513 | 333 |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
334 std::string str (char sep = 'x') const; |
4543 | 335 |
336 bool all_zero (void) const | |
4548 | 337 { |
338 bool retval = true; | |
4543 | 339 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
340 for (int i = 0; i < ndims (); i++) |
4548 | 341 { |
10150 | 342 if (elem (i) != 0) |
343 { | |
344 retval = false; | |
345 break; | |
346 } | |
4548 | 347 } |
4543 | 348 |
4548 | 349 return retval; |
350 } | |
4559 | 351 |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
352 bool empty_2d (void) const |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
353 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
354 return ndims () == 2 && (elem (0) == 0 || elem (1) == 0); |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
355 } |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
356 |
9886
cddd5c3d5f04
fix & extend special-case optimizations for indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
357 bool zero_by_zero (void) const |
cddd5c3d5f04
fix & extend special-case optimizations for indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
358 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
359 return ndims () == 2 && elem (0) == 0 && elem (1) == 0; |
9886
cddd5c3d5f04
fix & extend special-case optimizations for indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
360 } |
cddd5c3d5f04
fix & extend special-case optimizations for indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9840
diff
changeset
|
361 |
4559 | 362 bool any_zero (void) const |
363 { | |
364 bool retval = false; | |
365 | |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
366 for (int i = 0; i < ndims (); i++) |
4559 | 367 { |
10150 | 368 if (elem (i) == 0) |
369 { | |
370 retval = true; | |
371 break; | |
372 } | |
4559 | 373 } |
374 | |
375 return retval; | |
376 } | |
4567 | 377 |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
378 int num_ones (void) const; |
4635 | 379 |
10150 | 380 bool all_ones (void) const |
4655 | 381 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
382 return (num_ones () == ndims ()); |
4655 | 383 } |
384 | |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
385 //! Number of elements that a matrix with this dimensions would have. |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
386 /*! |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
387 Return the number of elements that a matrix with this dimension |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
388 vector would have, NOT the number of dimensions (elements in the |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
389 dimension vector). |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
390 */ |
4567 | 391 |
9027
9a46ba093db4
generalize dim_vector::numel
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
392 octave_idx_type numel (int n = 0) const |
4567 | 393 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
394 int n_dims = ndims (); |
4567 | 395 |
9027
9a46ba093db4
generalize dim_vector::numel
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
396 octave_idx_type retval = 1; |
4567 | 397 |
9027
9a46ba093db4
generalize dim_vector::numel
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
398 for (int i = n; i < n_dims; i++) |
4567 | 399 retval *= elem (i); |
400 | |
401 return retval; | |
402 } | |
4673 | 403 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
404 /*! |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
405 The following function will throw a std::bad_alloc () |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
406 exception if the requested size is larger than can be indexed by |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21724
diff
changeset
|
407 octave_idx_type. This may be smaller than the actual amount of |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
408 memory that can be safely allocated on a system. However, if we |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
409 don't fail here, we can end up with a mysterious crash inside a |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
410 function that is iterating over an array using octave_idx_type |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
411 indices. |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
412 */ |
9840
c0b54271904b
improve safe numel() calculation for arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
9743
diff
changeset
|
413 |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
414 octave_idx_type safe_numel (void) const; |
9840
c0b54271904b
improve safe numel() calculation for arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
9743
diff
changeset
|
415 |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
416 bool any_neg (void) const |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
417 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
418 int n_dims = ndims (); |
10150 | 419 int i; |
420 | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
421 for (i = 0; i < n_dims; i++) |
10150 | 422 if (elem (i) < 0) |
423 break; | |
424 | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
425 return i < n_dims; |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
426 } |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
427 |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
428 dim_vector squeeze (void) const; |
10498
8615b55b5caf
fix & improve cat (bug #29465)
Jaroslav Hajek <highegg@gmail.com>
parents:
10420
diff
changeset
|
429 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
430 //! This corresponds to cat(). |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
431 bool concat (const dim_vector& dvb, int dim); |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
432 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
433 //! This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1). |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
434 // The rules are more relaxed here. |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10681
diff
changeset
|
435 bool hvcat (const dim_vector& dvb, int dim); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
436 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
437 /*! |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
438 Force certain dimensionality, preserving numel (). Missing |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
439 dimensions are set to 1, redundant are folded into the trailing |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
440 one. If n = 1, the result is 2d and the second dim is 1 |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
441 (dim_vectors are always at least 2D). |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
442 */ |
10681
0ba9bd294421
make cat() (hopefully) more matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10645
diff
changeset
|
443 dim_vector redim (int n) const; |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
444 |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10150
diff
changeset
|
445 dim_vector as_column (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
446 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
447 if (ndims () == 2 && elem (1) == 1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
448 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
449 else |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
450 return dim_vector (numel (), 1); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
451 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10150
diff
changeset
|
452 |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10150
diff
changeset
|
453 dim_vector as_row (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
454 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
455 if (ndims () == 2 && elem (0) == 1) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
456 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
457 else |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
458 return dim_vector (1, numel ()); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
459 } |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10150
diff
changeset
|
460 |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
461 bool is_vector (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
462 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
463 return (ndims () == 2 && (elem (0) == 1 || elem (1) == 1)); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
464 } |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
465 |
9511
cc1fd3084cb2
implement dim_vector::first_non_singleton
Jaroslav Hajek <highegg@gmail.com>
parents:
9507
diff
changeset
|
466 int first_non_singleton (int def = 0) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
467 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
468 for (int i = 0; i < ndims (); i++) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
469 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
470 if (elem (i) != 1) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
471 return i; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
472 } |
9511
cc1fd3084cb2
implement dim_vector::first_non_singleton
Jaroslav Hajek <highegg@gmail.com>
parents:
9507
diff
changeset
|
473 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
474 return def; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
475 } |
9511
cc1fd3084cb2
implement dim_vector::first_non_singleton
Jaroslav Hajek <highegg@gmail.com>
parents:
9507
diff
changeset
|
476 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
477 //! Compute a linear index from an index tuple. |
10150 | 478 |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
479 octave_idx_type compute_index (const octave_idx_type *idx) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
480 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
481 octave_idx_type k = 0; |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
482 for (int i = ndims () - 1; i >= 0; i--) |
20230
e914b5399c67
Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents:
20208
diff
changeset
|
483 k = rep[i] * k + idx[i]; |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
484 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
485 return k; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
486 } |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
487 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
488 //! Ditto, but the tuple may be incomplete (nidx < length ()). |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
489 |
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
490 octave_idx_type compute_index (const octave_idx_type *idx, int nidx) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
491 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
492 octave_idx_type k = 0; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
493 for (int i = nidx - 1; i >= 0; i--) |
20230
e914b5399c67
Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents:
20208
diff
changeset
|
494 k = rep[i] * k + idx[i]; |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
495 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
496 return k; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
497 } |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
498 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
499 /*/! |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
500 Increment a multi-dimensional index tuple, optionally starting |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
501 from an offset position and return the index of the last index |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
502 position that was changed, or length () if just cycled over. |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
503 */ |
10150 | 504 |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
505 int increment_index (octave_idx_type *idx, int start = 0) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
506 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
507 int i; |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
508 for (i = start; i < ndims (); i++) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
509 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
510 if (++(*idx) == rep[i]) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
511 *idx++ = 0; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
512 else |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
513 break; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
514 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
515 return i; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
516 } |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
517 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
518 //! Return cumulative dimensions. |
10150 | 519 |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
520 dim_vector cumulative (void) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
521 { |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
522 int nd = ndims (); |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
523 dim_vector retval = alloc (nd); |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
524 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
525 octave_idx_type k = 1; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
526 for (int i = 0; i < nd; i++) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
527 retval.rep[i] = k *= rep[i]; |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
528 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
529 return retval; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
530 } |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
531 |
19199
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
532 //! Compute a linear index from an index tuple. Dimensions are |
3a6fd52e1458
liboctave/array/dim-vector.h: convert comments to doxygen
Carnë Draug <carandraug@octave.org>
parents:
17769
diff
changeset
|
533 //! required to be cumulative. |
10150 | 534 |
10645
8645b7087859
abstract scalar index checking off Array<T> (prep for struct optimizations)
Jaroslav Hajek <highegg@gmail.com>
parents:
10586
diff
changeset
|
535 octave_idx_type cum_compute_index (const octave_idx_type *idx) const |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
536 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
537 octave_idx_type k = idx[0]; |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
538 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
539 for (int i = 1; i < ndims (); i++) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
540 k += rep[i-1] * idx[i]; |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
541 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
542 return k; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
543 } |
9739
13b57eec9440
a few handy methods for dim_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
544 |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
545 friend bool operator == (const dim_vector& a, const dim_vector& b); |
4513 | 546 }; |
547 | |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
548 inline bool |
4543 | 549 operator == (const dim_vector& a, const dim_vector& b) |
550 { | |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
551 // Fast case. |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
552 if (a.rep == b.rep) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
553 return true; |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
554 |
4543 | 555 bool retval = true; |
556 | |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
557 int a_len = a.ndims (); |
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
558 int b_len = b.ndims (); |
4543 | 559 |
560 if (a_len != b_len) | |
561 retval = false; | |
562 else | |
563 { | |
564 for (int i = 0; i < a_len; i++) | |
10150 | 565 { |
566 if (a(i) != b(i)) | |
567 { | |
568 retval = false; | |
569 break; | |
570 } | |
571 } | |
4543 | 572 } |
573 | |
574 return retval; | |
575 } | |
576 | |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
9666
diff
changeset
|
577 inline bool |
4543 | 578 operator != (const dim_vector& a, const dim_vector& b) |
579 { | |
580 return ! operator == (a, b); | |
581 } | |
582 | |
4513 | 583 #endif |