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