Mercurial > octave
annotate src/ov.h @ 9657:3c1c3a38ec7b
implement templated octave_value extractor
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 19 Sep 2009 21:38:30 +0200 |
parents | 1be3c73ed7b5 |
children | afcf852256d2 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 John W. Eaton |
2376 | 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. | |
2376 | 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/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_value_h) | |
25 #define octave_value_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
29 #include <iosfwd> |
2376 | 30 #include <string> |
4219 | 31 #include <list> |
2376 | 32 |
33 #include "Range.h" | |
5828 | 34 #include "data-conv.h" |
2376 | 35 #include "idx-vector.h" |
5828 | 36 #include "mach-info.h" |
5900 | 37 #include "mxarray.h" |
2376 | 38 #include "mx-base.h" |
2477 | 39 #include "oct-alloc.h" |
4254 | 40 #include "oct-time.h" |
2942 | 41 #include "str-vec.h" |
42 | |
8676 | 43 #include "oct-hdf5.h" |
7433 | 44 #include "oct-sort.h" |
45 | |
3351 | 46 class Cell; |
2376 | 47 class Octave_map; |
2903 | 48 class octave_stream; |
2974 | 49 class octave_function; |
4700 | 50 class octave_user_function; |
4342 | 51 class octave_fcn_handle; |
4933 | 52 class octave_fcn_inline; |
2376 | 53 class octave_value_list; |
2979 | 54 class octave_lvalue; |
2376 | 55 |
5759 | 56 #include "ov-base.h" |
2376 | 57 |
5759 | 58 // Constants. |
2376 | 59 |
2427 | 60 class octave_value; |
61 | |
2376 | 62 class |
6109 | 63 OCTINTERP_API |
2974 | 64 octave_value |
2376 | 65 { |
66 public: | |
67 | |
3203 | 68 enum unary_op |
69 { | |
6518 | 70 op_not, // not |
71 op_uplus, // uplus | |
72 op_uminus, // uminus | |
73 op_transpose, // transpose | |
74 op_hermitian, // ctranspose | |
3525 | 75 op_incr, |
76 op_decr, | |
3203 | 77 num_unary_ops, |
78 unknown_unary_op | |
79 }; | |
80 | |
2376 | 81 enum binary_op |
82 { | |
6518 | 83 op_add, // plus |
84 op_sub, // minus | |
85 op_mul, // mtimes | |
86 op_div, // mrdivide | |
87 op_pow, // mpower | |
88 op_ldiv, // mldivide | |
3525 | 89 op_lshift, |
90 op_rshift, | |
6518 | 91 op_lt, // lt |
92 op_le, // le | |
93 op_eq, // eq | |
94 op_ge, // ge | |
95 op_gt, // gt | |
96 op_ne, // ne | |
97 op_el_mul, // times | |
98 op_el_div, // rdivide | |
99 op_el_pow, // power | |
100 op_el_ldiv, // ldivide | |
101 op_el_and, // and | |
102 op_el_or, // or | |
3525 | 103 op_struct_ref, |
2376 | 104 num_binary_ops, |
105 unknown_binary_op | |
106 }; | |
107 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
108 enum compound_binary_op |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
109 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
110 // ** compound operations ** |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
111 op_trans_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
112 op_mul_trans, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
113 op_herm_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
114 op_mul_herm, |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
115 op_el_not_and, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
116 op_el_not_or, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
117 op_el_and_not, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
118 op_el_or_not, |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
119 num_compound_binary_ops, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
120 unknown_compound_binary_op |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
121 }; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
122 |
2880 | 123 enum assign_op |
124 { | |
3525 | 125 op_asn_eq, |
126 op_add_eq, | |
127 op_sub_eq, | |
128 op_mul_eq, | |
129 op_div_eq, | |
130 op_ldiv_eq, | |
4018 | 131 op_pow_eq, |
3525 | 132 op_lshift_eq, |
133 op_rshift_eq, | |
134 op_el_mul_eq, | |
135 op_el_div_eq, | |
136 op_el_ldiv_eq, | |
4018 | 137 op_el_pow_eq, |
3525 | 138 op_el_and_eq, |
139 op_el_or_eq, | |
2880 | 140 num_assign_ops, |
141 unknown_assign_op | |
142 }; | |
143 | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9521
diff
changeset
|
144 static assign_op binary_op_to_assign_op (binary_op); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9521
diff
changeset
|
145 |
3523 | 146 static std::string unary_op_as_string (unary_op); |
7336 | 147 static std::string unary_op_fcn_name (unary_op); |
3203 | 148 |
3523 | 149 static std::string binary_op_as_string (binary_op); |
7336 | 150 static std::string binary_op_fcn_name (binary_op); |
2376 | 151 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
152 static std::string binary_op_fcn_name (compound_binary_op); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
153 |
3523 | 154 static std::string assign_op_as_string (assign_op); |
2880 | 155 |
3933 | 156 static octave_value empty_conv (const std::string& type, |
157 const octave_value& rhs = octave_value ()); | |
158 | |
2376 | 159 enum magic_colon { magic_colon_t }; |
160 | |
8992
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
161 octave_value (void) |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
162 { |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
163 static octave_base_value nil_rep; |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
164 rep = &nil_rep; |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
165 rep->count++; |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
166 } |
d12f44a5dce3
implement fast octave_value constructor
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
167 |
4254 | 168 octave_value (short int i); |
169 octave_value (unsigned short int i); | |
4233 | 170 octave_value (int i); |
4254 | 171 octave_value (unsigned int i); |
172 octave_value (long int i); | |
173 octave_value (unsigned long int i); | |
4353 | 174 |
5775 | 175 // FIXME -- these are kluges. They turn into doubles |
4353 | 176 // internally, which will break for very large values. We just use |
177 // them to store things like 64-bit ino_t, etc, and hope that those | |
178 // values are never actually larger than can be represented exactly | |
179 // in a double. | |
180 | |
181 #if defined (HAVE_LONG_LONG_INT) | |
182 octave_value (long long int i); | |
183 #endif | |
4356 | 184 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 185 octave_value (unsigned long long int i); |
186 #endif | |
187 | |
4254 | 188 octave_value (octave_time t); |
2376 | 189 octave_value (double d); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
190 octave_value (float d); |
5147 | 191 octave_value (const ArrayN<octave_value>& a, bool is_cs_list = false); |
4532 | 192 octave_value (const Cell& c, bool is_cs_list = false); |
5785 | 193 octave_value (const Matrix& m, const MatrixType& t = MatrixType()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
194 octave_value (const FloatMatrix& m, const MatrixType& t = MatrixType()); |
4513 | 195 octave_value (const NDArray& nda); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
196 octave_value (const FloatNDArray& nda); |
4911 | 197 octave_value (const ArrayN<double>& m); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
198 octave_value (const ArrayN<float>& m); |
2376 | 199 octave_value (const DiagMatrix& d); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
200 octave_value (const FloatDiagMatrix& d); |
3418 | 201 octave_value (const RowVector& v); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
202 octave_value (const FloatRowVector& v); |
3418 | 203 octave_value (const ColumnVector& v); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
204 octave_value (const FloatColumnVector& v); |
2376 | 205 octave_value (const Complex& C); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
206 octave_value (const FloatComplex& C); |
5785 | 207 octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
208 octave_value (const FloatComplexMatrix& m, const MatrixType& t = MatrixType()); |
4513 | 209 octave_value (const ComplexNDArray& cnda); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
210 octave_value (const FloatComplexNDArray& cnda); |
4478 | 211 octave_value (const ArrayN<Complex>& m); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
212 octave_value (const ArrayN<FloatComplex>& m); |
2376 | 213 octave_value (const ComplexDiagMatrix& d); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
214 octave_value (const FloatComplexDiagMatrix& d); |
3418 | 215 octave_value (const ComplexRowVector& v); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
216 octave_value (const FloatComplexRowVector& v); |
3418 | 217 octave_value (const ComplexColumnVector& v); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
218 octave_value (const FloatComplexColumnVector& v); |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
219 octave_value (const PermMatrix& p); |
2825 | 220 octave_value (bool b); |
5785 | 221 octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType()); |
4513 | 222 octave_value (const boolNDArray& bnda); |
7433 | 223 octave_value (const ArrayN<bool>& bnda); |
5279 | 224 octave_value (char c, char type = '"'); |
225 octave_value (const char *s, char type = '"'); | |
226 octave_value (const std::string& s, char type = '"'); | |
227 octave_value (const string_vector& s, char type = '"'); | |
228 octave_value (const charMatrix& chm, bool is_string = false, | |
229 char type = '"'); | |
230 octave_value (const charNDArray& chnda, bool is_string = false, | |
231 char type = '"'); | |
232 octave_value (const ArrayN<char>& chnda, bool is_string = false, | |
233 char type = '"'); | |
5785 | 234 octave_value (const SparseMatrix& m, const MatrixType& t = MatrixType ()); |
6863 | 235 octave_value (const Sparse<double>& m, const MatrixType& t = MatrixType ()); |
5164 | 236 octave_value (const SparseComplexMatrix& m, |
5785 | 237 const MatrixType& t = MatrixType ()); |
6863 | 238 octave_value (const Sparse<Complex>& m, const MatrixType& t = MatrixType ()); |
5164 | 239 octave_value (const SparseBoolMatrix& bm, |
5785 | 240 const MatrixType& t = MatrixType ()); |
7433 | 241 octave_value (const Sparse<bool>& m, const MatrixType& t = MatrixType ()); |
4901 | 242 octave_value (const octave_int8& i); |
4910 | 243 octave_value (const octave_int16& i); |
244 octave_value (const octave_int32& i); | |
245 octave_value (const octave_int64& i); | |
4901 | 246 octave_value (const octave_uint8& i); |
247 octave_value (const octave_uint16& i); | |
248 octave_value (const octave_uint32& i); | |
249 octave_value (const octave_uint64& i); | |
250 octave_value (const int8NDArray& inda); | |
7064 | 251 octave_value (const ArrayN<octave_int8>& inda); |
4910 | 252 octave_value (const int16NDArray& inda); |
7064 | 253 octave_value (const ArrayN<octave_int16>& inda); |
4910 | 254 octave_value (const int32NDArray& inda); |
7064 | 255 octave_value (const ArrayN<octave_int32>& inda); |
4910 | 256 octave_value (const int64NDArray& inda); |
7064 | 257 octave_value (const ArrayN<octave_int64>& inda); |
4901 | 258 octave_value (const uint8NDArray& inda); |
7064 | 259 octave_value (const ArrayN<octave_uint8>& inda); |
4901 | 260 octave_value (const uint16NDArray& inda); |
7064 | 261 octave_value (const ArrayN<octave_uint16>& inda); |
4901 | 262 octave_value (const uint32NDArray& inda); |
7064 | 263 octave_value (const ArrayN<octave_uint32>& inda); |
4901 | 264 octave_value (const uint64NDArray& inda); |
7064 | 265 octave_value (const ArrayN<octave_uint64>& inda); |
9351
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
266 octave_value (const Array<octave_idx_type>& inda, |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
267 bool zero_based = false, bool cache_index = false); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9351
diff
changeset
|
268 octave_value (const idx_vector& idx); |
2376 | 269 octave_value (double base, double limit, double inc); |
270 octave_value (const Range& r); | |
271 octave_value (const Octave_map& m); | |
7336 | 272 octave_value (const Octave_map& m, const std::string& id); |
3977 | 273 octave_value (const octave_value_list& m, bool is_cs_list = false); |
2376 | 274 octave_value (octave_value::magic_colon); |
275 | |
5759 | 276 octave_value (octave_base_value *new_rep); |
7336 | 277 octave_value (octave_base_value *new_rep, int xcount); |
2376 | 278 |
279 // Copy constructor. | |
280 | |
281 octave_value (const octave_value& a) | |
282 { | |
283 rep = a.rep; | |
284 rep->count++; | |
285 } | |
286 | |
3933 | 287 // This should only be called for derived types. |
288 | |
5759 | 289 octave_base_value *clone (void) const; |
3933 | 290 |
5759 | 291 octave_base_value *empty_clone (void) const |
3933 | 292 { return rep->empty_clone (); } |
293 | |
2376 | 294 // Delete the representation of this constant if the count drops to |
295 // zero. | |
296 | |
6338 | 297 ~octave_value (void) |
298 { | |
299 if (--rep->count == 0) | |
300 delete rep; | |
301 } | |
2376 | 302 |
303 void make_unique (void) | |
304 { | |
305 if (rep->count > 1) | |
306 { | |
307 --rep->count; | |
9521 | 308 rep = rep->unique_clone (); |
2376 | 309 } |
310 } | |
311 | |
8546
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
312 // This uniquifies the value if it is referenced by more than a certain |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
313 // number of shallow copies. This is useful for optimizations where we |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
314 // know a certain copy, typically within a cell array, to be obsolete. |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
315 void make_unique (int obsolete_copies) |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
316 { |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
317 if (rep->count > obsolete_copies + 1) |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
318 { |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
319 --rep->count; |
9521 | 320 rep = rep->unique_clone (); |
8546
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
321 } |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
322 } |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
323 |
2376 | 324 // Simple assignment. |
325 | |
326 octave_value& operator = (const octave_value& a) | |
327 { | |
328 if (rep != a.rep) | |
329 { | |
330 if (--rep->count == 0) | |
331 delete rep; | |
332 | |
333 rep = a.rep; | |
334 rep->count++; | |
335 } | |
336 | |
337 return *this; | |
338 } | |
339 | |
3933 | 340 int get_count (void) const { return rep->count; } |
3239 | 341 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
342 octave_base_value::type_conv_info numeric_conversion_function (void) const |
2376 | 343 { return rep->numeric_conversion_function (); } |
344 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
345 octave_base_value::type_conv_info numeric_demotion_function (void) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
346 { return rep->numeric_demotion_function (); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
347 |
2409 | 348 void maybe_mutate (void); |
349 | |
5759 | 350 octave_value squeeze (void) const |
4532 | 351 { return rep->squeeze (); } |
352 | |
8458
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8456
diff
changeset
|
353 // The result of full(). |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8456
diff
changeset
|
354 octave_value full_value (void) const |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8456
diff
changeset
|
355 { return rep->full_value (); } |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8456
diff
changeset
|
356 |
5759 | 357 octave_base_value *try_narrowing_conversion (void) |
2410 | 358 { return rep->try_narrowing_conversion (); } |
2409 | 359 |
9329
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
360 // Close to dims (), but can be overloaded for classes. |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
361 Matrix size (void) |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
362 { return rep->size (); } |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
363 |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
364 octave_idx_type numel (const octave_value_list& idx) |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
365 { return rep->numel (idx); } |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
366 |
4271 | 367 octave_value single_subsref (const std::string& type, |
368 const octave_value_list& idx); | |
369 | |
5759 | 370 octave_value subsref (const std::string& type, |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
371 const std::list<octave_value_list>& idx) |
3933 | 372 { return rep->subsref (type, idx); } |
373 | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
374 octave_value subsref (const std::string& type, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
375 const std::list<octave_value_list>& idx, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
376 bool auto_add) |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
377 { return rep->subsref (type, idx, auto_add); } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
378 |
5759 | 379 octave_value_list subsref (const std::string& type, |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
380 const std::list<octave_value_list>& idx, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
381 int nargout); |
3933 | 382 |
4247 | 383 octave_value next_subsref (const std::string& type, const |
4219 | 384 std::list<octave_value_list>& idx, |
4233 | 385 size_t skip = 1); |
3933 | 386 |
4994 | 387 octave_value_list next_subsref (int nargout, |
388 const std::string& type, const | |
389 std::list<octave_value_list>& idx, | |
390 size_t skip = 1); | |
391 | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
392 octave_value next_subsref (bool auto_add, const std::string& type, const |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
393 std::list<octave_value_list>& idx, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
394 size_t skip = 1); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
395 |
5759 | 396 octave_value do_index_op (const octave_value_list& idx, |
5885 | 397 bool resize_ok = false) |
3933 | 398 { return rep->do_index_op (idx, resize_ok); } |
399 | |
5759 | 400 octave_value_list |
3544 | 401 do_multi_index_op (int nargout, const octave_value_list& idx); |
2974 | 402 |
5759 | 403 octave_value subsasgn (const std::string& type, |
4219 | 404 const std::list<octave_value_list>& idx, |
3933 | 405 const octave_value& rhs); |
2376 | 406 |
4247 | 407 octave_value assign (assign_op op, const std::string& type, |
4219 | 408 const std::list<octave_value_list>& idx, |
3933 | 409 const octave_value& rhs); |
2948 | 410 |
3933 | 411 const octave_value& assign (assign_op, const octave_value& rhs); |
2948 | 412 |
5759 | 413 idx_vector index_vector (void) const |
2376 | 414 { return rep->index_vector (); } |
415 | |
416 // Size. | |
417 | |
5759 | 418 dim_vector dims (void) const |
4513 | 419 { return rep->dims (); } |
420 | |
5759 | 421 octave_idx_type rows (void) const { return rep->rows (); } |
4563 | 422 |
5759 | 423 octave_idx_type columns (void) const { return rep->columns (); } |
3195 | 424 |
5275 | 425 octave_idx_type length (void) const; |
4554 | 426 |
5759 | 427 int ndims (void) const { return rep->ndims (); } |
4563 | 428 |
5164 | 429 bool all_zero_dims (void) const { return dims().all_zero (); } |
430 | |
5759 | 431 octave_idx_type numel (void) const |
5080 | 432 { return rep->numel (); } |
4559 | 433 |
5759 | 434 octave_idx_type capacity (void) const |
5164 | 435 { return rep->capacity (); } |
436 | |
5759 | 437 size_t byte_size (void) const |
4791 | 438 { return rep->byte_size (); } |
439 | |
5759 | 440 octave_idx_type nnz (void) const { return rep->nnz (); } |
5602 | 441 |
5759 | 442 octave_idx_type nzmax (void) const { return rep->nzmax (); } |
5604 | 443 |
5900 | 444 octave_idx_type nfields (void) const { return rep->nfields (); } |
445 | |
5759 | 446 octave_value reshape (const dim_vector& dv) const |
4587 | 447 { return rep->reshape (dv); } |
4567 | 448 |
5759 | 449 octave_value permute (const Array<int>& vec, bool inv = false) const |
4593 | 450 { return rep->permute (vec, inv); } |
451 | |
452 octave_value ipermute (const Array<int>& vec) const | |
453 { return rep->permute (vec, true); } | |
454 | |
5759 | 455 octave_value resize (const dim_vector& dv, bool fill = false) const |
456 { return rep->resize (dv, fill);} | |
4915 | 457 |
5785 | 458 MatrixType matrix_type (void) const |
459 { return rep->matrix_type (); } | |
460 | |
461 MatrixType matrix_type (const MatrixType& typ) const | |
462 { return rep->matrix_type (typ); } | |
463 | |
2376 | 464 // Does this constant have a type? Both of these are provided since |
465 // it is sometimes more natural to write is_undefined() instead of | |
466 // ! is_defined(). | |
467 | |
5759 | 468 bool is_defined (void) const |
2376 | 469 { return rep->is_defined (); } |
470 | |
471 bool is_undefined (void) const | |
472 { return ! is_defined (); } | |
473 | |
4559 | 474 bool is_empty (void) const |
5759 | 475 { return rep->is_empty (); } |
4559 | 476 |
5759 | 477 bool is_cell (void) const |
3351 | 478 { return rep->is_cell (); } |
479 | |
6116 | 480 bool is_cellstr (void) const |
481 { return rep->is_cellstr (); } | |
482 | |
5759 | 483 bool is_real_scalar (void) const |
2376 | 484 { return rep->is_real_scalar (); } |
485 | |
5759 | 486 bool is_real_matrix (void) const |
2376 | 487 { return rep->is_real_matrix (); } |
488 | |
5759 | 489 bool is_real_nd_array (void) const |
4505 | 490 { return rep->is_real_nd_array (); } |
491 | |
5759 | 492 bool is_complex_scalar (void) const |
2376 | 493 { return rep->is_complex_scalar (); } |
494 | |
5759 | 495 bool is_complex_matrix (void) const |
2376 | 496 { return rep->is_complex_matrix (); } |
497 | |
5881 | 498 bool is_bool_scalar (void) const |
499 { return rep->is_bool_scalar (); } | |
500 | |
5759 | 501 bool is_bool_matrix (void) const |
4587 | 502 { return rep->is_bool_matrix (); } |
503 | |
5759 | 504 bool is_char_matrix (void) const |
2376 | 505 { return rep->is_char_matrix (); } |
506 | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
507 bool is_diag_matrix (void) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
508 { return rep->is_diag_matrix (); } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
509 |
8371
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
510 bool is_perm_matrix (void) const |
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
511 { return rep->is_perm_matrix (); } |
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
512 |
5759 | 513 bool is_string (void) const |
2376 | 514 { return rep->is_string (); } |
515 | |
5759 | 516 bool is_sq_string (void) const |
5279 | 517 { return rep->is_sq_string (); } |
518 | |
5280 | 519 bool is_dq_string (void) const |
520 { return rep->is_string () && ! rep->is_sq_string (); } | |
521 | |
5759 | 522 bool is_range (void) const |
2376 | 523 { return rep->is_range (); } |
524 | |
5759 | 525 bool is_map (void) const |
2376 | 526 { return rep->is_map (); } |
527 | |
7336 | 528 bool is_object (void) const |
529 { return rep->is_object (); } | |
530 | |
5759 | 531 bool is_cs_list (void) const |
3977 | 532 { return rep->is_cs_list (); } |
533 | |
5759 | 534 bool is_list (void) const |
2880 | 535 { return rep->is_list (); } |
536 | |
5759 | 537 bool is_magic_colon (void) const |
2376 | 538 { return rep->is_magic_colon (); } |
539 | |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
540 bool is_null_value (void) const |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
541 { return rep->is_null_value (); } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
542 |
2376 | 543 // Are any or all of the elements in this constant nonzero? |
544 | |
5759 | 545 octave_value all (int dim = 0) const |
4015 | 546 { return rep->all (dim); } |
2376 | 547 |
5759 | 548 octave_value any (int dim = 0) const |
4015 | 549 { return rep->any (dim); } |
2376 | 550 |
5895 | 551 // Floating point types. |
552 | |
553 bool is_double_type (void) const | |
554 { return rep->is_double_type (); } | |
555 | |
556 bool is_single_type (void) const | |
557 { return rep->is_single_type (); } | |
558 | |
7576 | 559 bool is_float_type (void) const |
560 { return rep->is_float_type (); } | |
561 | |
5895 | 562 // Integer types. |
563 | |
564 bool is_int8_type (void) const | |
565 { return rep->is_int8_type (); } | |
566 | |
567 bool is_int16_type (void) const | |
568 { return rep->is_int16_type (); } | |
569 | |
570 bool is_int32_type (void) const | |
571 { return rep->is_int32_type (); } | |
572 | |
573 bool is_int64_type (void) const | |
574 { return rep->is_int64_type (); } | |
575 | |
576 bool is_uint8_type (void) const | |
577 { return rep->is_uint8_type (); } | |
578 | |
579 bool is_uint16_type (void) const | |
580 { return rep->is_uint16_type (); } | |
581 | |
582 bool is_uint32_type (void) const | |
583 { return rep->is_uint32_type (); } | |
584 | |
585 bool is_uint64_type (void) const | |
586 { return rep->is_uint64_type (); } | |
587 | |
2376 | 588 // Other type stuff. |
589 | |
5759 | 590 bool is_bool_type (void) const |
3209 | 591 { return rep->is_bool_type (); } |
592 | |
6223 | 593 bool is_integer_type (void) const |
594 { return rep->is_integer_type (); } | |
595 | |
5759 | 596 bool is_real_type (void) const |
2376 | 597 { return rep->is_real_type (); } |
598 | |
5759 | 599 bool is_complex_type (void) const |
2376 | 600 { return rep->is_complex_type (); } |
601 | |
5759 | 602 bool is_scalar_type (void) const |
2376 | 603 { return rep->is_scalar_type (); } |
604 | |
5759 | 605 bool is_matrix_type (void) const |
2376 | 606 { return rep->is_matrix_type (); } |
607 | |
5759 | 608 bool is_numeric_type (void) const |
2376 | 609 { return rep->is_numeric_type (); } |
610 | |
5759 | 611 bool is_sparse_type (void) const |
5631 | 612 { return rep->is_sparse_type (); } |
613 | |
2376 | 614 // Does this constant correspond to a truth value? |
615 | |
5759 | 616 bool is_true (void) const |
2376 | 617 { return rep->is_true (); } |
618 | |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
619 // Do two constants match (in a switch statement)? |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
620 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
621 bool is_equal (const octave_value&) const; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
622 |
2376 | 623 // Are the dimensions of this constant zero by zero? |
624 | |
5759 | 625 bool is_zero_by_zero (void) const |
626 { return (rows () == 0 && columns () == 0); } | |
2376 | 627 |
5759 | 628 bool is_constant (void) const |
2974 | 629 { return rep->is_constant (); } |
630 | |
5759 | 631 bool is_function_handle (void) const |
4654 | 632 { return rep->is_function_handle (); } |
633 | |
5759 | 634 bool is_inline_function (void) const |
4954 | 635 { return rep->is_inline_function (); } |
636 | |
5759 | 637 bool is_function (void) const |
2974 | 638 { return rep->is_function (); } |
2891 | 639 |
7336 | 640 bool is_user_script (void) const |
641 { return rep->is_user_script (); } | |
642 | |
643 bool is_user_function (void) const | |
644 { return rep->is_user_function (); } | |
645 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
646 bool is_user_code (void) const |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
647 { return rep->is_user_code (); } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
648 |
5759 | 649 bool is_builtin_function (void) const |
3325 | 650 { return rep->is_builtin_function (); } |
651 | |
5759 | 652 bool is_dld_function (void) const |
3325 | 653 { return rep->is_dld_function (); } |
654 | |
5864 | 655 bool is_mex_function (void) const |
656 { return rep->is_mex_function (); } | |
657 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
658 void erase_subfunctions (void) { rep->erase_subfunctions (); } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
659 |
2376 | 660 // Values. |
661 | |
2891 | 662 octave_value eval (void) { return *this; } |
663 | |
5759 | 664 short int |
4254 | 665 short_value (bool req_int = false, bool frc_str_conv = false) const |
666 { return rep->short_value (req_int, frc_str_conv); } | |
667 | |
5759 | 668 unsigned short int |
4254 | 669 ushort_value (bool req_int = false, bool frc_str_conv = false) const |
670 { return rep->ushort_value (req_int, frc_str_conv); } | |
671 | |
5759 | 672 int int_value (bool req_int = false, bool frc_str_conv = false) const |
3202 | 673 { return rep->int_value (req_int, frc_str_conv); } |
674 | |
5759 | 675 unsigned int |
4254 | 676 uint_value (bool req_int = false, bool frc_str_conv = false) const |
677 { return rep->uint_value (req_int, frc_str_conv); } | |
678 | |
5759 | 679 int nint_value (bool frc_str_conv = false) const |
3202 | 680 { return rep->nint_value (frc_str_conv); } |
681 | |
5759 | 682 long int |
4254 | 683 long_value (bool req_int = false, bool frc_str_conv = false) const |
684 { return rep->long_value (req_int, frc_str_conv); } | |
685 | |
5759 | 686 unsigned long int |
4254 | 687 ulong_value (bool req_int = false, bool frc_str_conv = false) const |
688 { return rep->ulong_value (req_int, frc_str_conv); } | |
689 | |
6133 | 690 octave_idx_type |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
7885
diff
changeset
|
691 idx_type_value (bool req_int = false, bool frc_str_conv = false) const; |
6133 | 692 |
5759 | 693 double double_value (bool frc_str_conv = false) const |
2376 | 694 { return rep->double_value (frc_str_conv); } |
695 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
696 float float_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
697 { return rep->float_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
698 |
5759 | 699 double scalar_value (bool frc_str_conv = false) const |
2916 | 700 { return rep->scalar_value (frc_str_conv); } |
701 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
702 float float_scalar_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
703 { return rep->float_scalar_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
704 |
5759 | 705 Cell cell_value (void) const; |
3351 | 706 |
5759 | 707 Matrix matrix_value (bool frc_str_conv = false) const |
2376 | 708 { return rep->matrix_value (frc_str_conv); } |
709 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
710 FloatMatrix float_matrix_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
711 { return rep->float_matrix_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
712 |
5759 | 713 NDArray array_value (bool frc_str_conv = false) const |
4550 | 714 { return rep->array_value (frc_str_conv); } |
4505 | 715 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
716 FloatNDArray float_array_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
717 { return rep->float_array_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
718 |
5759 | 719 Complex complex_value (bool frc_str_conv = false) const |
2376 | 720 { return rep->complex_value (frc_str_conv); } |
721 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
722 FloatComplex float_complex_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
723 { return rep->float_complex_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
724 |
5759 | 725 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
2376 | 726 { return rep->complex_matrix_value (frc_str_conv); } |
727 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
728 FloatComplexMatrix float_complex_matrix_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
729 { return rep->float_complex_matrix_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
730 |
5759 | 731 ComplexNDArray complex_array_value (bool frc_str_conv = false) const |
4550 | 732 { return rep->complex_array_value (frc_str_conv); } |
733 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
734 FloatComplexNDArray float_complex_array_value (bool frc_str_conv = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
735 { return rep->float_complex_array_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
736 |
5943 | 737 bool bool_value (bool warn = false) const |
738 { return rep->bool_value (warn); } | |
4550 | 739 |
5943 | 740 boolMatrix bool_matrix_value (bool warn = false) const |
741 { return rep->bool_matrix_value (warn); } | |
4550 | 742 |
5943 | 743 boolNDArray bool_array_value (bool warn = false) const |
744 { return rep->bool_array_value (warn); } | |
4550 | 745 |
5759 | 746 charMatrix char_matrix_value (bool frc_str_conv = false) const |
2376 | 747 { return rep->char_matrix_value (frc_str_conv); } |
748 | |
5759 | 749 charNDArray char_array_value (bool frc_str_conv = false) const |
4550 | 750 { return rep->char_array_value (frc_str_conv); } |
751 | |
5759 | 752 SparseMatrix sparse_matrix_value (bool frc_str_conv = false) const |
753 { return rep->sparse_matrix_value (frc_str_conv); } | |
5164 | 754 |
5759 | 755 SparseComplexMatrix sparse_complex_matrix_value (bool frc_str_conv = false) const |
756 { return rep->sparse_complex_matrix_value (frc_str_conv); } | |
5164 | 757 |
5759 | 758 SparseBoolMatrix sparse_bool_matrix_value (bool frc_str_conv = false) const |
759 { return rep->sparse_bool_matrix_value (frc_str_conv); } | |
5164 | 760 |
8916
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
761 DiagMatrix diag_matrix_value (bool force = false) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
762 { return rep->diag_matrix_value (force); } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
763 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
764 FloatDiagMatrix float_diag_matrix_value (bool force = false) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
765 { return rep->float_diag_matrix_value (force); } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
766 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
767 ComplexDiagMatrix complex_diag_matrix_value (bool force = false) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
768 { return rep->complex_diag_matrix_value (force); } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
769 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
770 FloatComplexDiagMatrix float_complex_diag_matrix_value (bool force = false) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
771 { return rep->float_complex_diag_matrix_value (force); } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
772 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
773 PermMatrix perm_matrix_value (void) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
774 { return rep->perm_matrix_value (); } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8811
diff
changeset
|
775 |
5759 | 776 octave_int8 int8_scalar_value (void) const |
4910 | 777 { return rep->int8_scalar_value (); } |
778 | |
5759 | 779 octave_int16 int16_scalar_value (void) const |
4910 | 780 { return rep->int16_scalar_value (); } |
781 | |
5759 | 782 octave_int32 int32_scalar_value (void) const |
4910 | 783 { return rep->int32_scalar_value (); } |
784 | |
5759 | 785 octave_int64 int64_scalar_value (void) const |
4910 | 786 { return rep->int64_scalar_value (); } |
787 | |
5759 | 788 octave_uint8 uint8_scalar_value (void) const |
4910 | 789 { return rep->uint8_scalar_value (); } |
790 | |
5759 | 791 octave_uint16 uint16_scalar_value (void) const |
4910 | 792 { return rep->uint16_scalar_value (); } |
793 | |
5759 | 794 octave_uint32 uint32_scalar_value (void) const |
4910 | 795 { return rep->uint32_scalar_value (); } |
796 | |
5759 | 797 octave_uint64 uint64_scalar_value (void) const |
4910 | 798 { return rep->uint64_scalar_value (); } |
799 | |
5759 | 800 int8NDArray int8_array_value (void) const |
4906 | 801 { return rep->int8_array_value (); } |
802 | |
5759 | 803 int16NDArray int16_array_value (void) const |
4906 | 804 { return rep->int16_array_value (); } |
805 | |
5759 | 806 int32NDArray int32_array_value (void) const |
4906 | 807 { return rep->int32_array_value (); } |
808 | |
5759 | 809 int64NDArray int64_array_value (void) const |
4906 | 810 { return rep->int64_array_value (); } |
811 | |
5759 | 812 uint8NDArray uint8_array_value (void) const |
4906 | 813 { return rep->uint8_array_value (); } |
814 | |
5759 | 815 uint16NDArray uint16_array_value (void) const |
4906 | 816 { return rep->uint16_array_value (); } |
817 | |
5759 | 818 uint32NDArray uint32_array_value (void) const |
4906 | 819 { return rep->uint32_array_value (); } |
820 | |
5759 | 821 uint64NDArray uint64_array_value (void) const |
4906 | 822 { return rep->uint64_array_value (); } |
823 | |
5759 | 824 string_vector all_strings (bool pad = false) const |
5715 | 825 { return rep->all_strings (pad); } |
2376 | 826 |
5759 | 827 std::string string_value (bool force = false) const |
4665 | 828 { return rep->string_value (force); } |
2376 | 829 |
8732 | 830 Array<std::string> cellstr_value (void) const |
831 { return rep->cellstr_value (); } | |
832 | |
5759 | 833 Range range_value (void) const |
2376 | 834 { return rep->range_value (); } |
835 | |
5759 | 836 Octave_map map_value (void) const; |
2376 | 837 |
5759 | 838 string_vector map_keys (void) const |
3933 | 839 { return rep->map_keys (); } |
840 | |
9151 | 841 size_t nparents (void) const |
842 { return rep->nparents (); } | |
843 | |
844 std::list<std::string> parent_class_name_list (void) const | |
845 { return rep->parent_class_name_list (); } | |
846 | |
9010
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
847 string_vector parent_class_names (void) const |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
848 { return rep->parent_class_names (); } |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
849 |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
850 octave_base_value * |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
851 find_parent_class (const std::string& parent_class_name) |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
852 { return rep->find_parent_class (parent_class_name); } |
f914834836e7
Partial implementation of derived classes using the old form with "@" files.
rtshort@smoketree.phaselocked.com
parents:
8992
diff
changeset
|
853 |
5759 | 854 octave_function *function_value (bool silent = false); |
2974 | 855 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
856 const octave_function *function_value (bool silent = false) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
857 |
5759 | 858 octave_user_function *user_function_value (bool silent = false); |
4700 | 859 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
860 octave_user_script *user_script_value (bool silent = false); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
861 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
862 octave_user_code *user_code_value (bool silent = false); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
863 |
5759 | 864 octave_fcn_handle *fcn_handle_value (bool silent = false); |
4343 | 865 |
5759 | 866 octave_fcn_inline *fcn_inline_value (bool silent = false); |
4933 | 867 |
5759 | 868 octave_value_list list_value (void) const; |
2880 | 869 |
3419 | 870 ColumnVector column_vector_value (bool frc_str_conv = false, |
2376 | 871 bool frc_vec_conv = false) const; |
872 | |
873 ComplexColumnVector | |
3419 | 874 complex_column_vector_value (bool frc_str_conv = false, |
2376 | 875 bool frc_vec_conv = false) const; |
876 | |
3419 | 877 RowVector row_vector_value (bool frc_str_conv = false, |
878 bool frc_vec_conv = false) const; | |
879 | |
880 ComplexRowVector | |
881 complex_row_vector_value (bool frc_str_conv = false, | |
882 bool frc_vec_conv = false) const; | |
883 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
884 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
885 FloatColumnVector float_column_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
886 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
887 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
888 FloatComplexColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
889 float_complex_column_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
890 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
891 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
892 FloatRowVector float_row_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
893 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
894 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
895 FloatComplexRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
896 float_complex_row_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
897 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
898 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
899 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
900 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
901 |
4044 | 902 Array<int> int_vector_value (bool req_int = false, |
903 bool frc_str_conv = false, | |
904 bool frc_vec_conv = false) const; | |
905 | |
8811 | 906 Array<octave_idx_type> |
907 octave_idx_type_vector_value (bool req_int = false, | |
908 bool frc_str_conv = false, | |
909 bool frc_vec_conv = false) const; | |
910 | |
3419 | 911 Array<double> vector_value (bool frc_str_conv = false, |
912 bool frc_vec_conv = false) const; | |
913 | |
914 Array<Complex> complex_vector_value (bool frc_str_conv = false, | |
915 bool frc_vec_conv = false) const; | |
916 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
917 Array<float> float_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
918 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
919 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
920 Array<FloatComplex> float_complex_vector_value (bool frc_str_conv = false, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
921 bool frc_vec_conv = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
922 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
923 // Possibly economize a lazy-indexed value. |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
924 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
925 void maybe_economize (void) |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
926 { rep->maybe_economize (); } |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
927 |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
928 // The following two hook conversions are called on any octave_value prior to |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
929 // storing it to a "permanent" location, like a named variable, a cell or a |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
930 // struct component, or a return value of a function. |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
931 |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
932 octave_value storable_value (void) const; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
933 |
8531
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
934 // Ditto, but in place, i.e. equivalent to *this = this->storable_value (), |
b01fef323c24
add some explaining comments
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
935 // but possibly more efficient. |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
936 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
937 void make_storable_value (void); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8017
diff
changeset
|
938 |
2376 | 939 // Conversions. These should probably be private. If a user of this |
940 // class wants a certain kind of constant, he should simply ask for | |
941 // it, and we should convert it if possible. | |
942 | |
5279 | 943 octave_value convert_to_str (bool pad = false, bool force = false, |
5759 | 944 char type = '"') const |
945 { return rep->convert_to_str (pad, force, type); } | |
4452 | 946 |
5759 | 947 octave_value |
5279 | 948 convert_to_str_internal (bool pad, bool force, char type) const |
949 { return rep->convert_to_str_internal (pad, force, type); } | |
2376 | 950 |
5759 | 951 void convert_to_row_or_column_vector (void) |
2376 | 952 { rep->convert_to_row_or_column_vector (); } |
953 | |
5759 | 954 bool print_as_scalar (void) const |
4604 | 955 { return rep->print_as_scalar (); } |
956 | |
5759 | 957 void print (std::ostream& os, bool pr_as_read_syntax = false) const |
2466 | 958 { rep->print (os, pr_as_read_syntax); } |
2376 | 959 |
5759 | 960 void print_raw (std::ostream& os, |
4457 | 961 bool pr_as_read_syntax = false) const |
2903 | 962 { rep->print_raw (os, pr_as_read_syntax); } |
963 | |
5759 | 964 bool print_name_tag (std::ostream& os, const std::string& name) const |
2903 | 965 { return rep->print_name_tag (os, name); } |
2376 | 966 |
3523 | 967 void print_with_name (std::ostream& os, const std::string& name, |
5759 | 968 bool print_padding = true) const |
969 { rep->print_with_name (os, name, print_padding); } | |
2376 | 970 |
5759 | 971 int type_id (void) const { return rep->type_id (); } |
2376 | 972 |
5759 | 973 std::string type_name (void) const { return rep->type_name (); } |
974 | |
975 std::string class_name (void) const { return rep->class_name (); } | |
4612 | 976 |
3203 | 977 // Unary and binary operations. |
978 | |
6109 | 979 friend OCTINTERP_API octave_value do_unary_op (unary_op op, |
3933 | 980 const octave_value& a); |
3203 | 981 |
3933 | 982 const octave_value& do_non_const_unary_op (unary_op op); |
983 | |
984 void do_non_const_unary_op (unary_op op, const octave_value_list& idx); | |
2376 | 985 |
4247 | 986 octave_value do_non_const_unary_op (unary_op op, const std::string& type, |
4219 | 987 const std::list<octave_value_list>& idx); |
3205 | 988 |
6109 | 989 friend OCTINTERP_API octave_value do_binary_op (binary_op op, |
3933 | 990 const octave_value& a, |
991 const octave_value& b); | |
2376 | 992 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
993 friend OCTINTERP_API octave_value do_binary_op (compound_binary_op op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
994 const octave_value& a, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
995 const octave_value& b); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
996 |
6109 | 997 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a, |
4915 | 998 const octave_value& b, |
6867 | 999 const Array<octave_idx_type>& ra_idx); |
4915 | 1000 |
5759 | 1001 const octave_base_value& get_rep (void) const { return *rep; } |
3301 | 1002 |
8456
c1709a45b45b
optimize structure components access
Jaroslav Hajek <highegg@gmail.com>
parents:
8437
diff
changeset
|
1003 bool is_copy_of (const octave_value &val) const { return rep == val.rep; } |
c1709a45b45b
optimize structure components access
Jaroslav Hajek <highegg@gmail.com>
parents:
8437
diff
changeset
|
1004 |
5759 | 1005 void print_info (std::ostream& os, |
3933 | 1006 const std::string& prefix = std::string ()) const; |
1007 | |
6974 | 1008 bool save_ascii (std::ostream& os) { return rep->save_ascii (os); } |
4687 | 1009 |
6974 | 1010 bool load_ascii (std::istream& is) { return rep->load_ascii (is); } |
4687 | 1011 |
5759 | 1012 bool save_binary (std::ostream& os, bool& save_as_floats) |
4687 | 1013 { return rep->save_binary (os, save_as_floats); } |
1014 | |
5759 | 1015 bool load_binary (std::istream& is, bool swap, |
4687 | 1016 oct_mach_info::float_format fmt) |
1017 { return rep->load_binary (is, swap, fmt); } | |
1018 | |
1019 #if defined (HAVE_HDF5) | |
5759 | 1020 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) |
4687 | 1021 { return rep->save_hdf5 (loc_id, name, save_as_floats); } |
1022 | |
5759 | 1023 bool load_hdf5 (hid_t loc_id, const char *name, |
4687 | 1024 bool have_h5giterate_bug) |
1025 { return rep->load_hdf5 (loc_id, name, have_h5giterate_bug); } | |
1026 #endif | |
1027 | |
5759 | 1028 int write (octave_stream& os, int block_size, |
4944 | 1029 oct_data_conv::data_type output_type, int skip, |
1030 oct_mach_info::float_format flt_fmt) const; | |
1031 | |
5759 | 1032 octave_base_value *internal_rep (void) const { return rep; } |
4901 | 1033 |
5900 | 1034 // Unsafe. These functions exist to support the MEX interface. |
1035 // You should not use them anywhere else. | |
1036 void *mex_get_data (void) const { return rep->mex_get_data (); } | |
1037 | |
1038 octave_idx_type *mex_get_ir (void) const { return rep->mex_get_ir (); } | |
1039 | |
1040 octave_idx_type *mex_get_jc (void) const { return rep->mex_get_jc (); } | |
1041 | |
1042 mxArray *as_mxArray (void) const { return rep->as_mxArray (); } | |
1043 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
1044 octave_value diag (octave_idx_type k = 0) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
1045 { return rep->diag (k); } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
1046 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1047 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 1048 { return rep->sort (dim, mode); } |
1049 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1050 sortmode mode = ASCENDING) const |
7433 | 1051 { return rep->sort (sidx, dim, mode); } |
1052 | |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1053 sortmode is_sorted (sortmode mode = UNSORTED) const |
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1054 { return rep->is_sorted (mode); } |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8676
diff
changeset
|
1055 |
8733
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
1056 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const |
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
1057 { return rep->sort_rows_idx (mode); } |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8676
diff
changeset
|
1058 |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1059 sortmode is_sorted_rows (sortmode mode = UNSORTED) const |
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1060 { return rep->is_sorted_rows (mode); } |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8676
diff
changeset
|
1061 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1062 void lock (void) { rep->lock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1063 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1064 void unlock (void) { rep->unlock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1065 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1066 bool islocked (void) const { return rep->islocked (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
1067 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1068 void dump (std::ostream& os) const { rep->dump (os); } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1069 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1070 #define MAPPER_FORWARD(F) \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1071 octave_value F (void) const { return rep->F (); } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1072 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1073 MAPPER_FORWARD (abs) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1074 MAPPER_FORWARD (acos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1075 MAPPER_FORWARD (acosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1076 MAPPER_FORWARD (angle) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1077 MAPPER_FORWARD (arg) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1078 MAPPER_FORWARD (asin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1079 MAPPER_FORWARD (asinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1080 MAPPER_FORWARD (atan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1081 MAPPER_FORWARD (atanh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1082 MAPPER_FORWARD (ceil) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1083 MAPPER_FORWARD (conj) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1084 MAPPER_FORWARD (cos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1085 MAPPER_FORWARD (cosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1086 MAPPER_FORWARD (erf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1087 MAPPER_FORWARD (erfc) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1088 MAPPER_FORWARD (exp) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1089 MAPPER_FORWARD (expm1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1090 MAPPER_FORWARD (finite) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1091 MAPPER_FORWARD (fix) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1092 MAPPER_FORWARD (floor) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1093 MAPPER_FORWARD (gamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1094 MAPPER_FORWARD (imag) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1095 MAPPER_FORWARD (isinf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1096 MAPPER_FORWARD (isna) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1097 MAPPER_FORWARD (isnan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1098 MAPPER_FORWARD (lgamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1099 MAPPER_FORWARD (log) |
7740 | 1100 MAPPER_FORWARD (log2) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1101 MAPPER_FORWARD (log10) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1102 MAPPER_FORWARD (log1p) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1103 MAPPER_FORWARD (real) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1104 MAPPER_FORWARD (round) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
1105 MAPPER_FORWARD (roundb) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1106 MAPPER_FORWARD (signum) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1107 MAPPER_FORWARD (sin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1108 MAPPER_FORWARD (sinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1109 MAPPER_FORWARD (sqrt) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1110 MAPPER_FORWARD (tan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1111 MAPPER_FORWARD (tanh) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1112 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1113 // These functions are prefixed with X to avoid potential macro |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1114 // conflicts. |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1115 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1116 MAPPER_FORWARD (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1117 MAPPER_FORWARD (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1118 MAPPER_FORWARD (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1119 MAPPER_FORWARD (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1120 MAPPER_FORWARD (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1121 MAPPER_FORWARD (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1122 MAPPER_FORWARD (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1123 MAPPER_FORWARD (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1124 MAPPER_FORWARD (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1125 MAPPER_FORWARD (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1126 MAPPER_FORWARD (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1127 MAPPER_FORWARD (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1128 MAPPER_FORWARD (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1129 MAPPER_FORWARD (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1130 MAPPER_FORWARD (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1131 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1132 #undef MAPPER_FORWARD |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1133 |
2376 | 1134 protected: |
1135 | |
5759 | 1136 // The real representation. |
1137 octave_base_value *rep; | |
2413 | 1138 |
3933 | 1139 private: |
2903 | 1140 |
3205 | 1141 assign_op unary_op_to_assign_op (unary_op op); |
1142 | |
3204 | 1143 binary_op op_eq_to_binary_op (assign_op op); |
1144 | |
9521 | 1145 // This declaration protects against constructing octave_value from |
1146 // const octave_base_value* which actually silently calls octave_value (bool). | |
1147 octave_value (const octave_base_value *); | |
1148 | |
3219 | 1149 DECLARE_OCTAVE_ALLOCATOR |
2376 | 1150 }; |
1151 | |
5508 | 1152 // Publish externally used friend functions. |
1153 | |
6109 | 1154 extern OCTINTERP_API octave_value |
5508 | 1155 do_unary_op (octave_value::unary_op op, const octave_value& a); |
1156 | |
6109 | 1157 extern OCTINTERP_API octave_value |
5508 | 1158 do_binary_op (octave_value::binary_op op, |
1159 const octave_value& a, const octave_value& b); | |
1160 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1161 extern OCTINTERP_API octave_value |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1162 do_binary_op (octave_value::compound_binary_op op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1163 const octave_value& a, const octave_value& b); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1164 |
3203 | 1165 #define OV_UNOP_FN(name) \ |
1166 inline octave_value \ | |
1167 name (const octave_value& a) \ | |
1168 { \ | |
1169 return do_unary_op (octave_value::name, a); \ | |
1170 } | |
1171 | |
1172 #define OV_UNOP_OP(name, op) \ | |
1173 inline octave_value \ | |
1174 operator op (const octave_value& a) \ | |
1175 { \ | |
1176 return name (a); \ | |
1177 } | |
1178 | |
1179 #define OV_UNOP_FN_OP(name, op) \ | |
1180 OV_UNOP_FN (name) \ | |
1181 OV_UNOP_OP (name, op) | |
1182 | |
3525 | 1183 OV_UNOP_FN_OP (op_not, !) |
6518 | 1184 OV_UNOP_FN_OP (op_uplus, +) |
3525 | 1185 OV_UNOP_FN_OP (op_uminus, -) |
3203 | 1186 |
3525 | 1187 OV_UNOP_FN (op_transpose) |
1188 OV_UNOP_FN (op_hermitian) | |
3203 | 1189 |
1190 // No simple way to define these for prefix and suffix ops? | |
1191 // | |
1192 // incr | |
1193 // decr | |
1194 | |
1195 #define OV_BINOP_FN(name) \ | |
1196 inline octave_value \ | |
1197 name (const octave_value& a1, const octave_value& a2) \ | |
1198 { \ | |
1199 return do_binary_op (octave_value::name, a1, a2); \ | |
1200 } | |
1201 | |
1202 #define OV_BINOP_OP(name, op) \ | |
1203 inline octave_value \ | |
1204 operator op (const octave_value& a1, const octave_value& a2) \ | |
1205 { \ | |
1206 return name (a1, a2); \ | |
1207 } | |
1208 | |
1209 #define OV_BINOP_FN_OP(name, op) \ | |
1210 OV_BINOP_FN (name) \ | |
1211 OV_BINOP_OP (name, op) | |
1212 | |
3525 | 1213 OV_BINOP_FN_OP (op_add, +) |
1214 OV_BINOP_FN_OP (op_sub, -) | |
1215 OV_BINOP_FN_OP (op_mul, *) | |
1216 OV_BINOP_FN_OP (op_div, /) | |
3203 | 1217 |
3525 | 1218 OV_BINOP_FN (op_pow) |
1219 OV_BINOP_FN (op_ldiv) | |
1220 OV_BINOP_FN (op_lshift) | |
1221 OV_BINOP_FN (op_rshift) | |
3203 | 1222 |
3525 | 1223 OV_BINOP_FN_OP (op_lt, <) |
1224 OV_BINOP_FN_OP (op_le, <=) | |
1225 OV_BINOP_FN_OP (op_eq, ==) | |
1226 OV_BINOP_FN_OP (op_ge, >=) | |
1227 OV_BINOP_FN_OP (op_gt, >) | |
1228 OV_BINOP_FN_OP (op_ne, !=) | |
3203 | 1229 |
3525 | 1230 OV_BINOP_FN (op_el_mul) |
1231 OV_BINOP_FN (op_el_div) | |
1232 OV_BINOP_FN (op_el_pow) | |
1233 OV_BINOP_FN (op_el_ldiv) | |
1234 OV_BINOP_FN (op_el_and) | |
1235 OV_BINOP_FN (op_el_or) | |
3203 | 1236 |
3525 | 1237 OV_BINOP_FN (op_struct_ref) |
3203 | 1238 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1239 #define OV_COMP_BINOP_FN(name) \ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1240 inline octave_value \ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1241 name (const octave_value& a1, const octave_value& a2) \ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1242 { \ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1243 return do_binary_op (octave_value::name, a1, a2); \ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1244 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1245 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1246 OV_COMP_BINOP_FN (op_trans_mul) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1247 OV_COMP_BINOP_FN (op_mul_trans) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1248 OV_COMP_BINOP_FN (op_herm_mul) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1249 OV_COMP_BINOP_FN (op_mul_herm) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
1250 |
6109 | 1251 extern OCTINTERP_API void install_types (void); |
2376 | 1252 |
5775 | 1253 // FIXME -- these trait classes probably belong somehwere else... |
4946 | 1254 |
1255 template <typename T> | |
1256 class | |
1257 octave_type_traits | |
1258 { | |
1259 public: | |
1260 typedef T val_type; | |
1261 }; | |
1262 | |
1263 #define OCTAVE_TYPE_TRAIT(T, VAL_T) \ | |
1264 template <> \ | |
1265 class \ | |
1266 octave_type_traits<T> \ | |
1267 { \ | |
1268 public: \ | |
1269 typedef VAL_T val_type; \ | |
1270 } | |
1271 | |
1272 OCTAVE_TYPE_TRAIT (octave_int8, octave_int8::val_type); | |
1273 OCTAVE_TYPE_TRAIT (octave_uint8, octave_uint8::val_type); | |
1274 OCTAVE_TYPE_TRAIT (octave_int16, octave_int16::val_type); | |
1275 OCTAVE_TYPE_TRAIT (octave_uint16, octave_uint16::val_type); | |
1276 OCTAVE_TYPE_TRAIT (octave_int32, octave_int32::val_type); | |
1277 OCTAVE_TYPE_TRAIT (octave_uint32, octave_uint32::val_type); | |
1278 OCTAVE_TYPE_TRAIT (octave_int64, octave_int64::val_type); | |
1279 OCTAVE_TYPE_TRAIT (octave_uint64, octave_uint64::val_type); | |
1280 | |
1281 template <typename T> | |
1282 class octave_array_type_traits | |
1283 { | |
1284 public: | |
1285 typedef T element_type; | |
1286 }; | |
1287 | |
1288 #define OCTAVE_ARRAY_TYPE_TRAIT(T, ELT_T) \ | |
1289 template <> \ | |
1290 class \ | |
1291 octave_array_type_traits<T> \ | |
1292 { \ | |
1293 public: \ | |
1294 typedef ELT_T element_type; \ | |
1295 } | |
1296 | |
1297 OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char); | |
4970 | 1298 OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool); |
4946 | 1299 OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8); |
1300 OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8); | |
1301 OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16); | |
1302 OCTAVE_ARRAY_TYPE_TRAIT (uint16NDArray, octave_uint16); | |
1303 OCTAVE_ARRAY_TYPE_TRAIT (int32NDArray, octave_int32); | |
1304 OCTAVE_ARRAY_TYPE_TRAIT (uint32NDArray, octave_uint32); | |
1305 OCTAVE_ARRAY_TYPE_TRAIT (int64NDArray, octave_int64); | |
1306 OCTAVE_ARRAY_TYPE_TRAIT (uint64NDArray, octave_uint64); | |
1307 OCTAVE_ARRAY_TYPE_TRAIT (NDArray, double); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1308 OCTAVE_ARRAY_TYPE_TRAIT (FloatNDArray, float); |
4946 | 1309 |
5759 | 1310 // This will eventually go away, but for now it can be used to |
1311 // simplify the transition to the new octave_value class hierarchy, | |
1312 // which uses octave_base_value instead of octave_value for the type | |
1313 // of octave_value::rep. | |
1314 #define OV_REP_TYPE octave_base_value | |
1315 | |
9657
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1316 // Templated value extractors. |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1317 template<class Value> |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1318 inline Value octave_value_extract (const octave_value&) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1319 { assert (false); } |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1320 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1321 #define DEF_VALUE_EXTRACTOR(VALUE,MPREFIX) \ |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1322 template<> \ |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1323 inline VALUE octave_value_extract<VALUE> (const octave_value& v) \ |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1324 { return v.MPREFIX ## _value (); } |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1325 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1326 DEF_VALUE_EXTRACTOR (double, scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1327 DEF_VALUE_EXTRACTOR (float, float_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1328 DEF_VALUE_EXTRACTOR (Complex, complex) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1329 DEF_VALUE_EXTRACTOR (FloatComplex, float_complex) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1330 DEF_VALUE_EXTRACTOR (bool, bool) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1331 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1332 DEF_VALUE_EXTRACTOR (octave_int8, int8_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1333 DEF_VALUE_EXTRACTOR (octave_int16, int16_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1334 DEF_VALUE_EXTRACTOR (octave_int32, int32_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1335 DEF_VALUE_EXTRACTOR (octave_int64, int64_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1336 DEF_VALUE_EXTRACTOR (octave_uint8, uint8_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1337 DEF_VALUE_EXTRACTOR (octave_uint16, uint16_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1338 DEF_VALUE_EXTRACTOR (octave_uint32, uint32_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1339 DEF_VALUE_EXTRACTOR (octave_uint64, uint64_scalar) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1340 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1341 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1342 DEF_VALUE_EXTRACTOR (NDArray, array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1343 DEF_VALUE_EXTRACTOR (FloatNDArray, float_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1344 DEF_VALUE_EXTRACTOR (ComplexNDArray, complex_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1345 DEF_VALUE_EXTRACTOR (FloatComplexNDArray, float_complex_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1346 DEF_VALUE_EXTRACTOR (boolNDArray, bool_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1347 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1348 DEF_VALUE_EXTRACTOR (charNDArray, char_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1349 DEF_VALUE_EXTRACTOR (int8NDArray, int8_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1350 DEF_VALUE_EXTRACTOR (int16NDArray, int16_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1351 DEF_VALUE_EXTRACTOR (int32NDArray, int32_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1352 DEF_VALUE_EXTRACTOR (int64NDArray, int64_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1353 DEF_VALUE_EXTRACTOR (uint8NDArray, uint8_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1354 DEF_VALUE_EXTRACTOR (uint16NDArray, uint16_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1355 DEF_VALUE_EXTRACTOR (uint32NDArray, uint32_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1356 DEF_VALUE_EXTRACTOR (uint64NDArray, uint64_array) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1357 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1358 DEF_VALUE_EXTRACTOR (Matrix, matrix) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1359 DEF_VALUE_EXTRACTOR (FloatMatrix, float_matrix) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1360 DEF_VALUE_EXTRACTOR (ComplexMatrix, complex_matrix) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1361 DEF_VALUE_EXTRACTOR (FloatComplexMatrix, float_complex_matrix) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1362 DEF_VALUE_EXTRACTOR (boolMatrix, bool_matrix) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1363 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1364 DEF_VALUE_EXTRACTOR (ColumnVector, column_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1365 DEF_VALUE_EXTRACTOR (FloatColumnVector, float_column_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1366 DEF_VALUE_EXTRACTOR (ComplexColumnVector, complex_column_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1367 DEF_VALUE_EXTRACTOR (FloatComplexColumnVector, float_complex_column_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1368 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1369 DEF_VALUE_EXTRACTOR (RowVector, row_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1370 DEF_VALUE_EXTRACTOR (FloatRowVector, float_row_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1371 DEF_VALUE_EXTRACTOR (ComplexRowVector, complex_row_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1372 DEF_VALUE_EXTRACTOR (FloatComplexRowVector, float_complex_row_vector) |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1373 |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1374 #undef DEF_VALUE_EXTRACTOR |
3c1c3a38ec7b
implement templated octave_value extractor
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1375 |
2376 | 1376 #endif |
1377 | |
1378 /* | |
6705 | 1379 ;;; Local Variables: *** |
1380 ;;; mode: C++ *** | |
1381 ;;; End: *** | |
2376 | 1382 */ |