Mercurial > octave
annotate src/ov-base.cc @ 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 | d254a21e0120 |
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 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
4254 | 28 #include <climits> |
29 | |
3503 | 30 #include <iostream> |
2901 | 31 |
2376 | 32 #include "lo-ieee.h" |
4732 | 33 #include "lo-mappers.h" |
2376 | 34 |
5759 | 35 #include "defun.h" |
2376 | 36 #include "gripes.h" |
37 #include "oct-map.h" | |
2974 | 38 #include "oct-obj.h" |
2979 | 39 #include "oct-lvalue.h" |
3340 | 40 #include "oct-stream.h" |
2376 | 41 #include "ops.h" |
42 #include "ov-base.h" | |
3928 | 43 #include "ov-cell.h" |
44 #include "ov-ch-mat.h" | |
2376 | 45 #include "ov-complex.h" |
46 #include "ov-cx-mat.h" | |
3928 | 47 #include "ov-list.h" |
48 #include "ov-range.h" | |
49 #include "ov-re-mat.h" | |
50 #include "ov-scalar.h" | |
2376 | 51 #include "ov-str-mat.h" |
4343 | 52 #include "ov-fcn-handle.h" |
5759 | 53 #include "parse.h" |
54 #include "utils.h" | |
2948 | 55 #include "variables.h" |
2376 | 56 |
4612 | 57 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, |
58 "<unknown type>", "unknown"); | |
2376 | 59 |
5759 | 60 // If TRUE, turn off printing of results in functions (as if a |
61 // semicolon has been appended to each statement). | |
7336 | 62 bool Vsilent_functions = false; |
5759 | 63 |
7193 | 64 // TRUE means to perform automatic sparse to real mutation if there |
65 // is memory to be saved | |
66 bool Vsparse_auto_mutate = false; | |
67 | |
2376 | 68 octave_value |
4532 | 69 octave_base_value::squeeze (void) const |
70 { | |
71 std::string nm = type_name (); | |
72 error ("squeeze: invalid operation for %s type", nm.c_str ()); | |
73 return octave_value (); | |
74 } | |
75 | |
76 octave_value | |
8458
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
77 octave_base_value::full_value (void) const |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
78 { |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
79 gripe_wrong_type_arg ("full: invalid operation for %s type", type_name ()); |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
80 return octave_value (); |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
81 } |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
82 |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
83 octave_value |
4247 | 84 octave_base_value::subsref (const std::string&, |
4219 | 85 const std::list<octave_value_list>&) |
3933 | 86 { |
87 std::string nm = type_name (); | |
88 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
89 return octave_value (); | |
90 } | |
91 | |
92 octave_value_list | |
4247 | 93 octave_base_value::subsref (const std::string&, |
4219 | 94 const std::list<octave_value_list>&, int) |
3933 | 95 { |
96 std::string nm = type_name (); | |
97 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
98 return octave_value (); | |
99 } | |
100 | |
101 octave_value | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
102 octave_base_value::subsref (const std::string& type, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
103 const std::list<octave_value_list>& idx, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
104 bool auto_add) |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
105 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
106 // This way we may get a more meaningful error message. |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
107 return subsref (type, idx); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
108 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
109 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
110 octave_value |
5885 | 111 octave_base_value::do_index_op (const octave_value_list&, bool) |
2974 | 112 { |
3523 | 113 std::string nm = type_name (); |
2974 | 114 error ("can't perform indexing operations for %s type", nm.c_str ()); |
115 return octave_value (); | |
116 } | |
117 | |
118 octave_value_list | |
3544 | 119 octave_base_value::do_multi_index_op (int, const octave_value_list&) |
2376 | 120 { |
3523 | 121 std::string nm = type_name (); |
2376 | 122 error ("can't perform indexing operations for %s type", nm.c_str ()); |
123 return octave_value (); | |
124 } | |
125 | |
126 idx_vector | |
127 octave_base_value::index_vector (void) const | |
128 { | |
3523 | 129 std::string nm = type_name (); |
2376 | 130 error ("%s type invalid as index value", nm.c_str ()); |
131 return idx_vector (); | |
132 } | |
133 | |
5759 | 134 int |
135 octave_base_value::ndims (void) const | |
136 { | |
137 dim_vector dv = dims (); | |
138 | |
139 int n_dims = dv.length (); | |
140 | |
141 // Remove trailing singleton dimensions. | |
142 | |
143 for (int i = n_dims; i > 2; i--) | |
144 { | |
145 if (dv(i-1) == 1) | |
146 n_dims--; | |
147 else | |
148 break; | |
149 } | |
150 | |
151 // The result is always >= 2. | |
152 | |
153 if (n_dims < 2) | |
154 n_dims = 2; | |
155 | |
156 return n_dims; | |
157 } | |
158 | |
2376 | 159 octave_value |
4247 | 160 octave_base_value::subsasgn (const std::string& type, |
4219 | 161 const std::list<octave_value_list>& idx, |
3933 | 162 const octave_value& rhs) |
2376 | 163 { |
3933 | 164 octave_value retval; |
2376 | 165 |
3933 | 166 if (is_defined ()) |
167 { | |
4139 | 168 if (is_numeric_type ()) |
169 { | |
170 switch (type[0]) | |
171 { | |
172 case '(': | |
173 { | |
174 if (type.length () == 1) | |
175 retval = numeric_assign (type, idx, rhs); | |
4436 | 176 else if (is_empty ()) |
177 { | |
178 // Allow conversion of empty matrix to some other | |
179 // type in cases like | |
180 // | |
181 // x = []; x(i).f = rhs | |
182 | |
183 octave_value tmp = octave_value::empty_conv (type, rhs); | |
184 | |
185 retval = tmp.subsasgn (type, idx, rhs); | |
186 } | |
4139 | 187 else |
188 { | |
189 std::string nm = type_name (); | |
190 error ("in indexed assignment of %s, last rhs index must be ()", | |
191 nm.c_str ()); | |
192 } | |
193 } | |
194 break; | |
195 | |
196 case '{': | |
197 case '.': | |
198 { | |
199 std::string nm = type_name (); | |
200 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); | |
201 } | |
202 break; | |
203 | |
204 default: | |
205 panic_impossible (); | |
206 } | |
207 } | |
208 else | |
209 { | |
210 std::string nm = type_name (); | |
211 error ("can't perform indexed assignment for %s type", nm.c_str ()); | |
212 } | |
3933 | 213 } |
214 else | |
215 { | |
216 // Create new object of appropriate type for given index and rhs | |
217 // types and then call subsasgn again for that object. | |
218 | |
219 octave_value tmp = octave_value::empty_conv (type, rhs); | |
220 | |
221 retval = tmp.subsasgn (type, idx, rhs); | |
222 } | |
223 | |
224 return retval; | |
2376 | 225 } |
226 | |
5602 | 227 octave_idx_type |
228 octave_base_value::nnz (void) const | |
229 { | |
230 gripe_wrong_type_arg ("octave_base_value::nnz ()", type_name ()); | |
231 return -1; | |
232 } | |
233 | |
5604 | 234 octave_idx_type |
235 octave_base_value::nzmax (void) const | |
236 { | |
237 gripe_wrong_type_arg ("octave_base_value::nzmax ()", type_name ()); | |
238 return -1; | |
239 } | |
240 | |
5900 | 241 octave_idx_type |
242 octave_base_value::nfields (void) const | |
243 { | |
244 gripe_wrong_type_arg ("octave_base_value::nfields ()", type_name ()); | |
245 return -1; | |
246 } | |
247 | |
2376 | 248 octave_value |
4567 | 249 octave_base_value::reshape (const dim_vector&) const |
250 { | |
251 gripe_wrong_type_arg ("octave_base_value::reshape ()", type_name ()); | |
252 return octave_value (); | |
253 } | |
254 | |
255 octave_value | |
4593 | 256 octave_base_value::permute (const Array<int>&, bool) const |
257 { | |
258 gripe_wrong_type_arg ("octave_base_value::permute ()", type_name ()); | |
259 return octave_value (); | |
260 } | |
261 | |
262 octave_value | |
5731 | 263 octave_base_value::resize (const dim_vector&, bool) const |
4915 | 264 { |
265 gripe_wrong_type_arg ("octave_base_value::resize ()", type_name ()); | |
266 return octave_value (); | |
267 } | |
268 | |
5785 | 269 MatrixType |
270 octave_base_value::matrix_type (void) const | |
271 { | |
272 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
273 return MatrixType (); | |
274 } | |
275 | |
276 MatrixType | |
277 octave_base_value::matrix_type (const MatrixType&) const | |
278 { | |
279 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
280 return MatrixType (); | |
281 } | |
282 | |
4915 | 283 octave_value |
5759 | 284 octave_base_value::all (int) const |
285 { | |
286 return 0.0; | |
287 } | |
288 | |
289 octave_value | |
290 octave_base_value::any (int) const | |
291 { | |
292 return 0.0; | |
293 } | |
294 | |
295 octave_value | |
296 octave_base_value::convert_to_str (bool pad, bool force, char type) const | |
297 { | |
298 octave_value retval = convert_to_str_internal (pad, force, type); | |
299 | |
5781 | 300 if (! force && is_numeric_type ()) |
301 gripe_implicit_conversion ("Octave:num-to-str", | |
302 type_name (), retval.type_name ()); | |
5759 | 303 |
304 return retval; | |
305 } | |
306 | |
307 octave_value | |
5279 | 308 octave_base_value::convert_to_str_internal (bool, bool, char) const |
2376 | 309 { |
4452 | 310 gripe_wrong_type_arg ("octave_base_value::convert_to_str_internal ()", |
2376 | 311 type_name ()); |
312 return octave_value (); | |
313 } | |
314 | |
315 void | |
316 octave_base_value::convert_to_row_or_column_vector (void) | |
317 { | |
318 gripe_wrong_type_arg | |
319 ("octave_base_value::convert_to_row_or_column_vector ()", | |
320 type_name ()); | |
321 } | |
322 | |
323 void | |
3523 | 324 octave_base_value::print (std::ostream&, bool) const |
2376 | 325 { |
3195 | 326 gripe_wrong_type_arg ("octave_base_value::print ()", type_name ()); |
2376 | 327 } |
328 | |
2901 | 329 void |
3523 | 330 octave_base_value::print_raw (std::ostream&, bool) const |
2901 | 331 { |
3195 | 332 gripe_wrong_type_arg ("octave_base_value::print_raw ()", type_name ()); |
2901 | 333 } |
334 | |
335 bool | |
3523 | 336 octave_base_value::print_name_tag (std::ostream& os, const std::string& name) const |
2901 | 337 { |
4604 | 338 bool retval = false; |
339 | |
2901 | 340 indent (os); |
4604 | 341 |
342 if (print_as_scalar ()) | |
343 os << name << " = "; | |
344 else | |
345 { | |
346 os << name << " ="; | |
347 newline (os); | |
348 newline (os); | |
349 retval = true; | |
350 } | |
351 | |
352 return retval; | |
2901 | 353 } |
354 | |
3933 | 355 void |
5759 | 356 octave_base_value::print_with_name (std::ostream& output_buf, |
357 const std::string& name, | |
358 bool print_padding) const | |
359 { | |
360 if (! (evaluating_function_body && Vsilent_functions)) | |
361 { | |
7336 | 362 bool pad_after = print_name_tag (output_buf, name); |
5759 | 363 |
364 print (output_buf); | |
365 | |
366 if (print_padding && pad_after) | |
367 newline (output_buf); | |
368 } | |
369 } | |
370 | |
371 void | |
3933 | 372 octave_base_value::print_info (std::ostream& os, |
4661 | 373 const std::string& /* prefix */) const |
3933 | 374 { |
375 os << "no info for type: " << type_name () << "\n"; | |
376 } | |
377 | |
4254 | 378 #define INT_CONV_METHOD(T, F, MIN_LIMIT, MAX_LIMIT) \ |
379 T \ | |
380 octave_base_value::F ## _value (bool require_int, bool frc_str_conv) const \ | |
381 { \ | |
382 T retval = 0; \ | |
383 \ | |
384 double d = double_value (frc_str_conv); \ | |
385 \ | |
386 if (! error_state) \ | |
387 { \ | |
388 if (require_int && D_NINT (d) != d) \ | |
389 error ("conversion of %g to " #T " value failed", d); \ | |
5054 | 390 else if (d < MIN_LIMIT) \ |
391 retval = MIN_LIMIT; \ | |
392 else if (d > MAX_LIMIT) \ | |
393 retval = MAX_LIMIT; \ | |
4254 | 394 else \ |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
395 retval = static_cast<T> (::fix (d)); \ |
4254 | 396 } \ |
397 else \ | |
398 gripe_wrong_type_arg ("octave_base_value::" #F "_value ()", \ | |
399 type_name ()); \ | |
400 \ | |
401 return retval; \ | |
402 } | |
3202 | 403 |
4254 | 404 INT_CONV_METHOD (short int, short, SHRT_MIN, SHRT_MAX) |
405 INT_CONV_METHOD (unsigned short int, ushort, 0, USHRT_MAX) | |
3202 | 406 |
4254 | 407 INT_CONV_METHOD (int, int, INT_MIN, INT_MAX) |
408 INT_CONV_METHOD (unsigned int, uint, 0, UINT_MAX) | |
3202 | 409 |
4254 | 410 INT_CONV_METHOD (long int, long, LONG_MIN, LONG_MAX) |
411 INT_CONV_METHOD (unsigned long int, ulong, 0, ULONG_MAX) | |
3202 | 412 |
413 int | |
414 octave_base_value::nint_value (bool frc_str_conv) const | |
415 { | |
416 int retval = 0; | |
417 | |
418 double d = double_value (frc_str_conv); | |
419 | |
420 if (! error_state) | |
421 { | |
422 if (xisnan (d)) | |
423 { | |
424 error ("conversion of NaN to integer value failed"); | |
425 return retval; | |
426 } | |
427 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
428 retval = static_cast<int> (::fix (d)); |
3202 | 429 } |
430 else | |
431 gripe_wrong_type_arg ("octave_base_value::nint_value ()", type_name ()); | |
432 | |
433 return retval; | |
434 } | |
435 | |
2376 | 436 double |
437 octave_base_value::double_value (bool) const | |
438 { | |
4102 | 439 double retval = lo_ieee_nan_value (); |
2376 | 440 gripe_wrong_type_arg ("octave_base_value::double_value ()", type_name ()); |
441 return retval; | |
442 } | |
443 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
444 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
445 octave_base_value::float_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
446 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
447 float retval = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
448 gripe_wrong_type_arg ("octave_base_value::float_value ()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
449 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
450 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
451 |
3351 | 452 Cell |
3539 | 453 octave_base_value::cell_value () const |
3351 | 454 { |
455 Cell retval; | |
456 gripe_wrong_type_arg ("octave_base_value::cell_value()", type_name ()); | |
457 return retval; | |
458 } | |
459 | |
2376 | 460 Matrix |
461 octave_base_value::matrix_value (bool) const | |
462 { | |
463 Matrix retval; | |
464 gripe_wrong_type_arg ("octave_base_value::matrix_value()", type_name ()); | |
465 return retval; | |
466 } | |
467 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
468 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
469 octave_base_value::float_matrix_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
470 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
471 FloatMatrix retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
472 gripe_wrong_type_arg ("octave_base_value::float_matrix_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
473 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
474 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
475 |
4507 | 476 NDArray |
4550 | 477 octave_base_value::array_value (bool) const |
4505 | 478 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
479 FloatNDArray retval; |
4550 | 480 gripe_wrong_type_arg ("octave_base_value::array_value()", type_name ()); |
4505 | 481 return retval; |
482 } | |
483 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
484 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
485 octave_base_value::float_array_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
486 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
487 FloatNDArray retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
488 gripe_wrong_type_arg ("octave_base_value::float_array_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
489 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
490 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
491 |
2376 | 492 Complex |
493 octave_base_value::complex_value (bool) const | |
494 { | |
4102 | 495 double tmp = lo_ieee_nan_value (); |
496 Complex retval (tmp, tmp); | |
2376 | 497 gripe_wrong_type_arg ("octave_base_value::complex_value()", type_name ()); |
498 return retval; | |
499 } | |
500 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
501 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
502 octave_base_value::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
503 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
504 float tmp = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
505 FloatComplex retval (tmp, tmp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
506 gripe_wrong_type_arg ("octave_base_value::float_complex_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
507 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
508 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
509 |
2376 | 510 ComplexMatrix |
511 octave_base_value::complex_matrix_value (bool) const | |
512 { | |
513 ComplexMatrix retval; | |
514 gripe_wrong_type_arg ("octave_base_value::complex_matrix_value()", | |
515 type_name ()); | |
516 return retval; | |
517 } | |
518 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
519 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
520 octave_base_value::float_complex_matrix_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
521 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
522 FloatComplexMatrix retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
523 gripe_wrong_type_arg ("octave_base_value::float_complex_matrix_value()", |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
524 type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
525 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
526 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
527 |
4550 | 528 ComplexNDArray |
529 octave_base_value::complex_array_value (bool) const | |
530 { | |
531 ComplexNDArray retval; | |
532 gripe_wrong_type_arg ("octave_base_value::complex_array_value()", | |
533 type_name ()); | |
534 return retval; | |
535 } | |
536 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
537 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
538 octave_base_value::float_complex_array_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
539 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
540 FloatComplexNDArray retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
541 gripe_wrong_type_arg ("octave_base_value::float_complex_array_value()", |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
542 type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
543 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
544 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
545 |
4550 | 546 bool |
5943 | 547 octave_base_value::bool_value (bool) const |
4550 | 548 { |
549 bool retval = false; | |
550 gripe_wrong_type_arg ("octave_base_value::bool_value()", type_name ()); | |
551 return retval; | |
552 } | |
553 | |
554 boolMatrix | |
5943 | 555 octave_base_value::bool_matrix_value (bool) const |
4550 | 556 { |
557 boolMatrix retval; | |
558 gripe_wrong_type_arg ("octave_base_value::bool_matrix_value()", | |
559 type_name ()); | |
560 return retval; | |
561 } | |
562 | |
563 boolNDArray | |
5943 | 564 octave_base_value::bool_array_value (bool) const |
4550 | 565 { |
566 boolNDArray retval; | |
567 gripe_wrong_type_arg ("octave_base_value::bool_array_value()", | |
568 type_name ()); | |
569 return retval; | |
570 } | |
571 | |
2376 | 572 charMatrix |
4741 | 573 octave_base_value::char_matrix_value (bool force) const |
2376 | 574 { |
575 charMatrix retval; | |
4257 | 576 |
4741 | 577 octave_value tmp = convert_to_str (false, force); |
4257 | 578 |
4452 | 579 if (! error_state) |
580 retval = tmp.char_matrix_value (); | |
581 | |
2376 | 582 return retval; |
583 } | |
584 | |
4550 | 585 charNDArray |
586 octave_base_value::char_array_value (bool) const | |
587 { | |
588 charNDArray retval; | |
589 gripe_wrong_type_arg ("octave_base_value::char_array_value()", | |
590 type_name ()); | |
591 return retval; | |
592 } | |
593 | |
5164 | 594 SparseMatrix |
595 octave_base_value::sparse_matrix_value (bool) const | |
596 { | |
597 SparseMatrix retval; | |
598 gripe_wrong_type_arg ("octave_base_value::sparse_matrix_value()", type_name ()); | |
599 return retval; | |
600 } | |
601 | |
602 SparseComplexMatrix | |
603 octave_base_value::sparse_complex_matrix_value (bool) const | |
604 { | |
605 SparseComplexMatrix retval; | |
606 gripe_wrong_type_arg ("octave_base_value::sparse_complex_matrix_value()", type_name ()); | |
607 return retval; | |
608 } | |
609 | |
610 SparseBoolMatrix | |
611 octave_base_value::sparse_bool_matrix_value (bool) const | |
612 { | |
613 SparseBoolMatrix retval; | |
614 gripe_wrong_type_arg ("octave_base_value::sparse_bool_matrix_value()", type_name ()); | |
615 return retval; | |
616 } | |
617 | |
4910 | 618 octave_int8 |
619 octave_base_value::int8_scalar_value (void) const | |
620 { | |
621 octave_int8 retval; | |
622 gripe_wrong_type_arg ("octave_base_value::int8_scalar_value()", | |
623 type_name ()); | |
624 return retval; | |
625 } | |
626 | |
627 octave_int16 | |
628 octave_base_value::int16_scalar_value (void) const | |
629 { | |
630 octave_int16 retval; | |
631 gripe_wrong_type_arg ("octave_base_value::int16_scalar_value()", | |
632 type_name ()); | |
633 return retval; | |
634 } | |
635 | |
636 octave_int32 | |
637 octave_base_value::int32_scalar_value (void) const | |
638 { | |
639 octave_int32 retval; | |
640 gripe_wrong_type_arg ("octave_base_value::int32_scalar_value()", | |
641 type_name ()); | |
642 return retval; | |
643 } | |
644 | |
645 octave_int64 | |
646 octave_base_value::int64_scalar_value (void) const | |
647 { | |
648 octave_int64 retval; | |
649 gripe_wrong_type_arg ("octave_base_value::int64_scalar_value()", | |
650 type_name ()); | |
651 return retval; | |
652 } | |
653 | |
654 octave_uint8 | |
655 octave_base_value::uint8_scalar_value (void) const | |
656 { | |
657 octave_uint8 retval; | |
658 gripe_wrong_type_arg ("octave_base_value::uint8_scalar_value()", | |
659 type_name ()); | |
660 return retval; | |
661 } | |
662 | |
663 octave_uint16 | |
664 octave_base_value::uint16_scalar_value (void) const | |
665 { | |
666 octave_uint16 retval; | |
667 gripe_wrong_type_arg ("octave_base_value::uint16_scalar_value()", | |
668 type_name ()); | |
669 return retval; | |
670 } | |
671 | |
672 octave_uint32 | |
673 octave_base_value::uint32_scalar_value (void) const | |
674 { | |
675 octave_uint32 retval; | |
676 gripe_wrong_type_arg ("octave_base_value::uint32_scalar_value()", | |
677 type_name ()); | |
678 return retval; | |
679 } | |
680 | |
681 octave_uint64 | |
682 octave_base_value::uint64_scalar_value (void) const | |
683 { | |
684 octave_uint64 retval; | |
685 gripe_wrong_type_arg ("octave_base_value::uint64_scalar_value()", | |
686 type_name ()); | |
687 return retval; | |
688 } | |
689 | |
4906 | 690 int8NDArray |
691 octave_base_value::int8_array_value (void) const | |
692 { | |
693 int8NDArray retval; | |
694 gripe_wrong_type_arg ("octave_base_value::int8_array_value()", | |
695 type_name ()); | |
4910 | 696 return retval; |
4906 | 697 } |
698 | |
699 int16NDArray | |
700 octave_base_value::int16_array_value (void) const | |
701 { | |
702 int16NDArray retval; | |
703 gripe_wrong_type_arg ("octave_base_value::int16_array_value()", | |
704 type_name ()); | |
4910 | 705 return retval; |
4906 | 706 } |
707 | |
708 int32NDArray | |
709 octave_base_value::int32_array_value (void) const | |
710 { | |
711 int32NDArray retval; | |
712 gripe_wrong_type_arg ("octave_base_value::int32_array_value()", | |
713 type_name ()); | |
4910 | 714 return retval; |
4906 | 715 } |
716 | |
717 int64NDArray | |
718 octave_base_value::int64_array_value (void) const | |
719 { | |
720 int64NDArray retval; | |
721 gripe_wrong_type_arg ("octave_base_value::int64_array_value()", | |
722 type_name ()); | |
4910 | 723 return retval; |
4906 | 724 } |
725 | |
726 uint8NDArray | |
727 octave_base_value::uint8_array_value (void) const | |
728 { | |
729 uint8NDArray retval; | |
730 gripe_wrong_type_arg ("octave_base_value::uint8_array_value()", | |
731 type_name ()); | |
4910 | 732 return retval; |
4906 | 733 } |
734 | |
735 uint16NDArray | |
736 octave_base_value::uint16_array_value (void) const | |
737 { | |
738 uint16NDArray retval; | |
739 gripe_wrong_type_arg ("octave_base_value::uint16_array_value()", | |
740 type_name ()); | |
4910 | 741 return retval; |
4906 | 742 } |
743 | |
744 uint32NDArray | |
745 octave_base_value::uint32_array_value (void) const | |
746 { | |
747 uint32NDArray retval; | |
748 gripe_wrong_type_arg ("octave_base_value::uint32_array_value()", | |
749 type_name ()); | |
4910 | 750 return retval; |
4906 | 751 } |
752 | |
753 uint64NDArray | |
754 octave_base_value::uint64_array_value (void) const | |
755 { | |
756 uint64NDArray retval; | |
757 gripe_wrong_type_arg ("octave_base_value::uint64_array_value()", | |
758 type_name ()); | |
4910 | 759 return retval; |
4906 | 760 } |
761 | |
2493 | 762 string_vector |
5715 | 763 octave_base_value::all_strings (bool pad) const |
2376 | 764 { |
2493 | 765 string_vector retval; |
4257 | 766 |
5715 | 767 octave_value tmp = convert_to_str (pad, true); |
4257 | 768 |
4452 | 769 if (! error_state) |
770 retval = tmp.all_strings (); | |
4257 | 771 |
2376 | 772 return retval; |
773 } | |
774 | |
3536 | 775 std::string |
4457 | 776 octave_base_value::string_value (bool force) const |
2376 | 777 { |
3523 | 778 std::string retval; |
4257 | 779 |
4457 | 780 octave_value tmp = convert_to_str (force); |
4257 | 781 |
4452 | 782 if (! error_state) |
783 retval = tmp.string_value (); | |
4257 | 784 |
2376 | 785 return retval; |
786 } | |
787 | |
788 Range | |
789 octave_base_value::range_value (void) const | |
790 { | |
791 Range retval; | |
792 gripe_wrong_type_arg ("octave_base_value::range_value()", type_name ()); | |
793 return retval; | |
794 } | |
795 | |
796 Octave_map | |
797 octave_base_value::map_value (void) const | |
798 { | |
799 Octave_map retval; | |
800 gripe_wrong_type_arg ("octave_base_value::map_value()", type_name ()); | |
801 return retval; | |
802 } | |
803 | |
3933 | 804 string_vector |
805 octave_base_value::map_keys (void) const | |
806 { | |
807 string_vector retval; | |
808 gripe_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); | |
809 return retval; | |
810 } | |
811 | |
2974 | 812 octave_function * |
813 octave_base_value::function_value (bool silent) | |
814 { | |
815 octave_function *retval = 0; | |
816 | |
817 if (! silent) | |
818 gripe_wrong_type_arg ("octave_base_value::function_value()", | |
819 type_name ()); | |
820 return retval; | |
821 } | |
822 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
823 const octave_function * |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
824 octave_base_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
825 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
826 const octave_function *retval = 0; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
827 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
828 if (! silent) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
829 gripe_wrong_type_arg ("octave_base_value::function_value()", |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
830 type_name ()); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
831 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
832 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
833 |
4700 | 834 octave_user_function * |
835 octave_base_value::user_function_value (bool silent) | |
836 { | |
837 octave_user_function *retval = 0; | |
838 | |
839 if (! silent) | |
840 gripe_wrong_type_arg ("octave_base_value::user_function_value()", | |
841 type_name ()); | |
842 return retval; | |
843 } | |
844 | |
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
|
845 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
|
846 octave_base_value::user_script_value (bool silent) |
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
|
847 { |
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
|
848 octave_user_script *retval = 0; |
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
|
849 |
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
|
850 if (! silent) |
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
|
851 gripe_wrong_type_arg ("octave_base_value::user_script_value()", |
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
|
852 type_name ()); |
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
|
853 return retval; |
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
|
854 } |
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
|
855 |
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
|
856 octave_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
|
857 octave_base_value::user_code_value (bool silent) |
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
|
858 { |
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
|
859 octave_user_code *retval = 0; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
860 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
861 if (! silent) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
862 gripe_wrong_type_arg ("octave_base_value::user_code_value()", |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
863 type_name ()); |
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
|
864 return retval; |
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
|
865 } |
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
|
866 |
4346 | 867 octave_fcn_handle * |
4343 | 868 octave_base_value::fcn_handle_value (bool silent) |
869 { | |
4346 | 870 octave_fcn_handle *retval = 0; |
4343 | 871 |
872 if (! silent) | |
873 gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()", | |
874 type_name ()); | |
875 return retval; | |
876 } | |
877 | |
4933 | 878 octave_fcn_inline * |
879 octave_base_value::fcn_inline_value (bool silent) | |
880 { | |
881 octave_fcn_inline *retval = 0; | |
882 | |
883 if (! silent) | |
884 gripe_wrong_type_arg ("octave_base_value::fcn_inline_value()", | |
885 type_name ()); | |
886 return retval; | |
887 } | |
888 | |
2882 | 889 octave_value_list |
890 octave_base_value::list_value (void) const | |
891 { | |
892 octave_value_list retval; | |
893 gripe_wrong_type_arg ("octave_base_value::list_value()", type_name ()); | |
894 return retval; | |
895 } | |
896 | |
4687 | 897 bool |
6974 | 898 octave_base_value::save_ascii (std::ostream&) |
4687 | 899 { |
900 gripe_wrong_type_arg ("octave_base_value::save_ascii()", type_name ()); | |
901 return false; | |
902 } | |
903 | |
904 bool | |
905 octave_base_value::load_ascii (std::istream&) | |
906 { | |
907 gripe_wrong_type_arg ("octave_base_value::load_ascii()", type_name ()); | |
908 return false; | |
909 } | |
910 | |
911 bool | |
912 octave_base_value::save_binary (std::ostream&, bool&) | |
913 { | |
914 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
915 return false; | |
916 } | |
917 | |
918 bool | |
919 octave_base_value::load_binary (std::istream&, bool, | |
920 oct_mach_info::float_format) | |
921 { | |
922 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
923 return false; | |
924 } | |
925 | |
926 #if defined (HAVE_HDF5) | |
4944 | 927 |
4687 | 928 bool |
929 octave_base_value::save_hdf5 (hid_t, const char *, bool) | |
930 { | |
931 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
932 | |
933 return false; | |
934 } | |
935 | |
936 bool | |
937 octave_base_value::load_hdf5 (hid_t, const char *, bool) | |
938 { | |
939 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
940 | |
941 return false; | |
942 } | |
4944 | 943 |
4687 | 944 #endif |
945 | |
4944 | 946 int |
947 octave_base_value::write (octave_stream&, int, oct_data_conv::data_type, | |
948 int, oct_mach_info::float_format) const | |
949 { | |
950 gripe_wrong_type_arg ("octave_base_value::write()", type_name ()); | |
951 | |
952 return false; | |
953 } | |
954 | |
5900 | 955 mxArray * |
956 octave_base_value::as_mxArray (void) const | |
957 { | |
958 gripe_wrong_type_arg ("octave_base_value::as_mxArray ()", type_name ()); | |
959 | |
960 return 0; | |
961 } | |
962 | |
7433 | 963 octave_value |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
964 octave_base_value::diag (octave_idx_type) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
965 { |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
966 gripe_wrong_type_arg ("octave_base_value::diag ()", type_name ()); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
967 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
968 return octave_value(); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
969 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
970 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
971 octave_value |
7433 | 972 octave_base_value::sort (octave_idx_type, sortmode) const |
973 { | |
974 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
975 | |
976 return octave_value(); | |
977 } | |
978 | |
979 octave_value | |
980 octave_base_value::sort (Array<octave_idx_type> &, | |
981 octave_idx_type, sortmode) const | |
982 { | |
983 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
984 | |
985 return octave_value(); | |
986 } | |
987 | |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
988 #define UNDEFINED_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
989 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
990 octave_base_value::F (void) const \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
991 { \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
992 gripe_wrong_type_arg ("octave_base_value::" #F " ()", type_name ()); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
993 return octave_value (); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
994 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
995 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
996 UNDEFINED_MAPPER (abs) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
997 UNDEFINED_MAPPER (acos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
998 UNDEFINED_MAPPER (acosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
999 UNDEFINED_MAPPER (angle) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1000 UNDEFINED_MAPPER (arg) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1001 UNDEFINED_MAPPER (asin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1002 UNDEFINED_MAPPER (asinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1003 UNDEFINED_MAPPER (atan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1004 UNDEFINED_MAPPER (atanh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1005 UNDEFINED_MAPPER (ceil) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1006 UNDEFINED_MAPPER (conj) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1007 UNDEFINED_MAPPER (cos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1008 UNDEFINED_MAPPER (cosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1009 UNDEFINED_MAPPER (erf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1010 UNDEFINED_MAPPER (erfc) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1011 UNDEFINED_MAPPER (exp) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1012 UNDEFINED_MAPPER (expm1) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1013 UNDEFINED_MAPPER (finite) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1014 UNDEFINED_MAPPER (fix) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1015 UNDEFINED_MAPPER (floor) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1016 UNDEFINED_MAPPER (gamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1017 UNDEFINED_MAPPER (imag) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1018 UNDEFINED_MAPPER (isinf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1019 UNDEFINED_MAPPER (isna) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1020 UNDEFINED_MAPPER (isnan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1021 UNDEFINED_MAPPER (lgamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1022 UNDEFINED_MAPPER (log) |
7740 | 1023 UNDEFINED_MAPPER (log2) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1024 UNDEFINED_MAPPER (log10) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1025 UNDEFINED_MAPPER (log1p) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1026 UNDEFINED_MAPPER (real) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1027 UNDEFINED_MAPPER (round) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
1028 UNDEFINED_MAPPER (roundb) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1029 UNDEFINED_MAPPER (signum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1030 UNDEFINED_MAPPER (sin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1031 UNDEFINED_MAPPER (sinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1032 UNDEFINED_MAPPER (sqrt) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1033 UNDEFINED_MAPPER (tan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1034 UNDEFINED_MAPPER (tanh) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1035 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1036 // String mapper functions, convert to a string |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1037 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1038 #define STRING_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1039 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1040 octave_base_value::F (void) const \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1041 { \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1042 octave_value tmp = octave_value (char_array_value (true), true); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1043 return error_state ? octave_value () : octave_value (tmp.F ()); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1044 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1045 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1046 STRING_MAPPER (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1047 STRING_MAPPER (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1048 STRING_MAPPER (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1049 STRING_MAPPER (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1050 STRING_MAPPER (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1051 STRING_MAPPER (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1052 STRING_MAPPER (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1053 STRING_MAPPER (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1054 STRING_MAPPER (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1055 STRING_MAPPER (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1056 STRING_MAPPER (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1057 STRING_MAPPER (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1058 STRING_MAPPER (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1059 STRING_MAPPER (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1060 STRING_MAPPER (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1061 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1062 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1063 octave_base_value::lock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1064 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1065 gripe_wrong_type_arg ("octave_base_value::lock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1066 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1067 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1068 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1069 octave_base_value::unlock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1070 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1071 gripe_wrong_type_arg ("octave_base_value::unlock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1072 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1073 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1074 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1075 octave_base_value::dump (std::ostream& os) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1076 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1077 dim_vector dv = this->dims (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1078 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1079 os << "class: " << this->class_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1080 << " type: " << this->type_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1081 << " dims: " << dv.str (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1082 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1083 |
5759 | 1084 static void |
1085 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) | |
1086 { | |
1087 error ("assignment of `%s' to indexed `%s' not implemented", | |
1088 tn2.c_str (), tn1.c_str ()); | |
1089 } | |
1090 | |
1091 static void | |
1092 gripe_assign_conversion_failed (const std::string& tn1, | |
1093 const std::string& tn2) | |
1094 { | |
1095 error ("type conversion for assignment of `%s' to indexed `%s' failed", | |
1096 tn2.c_str (), tn1.c_str ()); | |
1097 } | |
1098 | |
1099 static void | |
1100 gripe_no_conversion (const std::string& on, const std::string& tn1, | |
1101 const std::string& tn2) | |
1102 { | |
1103 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", | |
1104 on.c_str (), tn2.c_str (), tn1.c_str ()); | |
1105 } | |
1106 | |
1107 octave_value | |
1108 octave_base_value::numeric_assign (const std::string& type, | |
1109 const std::list<octave_value_list>& idx, | |
1110 const octave_value& rhs) | |
1111 { | |
1112 octave_value retval; | |
1113 | |
1114 int t_lhs = type_id (); | |
1115 int t_rhs = rhs.type_id (); | |
1116 | |
1117 octave_value_typeinfo::assign_op_fcn f | |
1118 = octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, | |
1119 t_lhs, t_rhs); | |
1120 | |
1121 bool done = false; | |
1122 | |
1123 if (f) | |
1124 { | |
1125 f (*this, idx.front (), rhs.get_rep ()); | |
1126 | |
1127 done = (! error_state); | |
1128 } | |
1129 | |
1130 if (done) | |
1131 { | |
1132 count++; | |
1133 retval = octave_value (this); | |
1134 } | |
1135 else | |
1136 { | |
1137 int t_result | |
1138 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); | |
1139 | |
1140 if (t_result >= 0) | |
1141 { | |
1142 octave_base_value::type_conv_fcn cf | |
1143 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); | |
1144 | |
1145 if (cf) | |
1146 { | |
5874 | 1147 octave_base_value *tmp = cf (*this); |
5759 | 1148 |
1149 if (tmp) | |
1150 { | |
5874 | 1151 octave_value val (tmp); |
1152 | |
1153 retval = val.subsasgn (type, idx, rhs); | |
5759 | 1154 |
1155 done = (! error_state); | |
1156 } | |
1157 else | |
1158 gripe_assign_conversion_failed (type_name (), | |
1159 rhs.type_name ()); | |
1160 } | |
1161 else | |
1162 gripe_indexed_assignment (type_name (), rhs.type_name ()); | |
1163 } | |
1164 | |
1165 if (! (done || error_state)) | |
1166 { | |
1167 octave_value tmp_rhs; | |
1168 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1169 octave_base_value::type_conv_info cf_rhs |
5759 | 1170 = rhs.numeric_conversion_function (); |
1171 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1172 octave_base_value::type_conv_info cf_this |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1173 = numeric_conversion_function (); |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1174 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1175 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1176 if (cf_rhs.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1177 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1178 t_lhs, cf_rhs.type_id ()) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1179 || octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1180 cf_rhs.type_id ()) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1181 cf_this = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1182 else if (cf_this.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1183 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1184 cf_this.type_id (), t_rhs) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1185 || octave_value_typeinfo::lookup_pref_assign_conv (cf_this.type_id (), |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1186 t_rhs) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1187 cf_rhs = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1188 |
5759 | 1189 if (cf_rhs) |
1190 { | |
1191 octave_base_value *tmp = cf_rhs (rhs.get_rep ()); | |
1192 | |
1193 if (tmp) | |
1194 tmp_rhs = octave_value (tmp); | |
1195 else | |
1196 { | |
1197 gripe_assign_conversion_failed (type_name (), | |
1198 rhs.type_name ()); | |
1199 return octave_value (); | |
1200 } | |
1201 } | |
1202 else | |
1203 tmp_rhs = rhs; | |
1204 | |
5897 | 1205 count++; |
1206 octave_value tmp_lhs = octave_value (this); | |
5759 | 1207 |
1208 if (cf_this) | |
1209 { | |
1210 octave_base_value *tmp = cf_this (*this); | |
1211 | |
1212 if (tmp) | |
5897 | 1213 tmp_lhs = octave_value (tmp); |
5759 | 1214 else |
1215 { | |
1216 gripe_assign_conversion_failed (type_name (), | |
1217 rhs.type_name ()); | |
1218 return octave_value (); | |
1219 } | |
1220 } | |
1221 | |
1222 if (cf_this || cf_rhs) | |
1223 { | |
5897 | 1224 retval = tmp_lhs.subsasgn (type, idx, tmp_rhs); |
5759 | 1225 |
1226 done = (! error_state); | |
1227 } | |
1228 else | |
1229 gripe_no_conversion (octave_value::assign_op_as_string (octave_value::op_asn_eq), | |
1230 type_name (), rhs.type_name ()); | |
1231 } | |
1232 } | |
1233 | |
1234 // The assignment may have converted to a type that is wider than | |
1235 // necessary. | |
1236 | |
1237 retval.maybe_mutate (); | |
1238 | |
1239 return retval; | |
1240 } | |
1241 | |
1242 // Current indentation. | |
1243 int octave_base_value::curr_print_indent_level = 0; | |
1244 | |
1245 // TRUE means we are at the beginning of a line. | |
1246 bool octave_base_value::beginning_of_line = true; | |
1247 | |
1248 // Each print() function should call this before printing anything. | |
1249 // | |
1250 // This doesn't need to be fast, but isn't there a better way? | |
1251 | |
1252 void | |
1253 octave_base_value::indent (std::ostream& os) const | |
1254 { | |
1255 assert (curr_print_indent_level >= 0); | |
1256 | |
1257 if (beginning_of_line) | |
1258 { | |
5775 | 1259 // FIXME -- do we need this? |
5759 | 1260 // os << prefix; |
1261 | |
1262 for (int i = 0; i < curr_print_indent_level; i++) | |
1263 os << " "; | |
1264 | |
1265 beginning_of_line = false; | |
1266 } | |
1267 } | |
1268 | |
1269 // All print() functions should use this to print new lines. | |
1270 | |
1271 void | |
1272 octave_base_value::newline (std::ostream& os) const | |
1273 { | |
1274 os << "\n"; | |
1275 | |
1276 beginning_of_line = true; | |
1277 } | |
1278 | |
1279 // For ressetting print state. | |
1280 | |
1281 void | |
1282 octave_base_value::reset (void) const | |
1283 { | |
1284 beginning_of_line = true; | |
1285 curr_print_indent_level = 0; | |
1286 } | |
1287 | |
3203 | 1288 CONVDECLX (matrix_conv) |
2376 | 1289 { |
1290 return new octave_matrix (); | |
1291 } | |
1292 | |
3203 | 1293 CONVDECLX (complex_matrix_conv) |
2376 | 1294 { |
1295 return new octave_complex_matrix (); | |
1296 } | |
1297 | |
3203 | 1298 CONVDECLX (string_conv) |
2376 | 1299 { |
1300 return new octave_char_matrix_str (); | |
1301 } | |
1302 | |
3928 | 1303 CONVDECLX (cell_conv) |
1304 { | |
1305 return new octave_cell (); | |
1306 } | |
1307 | |
2376 | 1308 void |
1309 install_base_type_conversions (void) | |
1310 { | |
1311 INSTALL_ASSIGNCONV (octave_base_value, octave_scalar, octave_matrix); | |
1312 INSTALL_ASSIGNCONV (octave_base_value, octave_matrix, octave_matrix); | |
1313 INSTALL_ASSIGNCONV (octave_base_value, octave_complex, octave_complex_matrix); | |
1314 INSTALL_ASSIGNCONV (octave_base_value, octave_complex_matrix, octave_complex_matrix); | |
1315 INSTALL_ASSIGNCONV (octave_base_value, octave_range, octave_matrix); | |
1316 INSTALL_ASSIGNCONV (octave_base_value, octave_char_matrix_str, octave_char_matrix_str); | |
3928 | 1317 INSTALL_ASSIGNCONV (octave_base_value, octave_cell, octave_cell); |
2376 | 1318 |
1319 INSTALL_WIDENOP (octave_base_value, octave_matrix, matrix_conv); | |
1320 INSTALL_WIDENOP (octave_base_value, octave_complex_matrix, complex_matrix_conv); | |
1321 INSTALL_WIDENOP (octave_base_value, octave_char_matrix_str, string_conv); | |
3928 | 1322 INSTALL_WIDENOP (octave_base_value, octave_cell, cell_conv); |
2376 | 1323 } |
1324 | |
5794 | 1325 DEFUN (silent_functions, args, nargout, |
1326 "-*- texinfo -*-\n\ | |
1327 @deftypefn {Built-in Function} {@var{val} =} silent_functions ()\n\ | |
1328 @deftypefnx {Built-in Function} {@var{old_val} =} silent_functions (@var{new_val})\n\ | |
1329 Query or set the internal variable that controls whether internal\n\ | |
1330 output from a function is suppressed. If this option is disabled,\n\ | |
1331 Octave will display the results produced by evaluating expressions\n\ | |
1332 within a function body that are not terminated with a semicolon.\n\ | |
1333 @end deftypefn") | |
5759 | 1334 { |
5794 | 1335 return SET_INTERNAL_VARIABLE (silent_functions); |
5759 | 1336 } |
1337 | |
7193 | 1338 DEFUN (sparse_auto_mutate, args, nargout, |
1339 "-*- texinfo -*-\n\ | |
1340 @deftypefn {Built-in Function} {@var{val} =} sparse_auto_mutate ()\n\ | |
1341 @deftypefnx {Built-in Function} {@var{old_val} =} sparse_auto_mutate (@var{new_val})\n\ | |
1342 Query or set the internal variable that controls whether Octave will\n\ | |
1343 automatically mutate sparse matrices to real matrices to save memory.\n\ | |
1344 For example,\n\ | |
1345 \n\ | |
1346 @example\n\ | |
1347 s = speye(3);\n\ | |
1348 sparse_auto_mutate (false)\n\ | |
1349 s (:, 1) = 1;\n\ | |
1350 typeinfo (s)\n\ | |
1351 @result{} sparse matrix\n\ | |
1352 sparse_auto_mutate (true)\n\ | |
1353 s (1, :) = 1;\n\ | |
1354 typeinfo (s)\n\ | |
1355 @result{} matrix\n\ | |
1356 @end example\n\ | |
1357 @end deftypefn") | |
1358 { | |
1359 return SET_INTERNAL_VARIABLE (sparse_auto_mutate); | |
1360 } | |
1361 | |
2376 | 1362 /* |
1363 ;;; Local Variables: *** | |
1364 ;;; mode: C++ *** | |
1365 ;;; End: *** | |
1366 */ |