Mercurial > octave-nkf
annotate src/ov-base.h @ 8551:906f976d35a8
further improve struct&cell indexing & indexed assignment
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 21 Jan 2009 13:02:49 +0100 |
parents | ad3afaaa19c1 |
children | 73c4516fae10 |
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_base_value_h) | |
25 #define octave_base_value_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
3503 | 29 #include <iostream> |
5759 | 30 #include <list> |
2376 | 31 #include <string> |
32 | |
5759 | 33 #if defined (HAVE_HDF5) |
34 #include <hdf5.h> | |
35 #endif | |
36 | |
37 #include "Range.h" | |
5828 | 38 #include "data-conv.h" |
5900 | 39 #include "mxarray.h" |
2376 | 40 #include "mx-base.h" |
41 #include "str-vec.h" | |
42 | |
43 #include "error.h" | |
44 | |
3351 | 45 class Cell; |
2376 | 46 class Octave_map; |
5759 | 47 class octave_value; |
2376 | 48 class octave_value_list; |
5759 | 49 class octave_stream; |
50 class octave_function; | |
51 class octave_user_function; | |
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
|
52 class octave_user_script; |
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
|
53 class octave_user_code; |
5759 | 54 class octave_fcn_handle; |
55 class octave_fcn_inline; | |
56 class octave_value_list; | |
57 class octave_lvalue; | |
2376 | 58 |
59 class tree_walker; | |
60 | |
5759 | 61 // T_ID is the type id of struct objects, set by register_type(). |
62 // T_NAME is the type name of struct objects. | |
7067 | 63 |
5759 | 64 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \ |
7066 | 65 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 (OCTAVE_EMPTY_CPP_ARG) |
5759 | 66 |
67 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA \ | |
68 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual) | |
69 | |
70 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(VIRTUAL) \ | |
71 public: \ | |
72 VIRTUAL int type_id (void) const { return t_id; } \ | |
73 VIRTUAL std::string type_name (void) const { return t_name; } \ | |
74 VIRTUAL std::string class_name (void) const { return c_name; } \ | |
75 static int static_type_id (void) { return t_id; } \ | |
76 static std::string static_type_name (void) { return t_name; } \ | |
77 static std::string static_class_name (void) { return c_name; } \ | |
78 static void register_type (void); \ | |
79 \ | |
80 private: \ | |
81 static int t_id; \ | |
82 static const std::string t_name; \ | |
83 static const std::string c_name; | |
84 | |
85 | |
86 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \ | |
87 int t::t_id (-1); \ | |
88 const std::string t::t_name (n); \ | |
89 const std::string t::c_name (c); \ | |
90 void t::register_type (void) \ | |
91 { \ | |
92 t_id = octave_value_typeinfo::register_type (t::t_name, \ | |
93 t::c_name, \ | |
94 octave_value (new t ())); \ | |
95 } | |
96 | |
2477 | 97 // A base value type, so that derived types only have to redefine what |
98 // they need (if they are derived from octave_base_value instead of | |
99 // octave_value). | |
2376 | 100 |
101 class | |
6109 | 102 OCTINTERP_API |
5759 | 103 octave_base_value |
2376 | 104 { |
105 public: | |
106 | |
5759 | 107 typedef octave_base_value * (*type_conv_fcn) (const octave_base_value&); |
108 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
109 // type conversion, including result type information |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
110 class type_conv_info |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
111 { |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
112 public: |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
113 type_conv_info (type_conv_fcn f = 0, int t = -1) : _fcn (f), _type_id (t) { } |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
114 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
115 operator type_conv_fcn (void) const { return _fcn; } |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
116 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
117 octave_base_value * operator () (const octave_base_value &v) const |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
118 { return (*_fcn) (v); } |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
119 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
120 int type_id (void) const { return _type_id; } |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
121 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
122 private: |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
123 type_conv_fcn _fcn; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
124 int _type_id; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
125 }; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
126 |
5759 | 127 friend class octave_value; |
2376 | 128 |
5759 | 129 octave_base_value (void) : count (1) { } |
130 | |
131 octave_base_value (const octave_base_value&) { } | |
2376 | 132 |
5759 | 133 virtual ~octave_base_value (void) { } |
134 | |
135 virtual octave_base_value * | |
136 clone (void) const { return new octave_base_value (*this); } | |
2376 | 137 |
5759 | 138 virtual octave_base_value * |
139 empty_clone (void) const { return new octave_base_value (); } | |
2376 | 140 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
141 virtual type_conv_info |
5759 | 142 numeric_conversion_function (void) const |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
143 { return type_conv_info (); } |
2410 | 144 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
145 virtual type_conv_info |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
146 numeric_demotion_function (void) const |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
147 { return type_conv_info (); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
148 |
5759 | 149 virtual octave_value squeeze (void) const; |
150 | |
8458
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8437
diff
changeset
|
151 virtual octave_value full_value (void) const; |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8437
diff
changeset
|
152 |
5759 | 153 virtual octave_base_value *try_narrowing_conversion (void) { return 0; } |
4532 | 154 |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
155 virtual void maybe_economize (void) { } |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
156 |
5759 | 157 virtual octave_value |
158 subsref (const std::string& type, | |
159 const std::list<octave_value_list>& idx); | |
3933 | 160 |
5759 | 161 virtual octave_value_list |
162 subsref (const std::string& type, | |
163 const std::list<octave_value_list>& idx, | |
164 int nargout); | |
3933 | 165 |
5759 | 166 virtual octave_value |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
167 subsref (const std::string& type, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
168 const std::list<octave_value_list>& idx, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
169 bool auto_add); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
170 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
171 virtual octave_value |
5885 | 172 do_index_op (const octave_value_list& idx, bool resize_ok = false); |
2974 | 173 |
5759 | 174 virtual octave_value_list |
3544 | 175 do_multi_index_op (int nargout, const octave_value_list& idx); |
2376 | 176 |
5759 | 177 virtual octave_value |
178 subsasgn (const std::string& type, | |
179 const std::list<octave_value_list>& idx, | |
180 const octave_value& rhs); | |
2376 | 181 |
5759 | 182 virtual idx_vector index_vector (void) const; |
2376 | 183 |
5759 | 184 virtual dim_vector dims (void) const { return dim_vector (-1, -1); } |
4559 | 185 |
5759 | 186 octave_idx_type rows (void) const |
187 { | |
188 dim_vector dv = dims (); | |
5164 | 189 |
5759 | 190 return (dv.length () > 0) ? dv(0) : -1; |
191 } | |
4791 | 192 |
5759 | 193 octave_idx_type columns (void) const |
194 { | |
195 dim_vector dv = dims (); | |
5602 | 196 |
5759 | 197 return (dv.length () > 1) ? dv(1) : -1; |
198 } | |
5604 | 199 |
5759 | 200 virtual int ndims (void) const; |
4567 | 201 |
5759 | 202 virtual octave_idx_type numel (void) const { return dims ().numel (); } |
4593 | 203 |
5759 | 204 virtual octave_idx_type capacity (void) const { return numel (); } |
205 | |
206 virtual size_t byte_size (void) const { return 0; } | |
4915 | 207 |
5759 | 208 virtual octave_idx_type nnz (void) const; |
2376 | 209 |
5759 | 210 virtual octave_idx_type nzmax (void) const; |
211 | |
5900 | 212 virtual octave_idx_type nfields (void) const; |
213 | |
5759 | 214 virtual octave_value reshape (const dim_vector&) const; |
3351 | 215 |
5759 | 216 virtual octave_value permute (const Array<int>& vec, bool = false) const; |
2376 | 217 |
5759 | 218 virtual octave_value resize (const dim_vector&, bool fill = false) const; |
2376 | 219 |
5785 | 220 virtual MatrixType matrix_type (void) const; |
221 | |
222 virtual MatrixType matrix_type (const MatrixType& typ) const; | |
223 | |
5759 | 224 virtual bool is_defined (void) const { return false; } |
4505 | 225 |
5759 | 226 bool is_empty (void) const { return numel () == 0; } |
2376 | 227 |
5759 | 228 virtual bool is_cell (void) const { return false; } |
2376 | 229 |
6116 | 230 virtual bool is_cellstr (void) const { return false; } |
231 | |
5759 | 232 virtual bool is_real_scalar (void) const { return false; } |
4587 | 233 |
5759 | 234 virtual bool is_real_matrix (void) const { return false; } |
235 | |
236 virtual bool is_real_nd_array (void) const { return false; } | |
2376 | 237 |
5759 | 238 virtual bool is_complex_scalar (void) const { return false; } |
2376 | 239 |
5759 | 240 virtual bool is_complex_matrix (void) const { return false; } |
241 | |
5881 | 242 virtual bool is_bool_scalar (void) const { return false; } |
243 | |
5759 | 244 virtual bool is_bool_matrix (void) const { return false; } |
5279 | 245 |
5759 | 246 virtual bool is_char_matrix (void) const { return false; } |
2376 | 247 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
248 virtual bool is_diag_matrix (void) const { return false; } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
249 |
8371
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
250 virtual bool is_perm_matrix (void) const { return false; } |
c3f7e2549abb
make det & inv aware of diagonal & permutation matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
251 |
5759 | 252 virtual bool is_string (void) const { return false; } |
2376 | 253 |
5759 | 254 virtual bool is_sq_string (void) const { return false; } |
4643 | 255 |
5759 | 256 virtual bool is_range (void) const { return false; } |
3977 | 257 |
5759 | 258 virtual bool is_map (void) const { return false; } |
259 | |
7336 | 260 virtual bool is_object (void) const { return false; } |
261 | |
5759 | 262 virtual bool is_cs_list (void) const { return false; } |
2376 | 263 |
5759 | 264 virtual bool is_list (void) const { return false; } |
265 | |
266 virtual bool is_magic_colon (void) const { return false; } | |
2376 | 267 |
5759 | 268 virtual bool is_all_va_args (void) const { return false; } |
2376 | 269 |
5759 | 270 virtual octave_value all (int = 0) const; |
271 | |
272 virtual octave_value any (int = 0) const; | |
2376 | 273 |
5895 | 274 virtual bool is_double_type (void) const { return false; } |
275 | |
276 virtual bool is_single_type (void) const { return false; } | |
277 | |
7576 | 278 virtual bool is_float_type (void) const { return false; } |
279 | |
5895 | 280 virtual bool is_int8_type (void) const { return false; } |
281 | |
282 virtual bool is_int16_type (void) const { return false; } | |
283 | |
284 virtual bool is_int32_type (void) const { return false; } | |
285 | |
286 virtual bool is_int64_type (void) const { return false; } | |
287 | |
288 virtual bool is_uint8_type (void) const { return false; } | |
289 | |
290 virtual bool is_uint16_type (void) const { return false; } | |
291 | |
292 virtual bool is_uint32_type (void) const { return false; } | |
293 | |
294 virtual bool is_uint64_type (void) const { return false; } | |
295 | |
5759 | 296 virtual bool is_bool_type (void) const { return false; } |
3209 | 297 |
6223 | 298 virtual bool is_integer_type (void) const { return false; } |
299 | |
5759 | 300 virtual bool is_real_type (void) const { return false; } |
2376 | 301 |
5759 | 302 virtual bool is_complex_type (void) const { return false; } |
2376 | 303 |
304 // Would be nice to get rid of the next four functions: | |
305 | |
5759 | 306 virtual bool is_scalar_type (void) const { return false; } |
2376 | 307 |
5759 | 308 virtual bool is_matrix_type (void) const { return false; } |
2376 | 309 |
5759 | 310 virtual bool is_numeric_type (void) const { return false; } |
2376 | 311 |
5759 | 312 virtual bool is_sparse_type (void) const { return false; } |
5631 | 313 |
5759 | 314 virtual bool is_true (void) const { return false; } |
315 | |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
316 virtual bool is_null_value (void) const { return false; } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
317 |
5759 | 318 virtual bool is_constant (void) const { return false; } |
2376 | 319 |
5759 | 320 virtual bool is_function_handle (void) const { return false; } |
2376 | 321 |
5759 | 322 virtual bool is_inline_function (void) const { return false; } |
2974 | 323 |
5759 | 324 virtual bool is_function (void) const { return false; } |
4954 | 325 |
7336 | 326 virtual bool is_user_script (void) const { return false; } |
327 | |
328 virtual bool is_user_function (void) const { return false; } | |
329 | |
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
|
330 virtual bool is_user_code (void) const { return 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
|
331 |
5759 | 332 virtual bool is_builtin_function (void) const { return false; } |
2974 | 333 |
5759 | 334 virtual bool is_dld_function (void) const { return false; } |
3325 | 335 |
5864 | 336 virtual bool is_mex_function (void) const { return false; } |
337 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
338 virtual void erase_subfunctions (void) { } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
339 |
5759 | 340 virtual short int short_value (bool = false, bool = false) const; |
4254 | 341 |
5759 | 342 virtual unsigned short int ushort_value (bool = false, bool = false) const; |
4254 | 343 |
5759 | 344 virtual int int_value (bool = false, bool = false) const; |
3202 | 345 |
5759 | 346 virtual unsigned int uint_value (bool = false, bool = false) const; |
4254 | 347 |
5759 | 348 virtual int nint_value (bool = false) const; |
3202 | 349 |
5759 | 350 virtual long int long_value (bool = false, bool = false) const; |
4254 | 351 |
5759 | 352 virtual unsigned long int ulong_value (bool = false, bool = false) const; |
4254 | 353 |
5759 | 354 virtual double double_value (bool = false) const; |
2376 | 355 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
356 virtual float float_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
357 |
5759 | 358 virtual double scalar_value (bool frc_str_conv = false) const |
3145 | 359 { return double_value (frc_str_conv); } |
2376 | 360 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
361 virtual 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
|
362 { return float_value (frc_str_conv); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
363 |
5759 | 364 virtual Cell cell_value (void) const; |
3351 | 365 |
5759 | 366 virtual Matrix matrix_value (bool = false) const; |
3145 | 367 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
368 virtual FloatMatrix float_matrix_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
369 |
5759 | 370 virtual NDArray array_value (bool = false) const; |
4505 | 371 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
372 virtual FloatNDArray float_array_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
373 |
5759 | 374 virtual Complex complex_value (bool = false) const; |
2376 | 375 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
376 virtual FloatComplex float_complex_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
377 |
5759 | 378 virtual ComplexMatrix complex_matrix_value (bool = false) const; |
2376 | 379 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
380 virtual FloatComplexMatrix float_complex_matrix_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
381 |
5759 | 382 virtual ComplexNDArray complex_array_value (bool = false) const; |
4550 | 383 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
384 virtual FloatComplexNDArray float_complex_array_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
385 |
5943 | 386 virtual bool bool_value (bool = false) const; |
4550 | 387 |
5943 | 388 virtual boolMatrix bool_matrix_value (bool = false) const; |
4550 | 389 |
5943 | 390 virtual boolNDArray bool_array_value (bool = false) const; |
4550 | 391 |
5759 | 392 virtual charMatrix char_matrix_value (bool force = false) const; |
393 | |
394 virtual charNDArray char_array_value (bool = false) const; | |
2376 | 395 |
5759 | 396 virtual SparseMatrix sparse_matrix_value (bool = false) const; |
4550 | 397 |
5759 | 398 virtual SparseComplexMatrix sparse_complex_matrix_value (bool = false) const; |
5164 | 399 |
5759 | 400 virtual SparseBoolMatrix sparse_bool_matrix_value (bool = false) const; |
5164 | 401 |
5759 | 402 virtual octave_int8 int8_scalar_value (void) const; |
5164 | 403 |
5759 | 404 virtual octave_int16 int16_scalar_value (void) const; |
4910 | 405 |
5759 | 406 virtual octave_int32 int32_scalar_value (void) const; |
407 | |
408 virtual octave_int64 int64_scalar_value (void) const; | |
4910 | 409 |
5759 | 410 virtual octave_uint8 uint8_scalar_value (void) const; |
4910 | 411 |
5759 | 412 virtual octave_uint16 uint16_scalar_value (void) const; |
4910 | 413 |
5759 | 414 virtual octave_uint32 uint32_scalar_value (void) const; |
4910 | 415 |
5759 | 416 virtual octave_uint64 uint64_scalar_value (void) const; |
4910 | 417 |
5759 | 418 virtual int8NDArray int8_array_value (void) const; |
4910 | 419 |
5759 | 420 virtual int16NDArray int16_array_value (void) const; |
4910 | 421 |
5759 | 422 virtual int32NDArray int32_array_value (void) const; |
4906 | 423 |
5759 | 424 virtual int64NDArray int64_array_value (void) const; |
4906 | 425 |
5759 | 426 virtual uint8NDArray uint8_array_value (void) const; |
4906 | 427 |
5759 | 428 virtual uint16NDArray uint16_array_value (void) const; |
4906 | 429 |
5759 | 430 virtual uint32NDArray uint32_array_value (void) const; |
4906 | 431 |
5759 | 432 virtual uint64NDArray uint64_array_value (void) const; |
4906 | 433 |
5759 | 434 virtual string_vector all_strings (bool pad = false) const; |
4906 | 435 |
5759 | 436 virtual std::string string_value (bool force = false) const; |
4906 | 437 |
5759 | 438 virtual Range range_value (void) const; |
2376 | 439 |
5759 | 440 virtual Octave_map map_value (void) const; |
2376 | 441 |
5759 | 442 virtual string_vector map_keys (void) const; |
2376 | 443 |
5759 | 444 virtual octave_function *function_value (bool silent = false); |
3933 | 445 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
446 virtual const octave_function *function_value (bool silent = false) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
447 |
5759 | 448 virtual octave_user_function *user_function_value (bool silent = false); |
4645 | 449 |
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
|
450 virtual 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
|
451 |
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
|
452 virtual 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
|
453 |
5759 | 454 virtual octave_fcn_handle *fcn_handle_value (bool silent = false); |
4643 | 455 |
5759 | 456 virtual octave_fcn_inline *fcn_inline_value (bool silent = false); |
2974 | 457 |
5759 | 458 virtual octave_value_list list_value (void) const; |
4343 | 459 |
5759 | 460 virtual octave_value convert_to_str (bool pad = false, bool force = false, |
461 char type = '"') const; | |
462 virtual octave_value | |
463 convert_to_str_internal (bool pad, bool force, char type) const; | |
4933 | 464 |
5759 | 465 virtual void convert_to_row_or_column_vector (void); |
2882 | 466 |
5759 | 467 virtual bool print_as_scalar (void) const { return false; } |
2376 | 468 |
5759 | 469 virtual void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
2376 | 470 |
5759 | 471 virtual void |
472 print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; | |
4604 | 473 |
5759 | 474 virtual bool |
475 print_name_tag (std::ostream& os, const std::string& name) const; | |
2901 | 476 |
5759 | 477 virtual void |
478 print_with_name (std::ostream& output_buf, const std::string& name, | |
479 bool print_padding = true) const; | |
2376 | 480 |
5759 | 481 virtual void print_info (std::ostream& os, const std::string& prefix) const; |
3933 | 482 |
6974 | 483 virtual bool save_ascii (std::ostream& os); |
4687 | 484 |
5759 | 485 virtual bool load_ascii (std::istream& is); |
4687 | 486 |
5759 | 487 virtual bool save_binary (std::ostream& os, bool& save_as_floats); |
4687 | 488 |
5759 | 489 virtual bool load_binary (std::istream& is, bool swap, |
490 oct_mach_info::float_format fmt); | |
4687 | 491 |
492 #if defined (HAVE_HDF5) | |
5759 | 493 virtual bool |
494 save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
4687 | 495 |
5759 | 496 virtual bool |
497 load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); | |
4687 | 498 #endif |
499 | |
5759 | 500 virtual int |
501 write (octave_stream& os, int block_size, | |
502 oct_data_conv::data_type output_type, int skip, | |
503 oct_mach_info::float_format flt_fmt) const; | |
504 | |
5900 | 505 virtual void *mex_get_data (void) const { return 0; } |
506 | |
507 virtual octave_idx_type *mex_get_ir (void) const { return 0; } | |
508 | |
509 virtual octave_idx_type *mex_get_jc (void) const { return 0; } | |
510 | |
511 virtual mxArray *as_mxArray (void) const; | |
512 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
513 virtual 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
|
514 |
7433 | 515 virtual octave_value sort (octave_idx_type dim = 0, |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
516 sortmode mode = ASCENDING) const; |
7433 | 517 virtual octave_value sort (Array<octave_idx_type> &sidx, |
518 octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
519 sortmode mode = ASCENDING) const; |
7433 | 520 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
521 virtual void lock (void); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
522 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
523 virtual void unlock (void); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
524 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
525 virtual bool islocked (void) const { return false; } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
526 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
527 virtual void dump (std::ostream& os) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
528 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
529 virtual octave_value abs (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
530 virtual octave_value acos (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
531 virtual octave_value acosh (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
532 virtual octave_value angle (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
533 virtual octave_value arg (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
534 virtual octave_value asin (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
535 virtual octave_value asinh (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
536 virtual octave_value atan (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
537 virtual octave_value atanh (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
538 virtual octave_value ceil (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
539 virtual octave_value conj (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
540 virtual octave_value cos (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
541 virtual octave_value cosh (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
542 virtual octave_value erf (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
543 virtual octave_value erfc (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
544 virtual octave_value exp (void) const; |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
545 virtual octave_value expm1 (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
546 virtual octave_value finite (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
547 virtual octave_value fix (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
548 virtual octave_value floor (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
549 virtual octave_value gamma (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
550 virtual octave_value imag (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
551 virtual octave_value isinf (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
552 virtual octave_value isna (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
553 virtual octave_value isnan (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
554 virtual octave_value lgamma (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
555 virtual octave_value log (void) const; |
7740 | 556 virtual octave_value log2 (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
557 virtual octave_value log10 (void) const; |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
558 virtual octave_value log1p (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
559 virtual octave_value real (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
560 virtual octave_value round (void) const; |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
561 virtual octave_value roundb (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
562 virtual octave_value signum (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
563 virtual octave_value sin (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
564 virtual octave_value sinh (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
565 virtual octave_value sqrt (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
566 virtual octave_value tan (void) const; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
567 virtual octave_value tanh (void) const; |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
568 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
569 // 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
|
570 // conflicts. |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
571 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
572 virtual octave_value xisalnum (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
573 virtual octave_value xisalpha (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
574 virtual octave_value xisascii (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
575 virtual octave_value xiscntrl (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
576 virtual octave_value xisdigit (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
577 virtual octave_value xisgraph (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
578 virtual octave_value xislower (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
579 virtual octave_value xisprint (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
580 virtual octave_value xispunct (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
581 virtual octave_value xisspace (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
582 virtual octave_value xisupper (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
583 virtual octave_value xisxdigit (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
584 virtual octave_value xtoascii (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
585 virtual octave_value xtolower (void) const; |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
586 virtual octave_value xtoupper (void) const; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
587 |
5759 | 588 protected: |
589 | |
590 // This should only be called for derived types. | |
591 | |
592 octave_value numeric_assign (const std::string& type, | |
593 const std::list<octave_value_list>& idx, | |
594 const octave_value& rhs); | |
595 | |
596 void reset_indent_level (void) const | |
597 { curr_print_indent_level = 0; } | |
598 | |
599 void increment_indent_level (void) const | |
600 { curr_print_indent_level += 2; } | |
601 | |
602 void decrement_indent_level (void) const | |
603 { curr_print_indent_level -= 2; } | |
604 | |
605 int current_print_indent_level (void) const | |
606 { return curr_print_indent_level; } | |
607 | |
608 void indent (std::ostream& os) const; | |
609 | |
610 void newline (std::ostream& os) const; | |
611 | |
612 void reset (void) const; | |
613 | |
614 // A reference count. | |
615 int count; | |
4944 | 616 |
2376 | 617 private: |
618 | |
5759 | 619 static int curr_print_indent_level; |
620 static bool beginning_of_line; | |
621 | |
622 DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA | |
2376 | 623 }; |
624 | |
7336 | 625 // If TRUE, turn off printing of results in functions (as if a |
626 // semicolon has been appended to each statement). | |
627 extern bool Vsilent_functions; | |
628 | |
7193 | 629 // TRUE means to perform automatic sparse to real mutation if there |
630 // is memory to be saved | |
631 extern bool Vsparse_auto_mutate; | |
632 | |
2376 | 633 #endif |
634 | |
635 /* | |
636 ;;; Local Variables: *** | |
637 ;;; mode: C++ *** | |
638 ;;; End: *** | |
639 */ |