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