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