2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "Array-flags.h" |
2942
|
32 #include "str-vec.h" |
4153
|
33 #include "quit.h" |
2376
|
34 |
2974
|
35 #include "oct-obj.h" |
2376
|
36 #include "ov.h" |
|
37 #include "ov-base.h" |
2825
|
38 #include "ov-bool.h" |
|
39 #include "ov-bool-mat.h" |
3351
|
40 #include "ov-cell.h" |
2376
|
41 #include "ov-scalar.h" |
|
42 #include "ov-re-mat.h" |
|
43 #include "ov-complex.h" |
|
44 #include "ov-cx-mat.h" |
|
45 #include "ov-ch-mat.h" |
|
46 #include "ov-str-mat.h" |
|
47 #include "ov-range.h" |
|
48 #include "ov-struct.h" |
2903
|
49 #include "ov-file.h" |
4643
|
50 #include "ov-streamoff.h" |
2880
|
51 #include "ov-list.h" |
3977
|
52 #include "ov-cs-list.h" |
2376
|
53 #include "ov-colon.h" |
|
54 #include "ov-va-args.h" |
2974
|
55 #include "ov-builtin.h" |
|
56 #include "ov-mapper.h" |
4649
|
57 #include "ov-dld-fcn.h" |
2974
|
58 #include "ov-usr-fcn.h" |
4342
|
59 #include "ov-fcn-handle.h" |
2376
|
60 #include "ov-typeinfo.h" |
|
61 |
|
62 #include "defun.h" |
2880
|
63 #include "error.h" |
2376
|
64 #include "gripes.h" |
|
65 #include "pager.h" |
4005
|
66 #include "parse.h" |
2376
|
67 #include "pr-output.h" |
|
68 #include "utils.h" |
|
69 #include "variables.h" |
|
70 |
2477
|
71 // We are likely to have a lot of octave_value objects to allocate, so |
|
72 // make the grow_size large. |
3219
|
73 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); |
2477
|
74 |
4005
|
75 // If TRUE, turn off printing of results in functions (as if a |
|
76 // semicolon has been appended to each statement). |
|
77 static bool Vsilent_functions; |
|
78 |
4455
|
79 // If TRUE, print a warning for assignments like |
2376
|
80 // |
|
81 // octave> A(1) = 3; A(2) = 5 |
|
82 // |
|
83 // for A already defined and a matrix type. |
4455
|
84 bool Vwarn_fortran_indexing; |
2376
|
85 |
4452
|
86 // Should we warn about conversions from complex to real? |
|
87 int Vwarn_imag_to_real; |
4257
|
88 |
4452
|
89 // Should we print a warning when converting `[97, 98, 99, "123"]' |
|
90 // to a character string? |
|
91 bool Vwarn_num_to_str; |
|
92 |
|
93 // If TRUE, warn for operations like |
2376
|
94 // |
|
95 // octave> 'abc' + 0 |
|
96 // 97 98 99 |
|
97 // |
4452
|
98 int Vwarn_str_to_num; |
2376
|
99 |
|
100 // If TRUE, print the name along with the value. |
|
101 bool Vprint_answer_id_name; |
|
102 |
|
103 // How many levels of structure elements should we print? |
|
104 int Vstruct_levels_to_print; |
|
105 |
|
106 // Allow divide by zero errors to be suppressed. |
|
107 bool Vwarn_divide_by_zero; |
|
108 |
4461
|
109 // If TRUE, print a warning when a matrix is resized by an indexed |
|
110 // assignment with indices outside the current bounds. |
|
111 bool Vwarn_resize_on_range_error; |
2948
|
112 |
2880
|
113 // XXX FIXME XXX |
|
114 |
2376
|
115 // Octave's value type. |
|
116 |
3536
|
117 std::string |
3203
|
118 octave_value::unary_op_as_string (unary_op op) |
|
119 { |
3523
|
120 std::string retval; |
3203
|
121 |
|
122 switch (op) |
|
123 { |
3533
|
124 case op_not: |
3203
|
125 retval = "!"; |
|
126 break; |
|
127 |
3533
|
128 case op_uminus: |
3203
|
129 retval = "-"; |
|
130 break; |
|
131 |
3533
|
132 case op_transpose: |
3203
|
133 retval = ".'"; |
|
134 break; |
|
135 |
3533
|
136 case op_hermitian: |
3203
|
137 retval = "'"; |
|
138 break; |
|
139 |
3533
|
140 case op_incr: |
3203
|
141 retval = "++"; |
|
142 break; |
|
143 |
3533
|
144 case op_decr: |
3203
|
145 retval = "--"; |
|
146 break; |
|
147 |
|
148 default: |
|
149 retval = "<unknown>"; |
|
150 } |
|
151 |
|
152 return retval; |
|
153 } |
|
154 |
3536
|
155 std::string |
2376
|
156 octave_value::binary_op_as_string (binary_op op) |
|
157 { |
3523
|
158 std::string retval; |
2376
|
159 |
|
160 switch (op) |
|
161 { |
3533
|
162 case op_add: |
2376
|
163 retval = "+"; |
|
164 break; |
|
165 |
3533
|
166 case op_sub: |
2376
|
167 retval = "-"; |
|
168 break; |
|
169 |
3533
|
170 case op_mul: |
2376
|
171 retval = "*"; |
|
172 break; |
|
173 |
3533
|
174 case op_div: |
2376
|
175 retval = "/"; |
|
176 break; |
|
177 |
3533
|
178 case op_pow: |
2376
|
179 retval = "^"; |
|
180 break; |
|
181 |
3533
|
182 case op_ldiv: |
2376
|
183 retval = "\\"; |
|
184 break; |
|
185 |
3533
|
186 case op_lshift: |
2903
|
187 retval = "<<"; |
|
188 break; |
|
189 |
3533
|
190 case op_rshift: |
2903
|
191 retval = ">>"; |
|
192 break; |
|
193 |
3533
|
194 case op_lt: |
2376
|
195 retval = "<"; |
|
196 break; |
|
197 |
3533
|
198 case op_le: |
2376
|
199 retval = "<="; |
|
200 break; |
|
201 |
3533
|
202 case op_eq: |
2376
|
203 retval = "=="; |
|
204 break; |
|
205 |
3533
|
206 case op_ge: |
2376
|
207 retval = ">="; |
|
208 break; |
|
209 |
3533
|
210 case op_gt: |
2376
|
211 retval = ">"; |
|
212 break; |
|
213 |
3533
|
214 case op_ne: |
2376
|
215 retval = "!="; |
|
216 break; |
|
217 |
3533
|
218 case op_el_mul: |
2376
|
219 retval = ".*"; |
|
220 break; |
|
221 |
3533
|
222 case op_el_div: |
2376
|
223 retval = "./"; |
|
224 break; |
|
225 |
3533
|
226 case op_el_pow: |
2376
|
227 retval = ".^"; |
|
228 break; |
|
229 |
3533
|
230 case op_el_ldiv: |
2376
|
231 retval = ".\\"; |
|
232 break; |
|
233 |
3533
|
234 case op_el_and: |
2376
|
235 retval = "&"; |
|
236 break; |
|
237 |
3533
|
238 case op_el_or: |
2376
|
239 retval = "|"; |
|
240 break; |
|
241 |
3533
|
242 case op_struct_ref: |
2376
|
243 retval = "."; |
|
244 break; |
|
245 |
|
246 default: |
|
247 retval = "<unknown>"; |
|
248 } |
|
249 |
|
250 return retval; |
|
251 } |
|
252 |
3536
|
253 std::string |
2880
|
254 octave_value::assign_op_as_string (assign_op op) |
|
255 { |
3523
|
256 std::string retval; |
2880
|
257 |
|
258 switch (op) |
|
259 { |
3533
|
260 case op_asn_eq: |
2880
|
261 retval = "="; |
|
262 break; |
|
263 |
3533
|
264 case op_add_eq: |
2880
|
265 retval = "+="; |
|
266 break; |
|
267 |
3533
|
268 case op_sub_eq: |
2880
|
269 retval = "-="; |
|
270 break; |
|
271 |
3533
|
272 case op_mul_eq: |
2880
|
273 retval = "*="; |
|
274 break; |
|
275 |
3533
|
276 case op_div_eq: |
2880
|
277 retval = "/="; |
|
278 break; |
|
279 |
3533
|
280 case op_ldiv_eq: |
3204
|
281 retval = "\\="; |
|
282 break; |
|
283 |
4018
|
284 case op_pow_eq: |
|
285 retval = "^="; |
|
286 break; |
|
287 |
3533
|
288 case op_lshift_eq: |
2903
|
289 retval = "<<="; |
|
290 break; |
|
291 |
3533
|
292 case op_rshift_eq: |
2903
|
293 retval = ">>="; |
|
294 break; |
|
295 |
3533
|
296 case op_el_mul_eq: |
2880
|
297 retval = ".*="; |
|
298 break; |
|
299 |
3533
|
300 case op_el_div_eq: |
2880
|
301 retval = "./="; |
|
302 break; |
|
303 |
3533
|
304 case op_el_ldiv_eq: |
3204
|
305 retval = ".\\="; |
|
306 break; |
|
307 |
4018
|
308 case op_el_pow_eq: |
|
309 retval = ".^="; |
|
310 break; |
|
311 |
3533
|
312 case op_el_and_eq: |
2880
|
313 retval = "&="; |
|
314 break; |
|
315 |
3533
|
316 case op_el_or_eq: |
2880
|
317 retval = "|="; |
|
318 break; |
|
319 |
|
320 default: |
|
321 retval = "<unknown>"; |
|
322 } |
|
323 |
|
324 return retval; |
|
325 } |
|
326 |
4513
|
327 octave_value * |
|
328 octave_value::nil_rep (void) const |
|
329 { |
|
330 static octave_base_value *nr = new octave_base_value (); |
|
331 return nr; |
|
332 } |
|
333 |
2376
|
334 octave_value::octave_value (void) |
4513
|
335 : rep (nil_rep ()) |
2825
|
336 { |
4513
|
337 rep->count++; |
2825
|
338 } |
2376
|
339 |
4254
|
340 octave_value::octave_value (short int i) |
|
341 : rep (new octave_scalar (i)) |
|
342 { |
|
343 rep->count = 1; |
|
344 } |
|
345 |
|
346 octave_value::octave_value (unsigned short int i) |
|
347 : rep (new octave_scalar (i)) |
|
348 { |
|
349 rep->count = 1; |
|
350 } |
|
351 |
4233
|
352 octave_value::octave_value (int i) |
|
353 : rep (new octave_scalar (i)) |
|
354 { |
|
355 rep->count = 1; |
|
356 } |
|
357 |
4254
|
358 octave_value::octave_value (unsigned int i) |
|
359 : rep (new octave_scalar (i)) |
|
360 { |
|
361 rep->count = 1; |
|
362 } |
|
363 |
|
364 octave_value::octave_value (long int i) |
|
365 : rep (new octave_scalar (i)) |
|
366 { |
|
367 rep->count = 1; |
|
368 } |
|
369 |
|
370 octave_value::octave_value (unsigned long int i) |
|
371 : rep (new octave_scalar (i)) |
|
372 { |
|
373 rep->count = 1; |
|
374 } |
|
375 |
4353
|
376 #if defined (HAVE_LONG_LONG_INT) |
|
377 octave_value::octave_value (long long int i) |
|
378 : rep (new octave_scalar (i)) |
|
379 { |
|
380 rep->count = 1; |
|
381 } |
|
382 #endif |
|
383 |
4355
|
384 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353
|
385 octave_value::octave_value (unsigned long long int i) |
|
386 : rep (new octave_scalar (i)) |
|
387 { |
|
388 rep->count = 1; |
|
389 } |
|
390 #endif |
|
391 |
4254
|
392 octave_value::octave_value (octave_time t) |
|
393 : rep (new octave_scalar (t)) |
|
394 { |
|
395 rep->count = 1; |
|
396 } |
|
397 |
2376
|
398 octave_value::octave_value (double d) |
2825
|
399 : rep (new octave_scalar (d)) |
|
400 { |
|
401 rep->count = 1; |
|
402 } |
2376
|
403 |
4587
|
404 octave_value::octave_value (const Cell& c, bool is_csl) |
4513
|
405 : rep (0) |
3351
|
406 { |
4587
|
407 if (is_csl) |
4513
|
408 rep = new octave_cs_list (c); |
|
409 else |
|
410 rep = new octave_cell (c); |
|
411 |
3351
|
412 rep->count = 1; |
|
413 } |
|
414 |
4587
|
415 octave_value::octave_value (const ArrayN<octave_value>& a, bool is_csl) |
4532
|
416 : rep (0) |
|
417 { |
|
418 Cell c (a); |
|
419 |
4587
|
420 if (is_csl) |
4532
|
421 rep = new octave_cs_list (c); |
|
422 else |
|
423 rep = new octave_cell (c); |
|
424 |
|
425 rep->count = 1; |
|
426 } |
|
427 |
2376
|
428 octave_value::octave_value (const Matrix& m) |
2423
|
429 : rep (new octave_matrix (m)) |
|
430 { |
|
431 rep->count = 1; |
|
432 maybe_mutate (); |
|
433 } |
2376
|
434 |
4507
|
435 octave_value::octave_value (const NDArray& a) |
4513
|
436 : rep (new octave_matrix (a)) |
4478
|
437 { |
|
438 rep->count = 1; |
|
439 maybe_mutate (); |
|
440 } |
|
441 |
2376
|
442 octave_value::octave_value (const DiagMatrix& d) |
2423
|
443 : rep (new octave_matrix (d)) |
|
444 { |
|
445 rep->count = 1; |
|
446 maybe_mutate (); |
|
447 } |
2376
|
448 |
3418
|
449 octave_value::octave_value (const RowVector& v) |
|
450 : rep (new octave_matrix (v)) |
2423
|
451 { |
|
452 rep->count = 1; |
|
453 maybe_mutate (); |
|
454 } |
2376
|
455 |
3418
|
456 octave_value::octave_value (const ColumnVector& v) |
|
457 : rep (new octave_matrix (v)) |
2423
|
458 { |
|
459 rep->count = 1; |
|
460 maybe_mutate (); |
|
461 } |
2376
|
462 |
|
463 octave_value::octave_value (const Complex& C) |
2423
|
464 : rep (new octave_complex (C)) |
|
465 { |
|
466 rep->count = 1; |
|
467 maybe_mutate (); |
|
468 } |
2376
|
469 |
|
470 octave_value::octave_value (const ComplexMatrix& m) |
2423
|
471 : rep (new octave_complex_matrix (m)) |
|
472 { |
|
473 rep->count = 1; |
|
474 maybe_mutate (); |
|
475 } |
2376
|
476 |
4513
|
477 octave_value::octave_value (const ComplexNDArray& a) |
|
478 : rep (new octave_complex_matrix (a)) |
4478
|
479 { |
|
480 rep->count = 1; |
|
481 maybe_mutate (); |
|
482 } |
|
483 |
2376
|
484 octave_value::octave_value (const ComplexDiagMatrix& d) |
2423
|
485 : rep (new octave_complex_matrix (d)) |
|
486 { |
|
487 rep->count = 1; |
|
488 maybe_mutate (); |
|
489 } |
2376
|
490 |
3418
|
491 octave_value::octave_value (const ComplexRowVector& v) |
|
492 : rep (new octave_complex_matrix (v)) |
2423
|
493 { |
|
494 rep->count = 1; |
|
495 maybe_mutate (); |
|
496 } |
2376
|
497 |
3418
|
498 octave_value::octave_value (const ComplexColumnVector& v) |
|
499 : rep (new octave_complex_matrix (v)) |
2423
|
500 { |
|
501 rep->count = 1; |
|
502 maybe_mutate (); |
|
503 } |
2376
|
504 |
2825
|
505 octave_value::octave_value (bool b) |
|
506 : rep (new octave_bool (b)) |
|
507 { |
|
508 rep->count = 1; |
|
509 } |
|
510 |
|
511 octave_value::octave_value (const boolMatrix& bm) |
|
512 : rep (new octave_bool_matrix (bm)) |
|
513 { |
|
514 rep->count = 1; |
|
515 maybe_mutate (); |
|
516 } |
|
517 |
4513
|
518 octave_value::octave_value (const boolNDArray& bnda) |
|
519 : rep (new octave_bool_matrix (bnda)) |
|
520 { |
|
521 rep->count = 1; |
|
522 maybe_mutate (); |
|
523 } |
|
524 |
3189
|
525 octave_value::octave_value (char c) |
|
526 : rep (new octave_char_matrix_str (c)) |
|
527 { |
|
528 rep->count = 1; |
|
529 maybe_mutate (); |
|
530 } |
|
531 |
2376
|
532 octave_value::octave_value (const char *s) |
2423
|
533 : rep (new octave_char_matrix_str (s)) |
|
534 { |
|
535 rep->count = 1; |
|
536 maybe_mutate (); |
|
537 } |
2376
|
538 |
3523
|
539 octave_value::octave_value (const std::string& s) |
2423
|
540 : rep (new octave_char_matrix_str (s)) |
|
541 { |
|
542 rep->count = 1; |
|
543 maybe_mutate (); |
|
544 } |
2376
|
545 |
|
546 octave_value::octave_value (const string_vector& s) |
2423
|
547 : rep (new octave_char_matrix_str (s)) |
|
548 { |
|
549 rep->count = 1; |
|
550 maybe_mutate (); |
|
551 } |
2376
|
552 |
4587
|
553 octave_value::octave_value (const charMatrix& chm, bool is_str) |
|
554 : rep (is_str |
4513
|
555 ? new octave_char_matrix_str (chm) |
|
556 : new octave_char_matrix (chm)) |
2409
|
557 { |
4513
|
558 rep->count = 1; |
|
559 maybe_mutate (); |
|
560 } |
2376
|
561 |
4587
|
562 octave_value::octave_value (const charNDArray& chm, bool is_str) |
|
563 : rep (is_str |
4513
|
564 ? new octave_char_matrix_str (chm) |
|
565 : new octave_char_matrix (chm)) |
|
566 { |
2409
|
567 rep->count = 1; |
2423
|
568 maybe_mutate (); |
2409
|
569 } |
2376
|
570 |
|
571 octave_value::octave_value (double base, double limit, double inc) |
2423
|
572 : rep (new octave_range (base, limit, inc)) |
|
573 { |
|
574 rep->count = 1; |
|
575 maybe_mutate (); |
|
576 } |
2376
|
577 |
|
578 octave_value::octave_value (const Range& r) |
2423
|
579 : rep (new octave_range (r)) |
|
580 { |
|
581 rep->count = 1; |
|
582 maybe_mutate (); |
|
583 } |
2376
|
584 |
|
585 octave_value::octave_value (const Octave_map& m) |
2825
|
586 : rep (new octave_struct (m)) |
|
587 { |
|
588 rep->count = 1; |
2880
|
589 } |
|
590 |
3340
|
591 octave_value::octave_value (const octave_stream& s, int n) |
2903
|
592 : rep (new octave_file (s, n)) |
|
593 { |
|
594 rep->count = 1; |
|
595 } |
|
596 |
4643
|
597 octave_value::octave_value (const streamoff_array& off) |
|
598 : rep (new octave_streamoff (off)) |
|
599 { |
|
600 rep->count = 1; |
|
601 } |
|
602 |
2974
|
603 octave_value::octave_value (octave_function *f) |
|
604 : rep (f) |
|
605 { |
|
606 rep->count = 1; |
|
607 } |
|
608 |
4654
|
609 octave_value::octave_value (const fcn_handle_array& fha) |
|
610 : rep (new octave_fcn_handle (fha)) |
|
611 { |
|
612 rep->count = 1; |
|
613 } |
|
614 |
|
615 octave_value::octave_value (octave_function *f, const std::string& nm) |
|
616 : rep (new octave_fcn_handle (f, nm)) |
4342
|
617 { |
|
618 rep->count = 1; |
|
619 } |
|
620 |
4587
|
621 octave_value::octave_value (const octave_value_list& l, bool is_csl) |
4591
|
622 : rep (0) |
2880
|
623 { |
4591
|
624 if (is_csl) |
|
625 rep = new octave_cs_list (l); |
|
626 else |
|
627 rep = new octave_list (l); |
|
628 |
2880
|
629 rep->count = 1; |
|
630 } |
2376
|
631 |
|
632 octave_value::octave_value (octave_value::magic_colon) |
2825
|
633 : rep (new octave_magic_colon ()) |
|
634 { |
|
635 rep->count = 1; |
|
636 } |
2376
|
637 |
|
638 octave_value::octave_value (octave_value::all_va_args) |
2825
|
639 : rep (new octave_all_va_args ()) |
|
640 { |
|
641 rep->count = 1; |
|
642 } |
2376
|
643 |
4276
|
644 octave_value::octave_value (octave_value *new_rep, int cnt) |
2825
|
645 : rep (new_rep) |
|
646 { |
4276
|
647 rep->count = cnt; |
2825
|
648 } |
2376
|
649 |
|
650 octave_value::~octave_value (void) |
|
651 { |
|
652 #if defined (MDEBUG) |
3531
|
653 std::cerr << "~octave_value: rep: " << rep |
|
654 << " rep->count: " << rep->count << "\n"; |
2376
|
655 #endif |
|
656 |
|
657 if (rep && --rep->count == 0) |
|
658 { |
|
659 delete rep; |
|
660 rep = 0; |
|
661 } |
|
662 } |
|
663 |
2880
|
664 octave_value * |
3933
|
665 octave_value::clone (void) const |
2880
|
666 { |
|
667 panic_impossible (); |
3546
|
668 return 0; |
2880
|
669 } |
|
670 |
2409
|
671 void |
|
672 octave_value::maybe_mutate (void) |
|
673 { |
2410
|
674 octave_value *tmp = rep->try_narrowing_conversion (); |
2409
|
675 |
|
676 if (tmp && tmp != rep) |
|
677 { |
|
678 if (--rep->count == 0) |
|
679 delete rep; |
|
680 |
|
681 rep = tmp; |
|
682 rep->count = 1; |
|
683 } |
|
684 } |
|
685 |
4247
|
686 octave_value |
4271
|
687 octave_value::single_subsref (const std::string& type, |
|
688 const octave_value_list& idx) |
4247
|
689 { |
|
690 std::list<octave_value_list> i; |
|
691 |
|
692 i.push_back (idx); |
|
693 |
|
694 return rep->subsref (type, i); |
|
695 } |
|
696 |
2974
|
697 octave_value_list |
4247
|
698 octave_value::subsref (const std::string& type, |
4219
|
699 const std::list<octave_value_list>& idx, int nargout) |
3933
|
700 { |
|
701 if (is_constant ()) |
|
702 return rep->subsref (type, idx); |
|
703 else |
|
704 return rep->subsref (type, idx, nargout); |
|
705 } |
|
706 |
|
707 octave_value |
4247
|
708 octave_value::next_subsref (const std::string& type, |
4219
|
709 const std::list<octave_value_list>& idx, |
4233
|
710 size_t skip) |
3933
|
711 { |
4582
|
712 if (! error_state && idx.size () > skip) |
3933
|
713 { |
4219
|
714 std::list<octave_value_list> new_idx (idx); |
4233
|
715 for (size_t i = 0; i < skip; i++) |
4219
|
716 new_idx.erase (new_idx.begin ()); |
3933
|
717 return subsref (type.substr (skip), new_idx); |
|
718 } |
|
719 else |
|
720 return *this; |
|
721 } |
|
722 |
|
723 octave_value_list |
3544
|
724 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx) |
2974
|
725 { |
3544
|
726 return rep->do_multi_index_op (nargout, idx); |
2974
|
727 } |
|
728 |
2376
|
729 static void |
3933
|
730 gripe_no_conversion (const std::string& on, const std::string& tn1, |
|
731 const std::string& tn2) |
2376
|
732 { |
3203
|
733 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", |
|
734 on.c_str (), tn2.c_str (), tn1.c_str ()); |
2376
|
735 } |
|
736 |
3933
|
737 #if 0 |
3204
|
738 static void |
3933
|
739 gripe_assign_failed (const std::string& on, const std::string& tn1, |
|
740 const std::string& tn2) |
3204
|
741 { |
|
742 error ("assignment failed for `%s %s %s'", |
|
743 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
744 } |
3933
|
745 #endif |
3204
|
746 |
|
747 static void |
3933
|
748 gripe_assign_failed_or_no_method (const std::string& on, |
|
749 const std::string& tn1, |
3523
|
750 const std::string& tn2) |
3204
|
751 { |
|
752 error ("assignment failed, or no method for `%s %s %s'", |
|
753 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
754 } |
|
755 |
3933
|
756 octave_value |
4247
|
757 octave_value::subsasgn (const std::string& type, |
4219
|
758 const std::list<octave_value_list>& idx, |
3933
|
759 const octave_value& rhs) |
|
760 { |
|
761 return rep->subsasgn (type, idx, rhs); |
|
762 } |
|
763 |
|
764 octave_value |
4247
|
765 octave_value::assign (assign_op op, const std::string& type, |
4219
|
766 const std::list<octave_value_list>& idx, |
3933
|
767 const octave_value& rhs) |
|
768 { |
|
769 octave_value retval; |
|
770 |
|
771 make_unique (); |
|
772 |
|
773 octave_value t_rhs = rhs; |
|
774 |
|
775 if (op != op_asn_eq) |
|
776 { |
|
777 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
778 // a specific function to call to handle the op= operation for |
|
779 // the types we have. |
|
780 |
|
781 octave_value t = subsref (type, idx); |
|
782 |
|
783 if (! error_state) |
|
784 { |
|
785 binary_op binop = op_eq_to_binary_op (op); |
|
786 |
|
787 if (! error_state) |
|
788 t_rhs = do_binary_op (binop, t, rhs); |
|
789 } |
|
790 } |
|
791 |
|
792 if (! error_state) |
|
793 { |
|
794 if (type[0] == '.' && ! is_map ()) |
|
795 { |
|
796 octave_value tmp = Octave_map (); |
|
797 retval = tmp.subsasgn (type, idx, t_rhs); |
|
798 } |
|
799 else |
|
800 retval = subsasgn (type, idx, t_rhs); |
|
801 } |
|
802 |
|
803 if (error_state) |
|
804 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
805 type_name (), rhs.type_name ()); |
|
806 |
|
807 return retval; |
|
808 } |
|
809 |
|
810 const octave_value& |
3203
|
811 octave_value::assign (assign_op op, const octave_value& rhs) |
2880
|
812 { |
3533
|
813 if (op == op_asn_eq) |
3203
|
814 operator = (rhs); |
|
815 else |
|
816 { |
3204
|
817 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
818 // a specific function to call to handle the op= operation for |
|
819 // the types we have. |
|
820 |
|
821 binary_op binop = op_eq_to_binary_op (op); |
|
822 |
|
823 if (! error_state) |
|
824 { |
|
825 octave_value t = do_binary_op (binop, *this, rhs); |
|
826 |
|
827 if (! error_state) |
|
828 operator = (t); |
|
829 } |
|
830 |
|
831 if (error_state) |
|
832 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
833 type_name (), rhs.type_name ()); |
|
834 } |
|
835 |
3933
|
836 return *this; |
2376
|
837 } |
|
838 |
4563
|
839 int |
|
840 octave_value::rows (void) const |
|
841 { |
|
842 dim_vector dv = dims (); |
|
843 |
|
844 return (dv.length () > 0) ? dv(0) : -1; |
|
845 } |
|
846 |
|
847 int |
|
848 octave_value::columns (void) const |
|
849 { |
|
850 dim_vector dv = dims (); |
|
851 |
|
852 return (dv.length () > 1) ? dv(1) : -1; |
|
853 } |
|
854 |
|
855 int |
|
856 octave_value::length (void) const |
|
857 { |
|
858 int retval = 0; |
|
859 |
|
860 dim_vector dv = dims (); |
4584
|
861 |
4563
|
862 for (int i = 0; i < dv.length (); i++) |
|
863 { |
|
864 if (dv(i) < 0) |
|
865 { |
|
866 retval = -1; |
|
867 break; |
|
868 } |
|
869 |
4584
|
870 if (dv(i) == 0) |
|
871 { |
|
872 retval = 0; |
|
873 break; |
|
874 } |
|
875 |
4563
|
876 if (dv(i) > retval) |
|
877 retval = dv(i); |
|
878 } |
|
879 |
|
880 return retval; |
|
881 } |
|
882 |
|
883 int |
|
884 octave_value::ndims (void) const |
|
885 { |
|
886 dim_vector dv = dims (); |
|
887 |
|
888 int n_dims = dv.length (); |
|
889 |
|
890 // Remove trailing singleton dimensions. |
|
891 |
|
892 for (int i = n_dims; i > 2; i--) |
|
893 { |
|
894 if (dv(i-1) == 1) |
|
895 n_dims--; |
|
896 else |
|
897 break; |
|
898 } |
|
899 |
|
900 // The result is always >= 2. |
|
901 |
|
902 if (n_dims < 2) |
|
903 n_dims = 2; |
|
904 |
|
905 return n_dims; |
|
906 } |
|
907 |
|
908 int |
|
909 octave_value::numel (void) const |
|
910 { |
|
911 dim_vector dv = dims (); |
|
912 |
4567
|
913 return dv.numel (); |
4563
|
914 } |
|
915 |
3351
|
916 Cell |
|
917 octave_value::cell_value (void) const |
|
918 { |
|
919 return rep->cell_value (); |
|
920 } |
|
921 |
2376
|
922 Octave_map |
|
923 octave_value::map_value (void) const |
|
924 { |
|
925 return rep->map_value (); |
|
926 } |
|
927 |
3340
|
928 octave_stream |
2903
|
929 octave_value::stream_value (void) const |
|
930 { |
|
931 return rep->stream_value (); |
|
932 } |
|
933 |
|
934 int |
|
935 octave_value::stream_number (void) const |
|
936 { |
|
937 return rep->stream_number (); |
|
938 } |
|
939 |
4645
|
940 std::streamoff |
4643
|
941 octave_value::streamoff_value (void) const |
|
942 { |
|
943 return rep->streamoff_value (); |
|
944 } |
|
945 |
4645
|
946 streamoff_array |
|
947 octave_value::streamoff_array_value (void) const |
|
948 { |
|
949 return rep->streamoff_array_value (); |
|
950 } |
|
951 |
2974
|
952 octave_function * |
|
953 octave_value::function_value (bool silent) |
|
954 { |
|
955 return rep->function_value (silent); |
|
956 } |
|
957 |
4346
|
958 octave_fcn_handle * |
4343
|
959 octave_value::fcn_handle_value (bool silent) |
|
960 { |
|
961 return rep->fcn_handle_value (silent); |
|
962 } |
|
963 |
2880
|
964 octave_value_list |
|
965 octave_value::list_value (void) const |
|
966 { |
|
967 return rep->list_value (); |
|
968 } |
|
969 |
2376
|
970 ColumnVector |
3419
|
971 octave_value::column_vector_value (bool force_string_conv, |
|
972 bool force_vector_conversion) const |
|
973 { |
|
974 ColumnVector retval; |
|
975 |
|
976 Matrix m = matrix_value (force_string_conv); |
|
977 |
|
978 if (error_state) |
|
979 return retval; |
|
980 |
|
981 int nr = m.rows (); |
|
982 int nc = m.columns (); |
|
983 |
|
984 if (nc == 1) |
|
985 { |
|
986 retval.resize (nr); |
|
987 for (int i = 0; i < nr; i++) |
|
988 retval (i) = m (i, 0); |
|
989 } |
|
990 else |
|
991 { |
3523
|
992 std::string tn = type_name (); |
3419
|
993 gripe_invalid_conversion (tn.c_str (), "real column vector"); |
|
994 } |
|
995 |
|
996 return retval; |
|
997 } |
|
998 |
|
999 ComplexColumnVector |
|
1000 octave_value::complex_column_vector_value (bool force_string_conv, |
|
1001 bool force_vector_conversion) const |
|
1002 { |
|
1003 ComplexColumnVector retval; |
|
1004 |
|
1005 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1006 |
|
1007 if (error_state) |
|
1008 return retval; |
|
1009 |
|
1010 int nr = m.rows (); |
|
1011 int nc = m.columns (); |
|
1012 |
|
1013 if (nc == 1) |
|
1014 { |
3465
|
1015 retval.resize (nr); |
|
1016 for (int i = 0; i < nr; i++) |
3419
|
1017 retval (i) = m (i, 0); |
|
1018 } |
|
1019 else |
|
1020 { |
3523
|
1021 std::string tn = type_name (); |
3419
|
1022 gripe_invalid_conversion (tn.c_str (), "complex column vector"); |
|
1023 } |
|
1024 |
|
1025 return retval; |
|
1026 } |
|
1027 |
|
1028 RowVector |
|
1029 octave_value::row_vector_value (bool force_string_conv, |
|
1030 bool force_vector_conversion) const |
|
1031 { |
|
1032 RowVector retval; |
|
1033 |
|
1034 Matrix m = matrix_value (force_string_conv); |
|
1035 |
|
1036 if (error_state) |
|
1037 return retval; |
|
1038 |
|
1039 int nr = m.rows (); |
|
1040 int nc = m.columns (); |
|
1041 |
|
1042 if (nr == 1) |
|
1043 { |
|
1044 retval.resize (nc); |
|
1045 for (int i = 0; i < nc; i++) |
|
1046 retval (i) = m (0, i); |
|
1047 } |
|
1048 else |
|
1049 { |
3523
|
1050 std::string tn = type_name (); |
3419
|
1051 gripe_invalid_conversion (tn.c_str (), "real row vector"); |
|
1052 } |
|
1053 |
|
1054 return retval; |
|
1055 } |
|
1056 |
|
1057 ComplexRowVector |
|
1058 octave_value::complex_row_vector_value (bool force_string_conv, |
|
1059 bool force_vector_conversion) const |
|
1060 { |
|
1061 ComplexRowVector retval; |
|
1062 |
|
1063 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1064 |
|
1065 if (error_state) |
|
1066 return retval; |
|
1067 |
|
1068 int nr = m.rows (); |
|
1069 int nc = m.columns (); |
|
1070 |
|
1071 if (nr == 1) |
|
1072 { |
|
1073 retval.resize (nc); |
|
1074 for (int i = 0; i < nc; i++) |
|
1075 retval (i) = m (0, i); |
|
1076 } |
|
1077 else |
|
1078 { |
3523
|
1079 std::string tn = type_name (); |
3419
|
1080 gripe_invalid_conversion (tn.c_str (), "complex row vector"); |
|
1081 } |
|
1082 |
|
1083 return retval; |
|
1084 } |
|
1085 |
|
1086 // Sloppy... |
|
1087 |
|
1088 Array<double> |
2376
|
1089 octave_value::vector_value (bool force_string_conv, |
|
1090 bool force_vector_conversion) const |
|
1091 { |
3419
|
1092 Array<double> retval; |
2376
|
1093 |
|
1094 Matrix m = matrix_value (force_string_conv); |
|
1095 |
|
1096 if (error_state) |
|
1097 return retval; |
|
1098 |
|
1099 int nr = m.rows (); |
|
1100 int nc = m.columns (); |
|
1101 |
|
1102 if (nr == 1) |
|
1103 { |
|
1104 retval.resize (nc); |
|
1105 for (int i = 0; i < nc; i++) |
|
1106 retval (i) = m (0, i); |
|
1107 } |
|
1108 else if (nc == 1) |
|
1109 { |
|
1110 retval.resize (nr); |
|
1111 for (int i = 0; i < nr; i++) |
|
1112 retval (i) = m (i, 0); |
|
1113 } |
4455
|
1114 else if (nr > 0 && nc > 0) |
2376
|
1115 { |
4455
|
1116 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1117 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1118 gripe_implicit_conversion (type_name (), "real vector"); |
|
1119 |
2376
|
1120 retval.resize (nr * nc); |
|
1121 int k = 0; |
|
1122 for (int j = 0; j < nc; j++) |
|
1123 for (int i = 0; i < nr; i++) |
4153
|
1124 { |
|
1125 OCTAVE_QUIT; |
|
1126 |
|
1127 retval (k++) = m (i, j); |
|
1128 } |
2376
|
1129 } |
|
1130 else |
|
1131 { |
3523
|
1132 std::string tn = type_name (); |
2376
|
1133 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1134 } |
|
1135 |
|
1136 return retval; |
|
1137 } |
|
1138 |
4044
|
1139 Array<int> |
|
1140 octave_value::int_vector_value (bool force_string_conv, bool require_int, |
|
1141 bool force_vector_conversion) const |
|
1142 { |
|
1143 Array<int> retval; |
|
1144 |
|
1145 Matrix m = matrix_value (force_string_conv); |
|
1146 |
|
1147 if (error_state) |
|
1148 return retval; |
|
1149 |
|
1150 int nr = m.rows (); |
|
1151 int nc = m.columns (); |
|
1152 |
|
1153 if (nr == 1) |
|
1154 { |
|
1155 retval.resize (nc); |
|
1156 for (int i = 0; i < nc; i++) |
|
1157 { |
4153
|
1158 OCTAVE_QUIT; |
|
1159 |
4044
|
1160 double d = m (0, i); |
|
1161 |
|
1162 if (require_int && D_NINT (d) != d) |
|
1163 { |
|
1164 error ("conversion to integer value failed"); |
|
1165 return retval; |
|
1166 } |
|
1167 |
|
1168 retval (i) = static_cast<int> (d); |
|
1169 } |
|
1170 } |
|
1171 else if (nc == 1) |
|
1172 { |
|
1173 retval.resize (nr); |
|
1174 for (int i = 0; i < nr; i++) |
|
1175 { |
4153
|
1176 OCTAVE_QUIT; |
|
1177 |
4044
|
1178 double d = m (i, 0); |
|
1179 |
|
1180 if (require_int && D_NINT (d) != d) |
|
1181 { |
|
1182 error ("conversion to integer value failed"); |
|
1183 return retval; |
|
1184 } |
|
1185 |
|
1186 retval (i) = static_cast<int> (d); |
|
1187 } |
|
1188 } |
4455
|
1189 else if (nr > 0 && nc > 0) |
4044
|
1190 { |
4455
|
1191 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1192 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1193 gripe_implicit_conversion (type_name (), "real vector"); |
|
1194 |
4044
|
1195 retval.resize (nr * nc); |
|
1196 int k = 0; |
|
1197 for (int j = 0; j < nc; j++) |
|
1198 { |
|
1199 for (int i = 0; i < nr; i++) |
|
1200 { |
4153
|
1201 OCTAVE_QUIT; |
|
1202 |
4044
|
1203 double d = m (i, j); |
|
1204 |
|
1205 if (require_int && D_NINT (d) != d) |
|
1206 { |
|
1207 error ("conversion to integer value failed"); |
|
1208 return retval; |
|
1209 } |
|
1210 |
|
1211 retval (k++) = static_cast<int> (d); |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 std::string tn = type_name (); |
|
1218 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1219 } |
|
1220 |
|
1221 return retval; |
|
1222 } |
|
1223 |
3419
|
1224 Array<Complex> |
2376
|
1225 octave_value::complex_vector_value (bool force_string_conv, |
|
1226 bool force_vector_conversion) const |
|
1227 { |
3419
|
1228 Array<Complex> retval; |
2376
|
1229 |
|
1230 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1231 |
|
1232 if (error_state) |
|
1233 return retval; |
|
1234 |
|
1235 int nr = m.rows (); |
|
1236 int nc = m.columns (); |
|
1237 |
|
1238 if (nr == 1) |
|
1239 { |
|
1240 retval.resize (nc); |
|
1241 for (int i = 0; i < nc; i++) |
4153
|
1242 { |
|
1243 OCTAVE_QUIT; |
|
1244 retval (i) = m (0, i); |
|
1245 } |
2376
|
1246 } |
|
1247 else if (nc == 1) |
|
1248 { |
|
1249 retval.resize (nr); |
|
1250 for (int i = 0; i < nr; i++) |
4153
|
1251 { |
|
1252 OCTAVE_QUIT; |
|
1253 retval (i) = m (i, 0); |
|
1254 } |
2376
|
1255 } |
4455
|
1256 else if (nr > 0 && nc > 0) |
2376
|
1257 { |
4455
|
1258 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1259 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1260 gripe_implicit_conversion (type_name (), "complex vector"); |
|
1261 |
2376
|
1262 retval.resize (nr * nc); |
|
1263 int k = 0; |
|
1264 for (int j = 0; j < nc; j++) |
|
1265 for (int i = 0; i < nr; i++) |
4153
|
1266 { |
|
1267 OCTAVE_QUIT; |
|
1268 retval (k++) = m (i, j); |
|
1269 } |
2376
|
1270 } |
|
1271 else |
|
1272 { |
3523
|
1273 std::string tn = type_name (); |
2376
|
1274 gripe_invalid_conversion (tn.c_str (), "complex vector"); |
|
1275 } |
|
1276 |
|
1277 return retval; |
|
1278 } |
|
1279 |
4452
|
1280 octave_value |
4457
|
1281 octave_value::convert_to_str (bool pad, bool force) const |
4452
|
1282 { |
4457
|
1283 octave_value retval = convert_to_str_internal (pad, force); |
4452
|
1284 |
4457
|
1285 if (! force && is_numeric_type () && Vwarn_num_to_str) |
4452
|
1286 gripe_implicit_conversion (type_name (), retval.type_name ()); |
|
1287 |
|
1288 return retval; |
|
1289 } |
|
1290 |
2376
|
1291 void |
4005
|
1292 octave_value::print_with_name (std::ostream& output_buf, |
|
1293 const std::string& name, |
2903
|
1294 bool print_padding) const |
2376
|
1295 { |
4005
|
1296 if (! (evaluating_function_body && Vsilent_functions)) |
|
1297 { |
|
1298 bool pad_after = print_name_tag (output_buf, name); |
2376
|
1299 |
4005
|
1300 print (output_buf); |
2376
|
1301 |
4005
|
1302 if (print_padding && pad_after) |
|
1303 newline (output_buf); |
|
1304 } |
2376
|
1305 } |
|
1306 |
|
1307 static void |
3523
|
1308 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) |
2413
|
1309 { |
2903
|
1310 error ("assignment of `%s' to indexed `%s' not implemented", |
2413
|
1311 tn2.c_str (), tn1.c_str ()); |
|
1312 } |
|
1313 |
|
1314 static void |
3933
|
1315 gripe_assign_conversion_failed (const std::string& tn1, |
|
1316 const std::string& tn2) |
2413
|
1317 { |
2903
|
1318 error ("type conversion for assignment of `%s' to indexed `%s' failed", |
2413
|
1319 tn2.c_str (), tn1.c_str ()); |
|
1320 } |
|
1321 |
3933
|
1322 octave_value |
4247
|
1323 octave_value::numeric_assign (const std::string& type, |
4219
|
1324 const std::list<octave_value_list>& idx, |
2413
|
1325 const octave_value& rhs) |
|
1326 { |
3933
|
1327 octave_value retval; |
2413
|
1328 |
|
1329 int t_lhs = type_id (); |
|
1330 int t_rhs = rhs.type_id (); |
|
1331 |
2880
|
1332 assign_op_fcn f |
3933
|
1333 = octave_value_typeinfo::lookup_assign_op (op_asn_eq, t_lhs, t_rhs); |
|
1334 |
|
1335 bool done = false; |
2413
|
1336 |
|
1337 if (f) |
|
1338 { |
3933
|
1339 f (*this, idx.front (), rhs.get_rep ()); |
2413
|
1340 |
3933
|
1341 done = (! error_state); |
2413
|
1342 } |
3933
|
1343 |
|
1344 if (done) |
|
1345 retval = octave_value (this, count + 1); |
3196
|
1346 else |
|
1347 { |
3933
|
1348 int t_result |
|
1349 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); |
|
1350 |
|
1351 if (t_result >= 0) |
|
1352 { |
|
1353 type_conv_fcn cf |
|
1354 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); |
|
1355 |
|
1356 if (cf) |
|
1357 { |
|
1358 octave_value *tmp (cf (*this)); |
3196
|
1359 |
3933
|
1360 if (tmp) |
|
1361 { |
|
1362 retval = tmp->subsasgn (type, idx, rhs); |
|
1363 |
4505
|
1364 // The assignment may have converted to a type that |
|
1365 // is wider than necessary. |
|
1366 |
|
1367 retval.maybe_mutate (); |
|
1368 |
3933
|
1369 done = (! error_state); |
|
1370 } |
|
1371 else |
|
1372 gripe_assign_conversion_failed (type_name (), |
|
1373 rhs.type_name ()); |
|
1374 } |
|
1375 else |
|
1376 gripe_indexed_assignment (type_name (), rhs.type_name ()); |
|
1377 } |
|
1378 |
|
1379 if (! (done || error_state)) |
3196
|
1380 { |
3933
|
1381 octave_value tmp_rhs; |
|
1382 type_conv_fcn cf_rhs = rhs.numeric_conversion_function (); |
|
1383 |
|
1384 if (cf_rhs) |
|
1385 { |
|
1386 octave_value *tmp = cf_rhs (rhs.get_rep ()); |
|
1387 |
|
1388 if (tmp) |
|
1389 tmp_rhs = octave_value (tmp); |
|
1390 else |
|
1391 { |
|
1392 gripe_assign_conversion_failed (type_name (), |
|
1393 rhs.type_name ()); |
|
1394 return octave_value (); |
|
1395 } |
|
1396 } |
|
1397 else |
|
1398 tmp_rhs = rhs; |
|
1399 |
|
1400 type_conv_fcn cf_this = numeric_conversion_function (); |
|
1401 |
|
1402 octave_value *tmp_lhs = this; |
3196
|
1403 |
3933
|
1404 if (cf_this) |
|
1405 { |
|
1406 octave_value *tmp = cf_this (*this); |
|
1407 |
|
1408 if (tmp) |
|
1409 tmp_lhs = tmp; |
|
1410 else |
|
1411 { |
|
1412 gripe_assign_conversion_failed (type_name (), |
|
1413 rhs.type_name ()); |
|
1414 return octave_value (); |
|
1415 } |
|
1416 } |
|
1417 |
|
1418 if (cf_this || cf_rhs) |
|
1419 { |
|
1420 retval = tmp_lhs->subsasgn (type, idx, tmp_rhs); |
|
1421 |
|
1422 done = (! error_state); |
|
1423 } |
|
1424 else |
|
1425 gripe_no_conversion (assign_op_as_string (op_asn_eq), |
|
1426 type_name (), rhs.type_name ()); |
3196
|
1427 } |
|
1428 } |
2413
|
1429 |
|
1430 return retval; |
|
1431 } |
|
1432 |
|
1433 static void |
3933
|
1434 gripe_binary_op (const std::string& on, const std::string& tn1, |
|
1435 const std::string& tn2) |
2376
|
1436 { |
2903
|
1437 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
2376
|
1438 on.c_str (), tn1.c_str (), tn2.c_str ()); |
|
1439 } |
|
1440 |
3203
|
1441 static void |
3523
|
1442 gripe_binary_op_conv (const std::string& on) |
3203
|
1443 { |
|
1444 error ("type conversion failed for binary operator `%s'", on.c_str ()); |
|
1445 } |
|
1446 |
2376
|
1447 octave_value |
3933
|
1448 do_binary_op (octave_value::binary_op op, |
|
1449 const octave_value& v1, const octave_value& v2) |
2376
|
1450 { |
|
1451 octave_value retval; |
|
1452 |
|
1453 int t1 = v1.type_id (); |
|
1454 int t2 = v2.type_id (); |
|
1455 |
2427
|
1456 binary_op_fcn f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1457 |
|
1458 if (f) |
|
1459 retval = f (*v1.rep, *v2.rep); |
|
1460 else |
|
1461 { |
|
1462 octave_value tv1; |
2427
|
1463 type_conv_fcn cf1 = v1.numeric_conversion_function (); |
2376
|
1464 |
|
1465 if (cf1) |
|
1466 { |
3203
|
1467 octave_value *tmp = cf1 (*v1.rep); |
|
1468 |
|
1469 if (tmp) |
|
1470 { |
|
1471 tv1 = octave_value (tmp); |
|
1472 t1 = tv1.type_id (); |
|
1473 } |
|
1474 else |
|
1475 { |
|
1476 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1477 return retval; |
|
1478 } |
2376
|
1479 } |
|
1480 else |
|
1481 tv1 = v1; |
|
1482 |
|
1483 octave_value tv2; |
2427
|
1484 type_conv_fcn cf2 = v2.numeric_conversion_function (); |
2376
|
1485 |
|
1486 if (cf2) |
|
1487 { |
3203
|
1488 octave_value *tmp = cf2 (*v2.rep); |
|
1489 |
|
1490 if (tmp) |
|
1491 { |
|
1492 tv2 = octave_value (tmp); |
|
1493 t2 = tv2.type_id (); |
|
1494 } |
|
1495 else |
|
1496 { |
|
1497 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1498 return retval; |
|
1499 } |
2376
|
1500 } |
|
1501 else |
|
1502 tv2 = v2; |
|
1503 |
|
1504 if (cf1 || cf2) |
|
1505 { |
4587
|
1506 f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1507 |
|
1508 if (f) |
|
1509 retval = f (*tv1.rep, *tv2.rep); |
|
1510 else |
|
1511 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1512 v1.type_name (), v2.type_name ()); |
|
1513 } |
|
1514 else |
|
1515 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1516 v1.type_name (), v2.type_name ()); |
|
1517 } |
|
1518 |
|
1519 return retval; |
|
1520 } |
|
1521 |
3933
|
1522 void |
|
1523 octave_value::print_info (std::ostream& os, const std::string& prefix) const |
|
1524 { |
|
1525 os << prefix << "type_name: " << type_name () << "\n" |
|
1526 << prefix << "count: " << get_count () << "\n" |
|
1527 << prefix << "rep info: "; |
|
1528 |
|
1529 rep->print_info (os, prefix + " "); |
|
1530 } |
|
1531 |
3203
|
1532 static void |
3523
|
1533 gripe_unary_op (const std::string& on, const std::string& tn) |
3203
|
1534 { |
|
1535 error ("unary operator `%s' not implemented for `%s' operands", |
|
1536 on.c_str (), tn.c_str ()); |
|
1537 } |
|
1538 |
|
1539 static void |
3523
|
1540 gripe_unary_op_conv (const std::string& on) |
3203
|
1541 { |
|
1542 error ("type conversion failed for unary operator `%s'", on.c_str ()); |
|
1543 } |
|
1544 |
|
1545 octave_value |
|
1546 do_unary_op (octave_value::unary_op op, const octave_value& v) |
|
1547 { |
|
1548 octave_value retval; |
|
1549 |
|
1550 int t = v.type_id (); |
|
1551 |
|
1552 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1553 |
|
1554 if (f) |
|
1555 retval = f (*v.rep); |
|
1556 else |
|
1557 { |
|
1558 octave_value tv; |
|
1559 type_conv_fcn cf = v.numeric_conversion_function (); |
|
1560 |
|
1561 if (cf) |
|
1562 { |
|
1563 octave_value *tmp = cf (*v.rep); |
|
1564 |
|
1565 if (tmp) |
|
1566 { |
|
1567 tv = octave_value (tmp); |
|
1568 t = tv.type_id (); |
|
1569 |
4587
|
1570 f = octave_value_typeinfo::lookup_unary_op (op, t); |
3203
|
1571 |
|
1572 if (f) |
|
1573 retval = f (*tv.rep); |
|
1574 else |
|
1575 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1576 v.type_name ()); |
|
1577 } |
|
1578 else |
|
1579 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
|
1580 } |
|
1581 else |
|
1582 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1583 v.type_name ()); |
|
1584 } |
|
1585 |
|
1586 return retval; |
|
1587 } |
|
1588 |
|
1589 static void |
3933
|
1590 gripe_unary_op_conversion_failed (const std::string& op, |
|
1591 const std::string& tn) |
3203
|
1592 { |
|
1593 error ("operator %s: type conversion for `%s' failed", |
|
1594 op.c_str (), tn.c_str ()); |
|
1595 } |
|
1596 |
3933
|
1597 const octave_value& |
|
1598 octave_value::do_non_const_unary_op (unary_op op) |
3203
|
1599 { |
|
1600 octave_value retval; |
|
1601 |
|
1602 int t = type_id (); |
|
1603 |
|
1604 non_const_unary_op_fcn f |
|
1605 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1606 |
|
1607 if (f) |
|
1608 { |
|
1609 make_unique (); |
|
1610 |
|
1611 f (*rep); |
|
1612 } |
|
1613 else |
|
1614 { |
|
1615 type_conv_fcn cf = numeric_conversion_function (); |
|
1616 |
|
1617 if (cf) |
|
1618 { |
|
1619 octave_value *tmp = cf (*rep); |
|
1620 |
|
1621 if (tmp) |
|
1622 { |
|
1623 octave_value *old_rep = rep; |
|
1624 rep = tmp; |
|
1625 rep->count = 1; |
|
1626 |
|
1627 t = type_id (); |
|
1628 |
|
1629 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1630 |
|
1631 if (f) |
|
1632 { |
|
1633 f (*rep); |
|
1634 |
|
1635 if (old_rep && --old_rep->count == 0) |
|
1636 delete old_rep; |
|
1637 } |
|
1638 else |
|
1639 { |
|
1640 if (old_rep) |
|
1641 { |
|
1642 if (--rep->count == 0) |
|
1643 delete rep; |
|
1644 |
|
1645 rep = old_rep; |
|
1646 } |
|
1647 |
|
1648 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1649 type_name ()); |
|
1650 } |
|
1651 } |
|
1652 else |
|
1653 gripe_unary_op_conversion_failed |
|
1654 (octave_value::unary_op_as_string (op), type_name ()); |
|
1655 } |
|
1656 else |
|
1657 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
|
1658 } |
3933
|
1659 |
|
1660 return *this; |
3203
|
1661 } |
|
1662 |
3933
|
1663 #if 0 |
3205
|
1664 static void |
3933
|
1665 gripe_unary_op_failed_or_no_method (const std::string& on, |
|
1666 const std::string& tn) |
3205
|
1667 { |
|
1668 error ("operator %s: no method, or unable to evaluate for %s operand", |
|
1669 on.c_str (), tn.c_str ()); |
|
1670 } |
3933
|
1671 #endif |
3205
|
1672 |
|
1673 void |
3933
|
1674 octave_value::do_non_const_unary_op (unary_op op, const octave_value_list& idx) |
3205
|
1675 { |
3933
|
1676 abort (); |
|
1677 } |
|
1678 |
|
1679 octave_value |
4247
|
1680 octave_value::do_non_const_unary_op (unary_op op, const std::string& type, |
4219
|
1681 const std::list<octave_value_list>& idx) |
3933
|
1682 { |
|
1683 octave_value retval; |
|
1684 |
|
1685 if (idx.empty ()) |
|
1686 { |
|
1687 do_non_const_unary_op (op); |
3205
|
1688 |
3933
|
1689 retval = *this; |
|
1690 } |
|
1691 else |
|
1692 { |
|
1693 // XXX FIXME XXX -- only do the following stuff if we can't find a |
|
1694 // specific function to call to handle the op= operation for the |
|
1695 // types we have. |
3205
|
1696 |
3933
|
1697 assign_op assop = unary_op_to_assign_op (op); |
|
1698 |
|
1699 retval = assign (assop, type, idx, 1.0); |
|
1700 } |
|
1701 |
|
1702 return retval; |
3205
|
1703 } |
|
1704 |
2903
|
1705 // Current indentation. |
|
1706 int octave_value::curr_print_indent_level = 0; |
|
1707 |
3018
|
1708 // TRUE means we are at the beginning of a line. |
2903
|
1709 bool octave_value::beginning_of_line = true; |
|
1710 |
|
1711 // Each print() function should call this before printing anything. |
|
1712 // |
|
1713 // This doesn't need to be fast, but isn't there a better way? |
|
1714 |
|
1715 void |
3523
|
1716 octave_value::indent (std::ostream& os) const |
2903
|
1717 { |
|
1718 assert (curr_print_indent_level >= 0); |
|
1719 |
|
1720 if (beginning_of_line) |
|
1721 { |
|
1722 // XXX FIXME XXX -- do we need this? |
|
1723 // os << prefix; |
|
1724 |
|
1725 for (int i = 0; i < curr_print_indent_level; i++) |
|
1726 os << " "; |
|
1727 |
|
1728 beginning_of_line = false; |
|
1729 } |
|
1730 } |
|
1731 |
|
1732 // All print() functions should use this to print new lines. |
|
1733 |
|
1734 void |
3523
|
1735 octave_value::newline (std::ostream& os) const |
2903
|
1736 { |
|
1737 os << "\n"; |
|
1738 |
|
1739 beginning_of_line = true; |
|
1740 } |
|
1741 |
|
1742 // For ressetting print state. |
|
1743 |
|
1744 void |
|
1745 octave_value::reset (void) const |
|
1746 { |
|
1747 beginning_of_line = true; |
|
1748 curr_print_indent_level = 0; |
|
1749 } |
|
1750 |
3205
|
1751 octave_value::assign_op |
|
1752 octave_value::unary_op_to_assign_op (unary_op op) |
|
1753 { |
|
1754 assign_op binop = unknown_assign_op; |
|
1755 |
|
1756 switch (op) |
|
1757 { |
3533
|
1758 case op_incr: |
|
1759 binop = op_add_eq; |
3205
|
1760 break; |
|
1761 |
3533
|
1762 case op_decr: |
|
1763 binop = op_sub_eq; |
3205
|
1764 break; |
|
1765 |
|
1766 default: |
|
1767 { |
3523
|
1768 std::string on = unary_op_as_string (op); |
3205
|
1769 error ("operator %s: no assign operator found", on.c_str ()); |
|
1770 } |
|
1771 } |
|
1772 |
|
1773 return binop; |
|
1774 } |
|
1775 |
3204
|
1776 octave_value::binary_op |
|
1777 octave_value::op_eq_to_binary_op (assign_op op) |
|
1778 { |
|
1779 binary_op binop = unknown_binary_op; |
|
1780 |
|
1781 switch (op) |
|
1782 { |
3533
|
1783 case op_add_eq: |
|
1784 binop = op_add; |
3204
|
1785 break; |
|
1786 |
3533
|
1787 case op_sub_eq: |
|
1788 binop = op_sub; |
3204
|
1789 break; |
|
1790 |
3533
|
1791 case op_mul_eq: |
|
1792 binop = op_mul; |
3204
|
1793 break; |
|
1794 |
3533
|
1795 case op_div_eq: |
|
1796 binop = op_div; |
3204
|
1797 break; |
|
1798 |
3533
|
1799 case op_ldiv_eq: |
|
1800 binop = op_ldiv; |
3204
|
1801 break; |
|
1802 |
4018
|
1803 case op_pow_eq: |
|
1804 binop = op_pow; |
|
1805 break; |
|
1806 |
3533
|
1807 case op_lshift_eq: |
|
1808 binop = op_lshift; |
3204
|
1809 break; |
|
1810 |
3533
|
1811 case op_rshift_eq: |
|
1812 binop = op_rshift; |
3204
|
1813 break; |
|
1814 |
3533
|
1815 case op_el_mul_eq: |
|
1816 binop = op_el_mul; |
3204
|
1817 break; |
|
1818 |
3533
|
1819 case op_el_div_eq: |
|
1820 binop = op_el_div; |
3204
|
1821 break; |
|
1822 |
3533
|
1823 case op_el_ldiv_eq: |
|
1824 binop = op_el_ldiv; |
3204
|
1825 break; |
|
1826 |
4018
|
1827 case op_el_pow_eq: |
|
1828 binop = op_el_pow; |
|
1829 break; |
|
1830 |
3533
|
1831 case op_el_and_eq: |
|
1832 binop = op_el_and; |
3204
|
1833 break; |
|
1834 |
3533
|
1835 case op_el_or_eq: |
|
1836 binop = op_el_or; |
3204
|
1837 break; |
|
1838 |
|
1839 default: |
|
1840 { |
3523
|
1841 std::string on = assign_op_as_string (op); |
3204
|
1842 error ("operator %s: no binary operator found", on.c_str ()); |
|
1843 } |
|
1844 } |
|
1845 |
|
1846 return binop; |
|
1847 } |
|
1848 |
3933
|
1849 octave_value |
|
1850 octave_value::empty_conv (const std::string& type, const octave_value& rhs) |
|
1851 { |
|
1852 octave_value retval; |
|
1853 |
|
1854 if (type.length () > 0) |
|
1855 { |
|
1856 switch (type[0]) |
|
1857 { |
|
1858 case '(': |
|
1859 { |
|
1860 if (type.length () > 1 && type[1] == '.') |
|
1861 retval = Octave_map (); |
|
1862 else |
|
1863 retval = octave_value (rhs.empty_clone ()); |
|
1864 } |
|
1865 break; |
|
1866 |
|
1867 case '{': |
|
1868 retval = Cell (); |
|
1869 break; |
|
1870 |
|
1871 case '.': |
|
1872 retval = Octave_map (); |
|
1873 break; |
|
1874 |
|
1875 default: |
|
1876 panic_impossible (); |
|
1877 } |
|
1878 } |
|
1879 else |
|
1880 retval = octave_value (rhs.empty_clone ()); |
|
1881 |
|
1882 return retval; |
|
1883 } |
|
1884 |
2376
|
1885 void |
|
1886 install_types (void) |
|
1887 { |
|
1888 octave_base_value::register_type (); |
3928
|
1889 octave_cell::register_type (); |
2376
|
1890 octave_scalar::register_type (); |
|
1891 octave_complex::register_type (); |
|
1892 octave_matrix::register_type (); |
|
1893 octave_complex_matrix::register_type (); |
|
1894 octave_range::register_type (); |
2825
|
1895 octave_bool::register_type (); |
|
1896 octave_bool_matrix::register_type (); |
2376
|
1897 octave_char_matrix::register_type (); |
|
1898 octave_char_matrix_str::register_type (); |
|
1899 octave_struct::register_type (); |
2903
|
1900 octave_file::register_type (); |
2880
|
1901 octave_list::register_type (); |
3977
|
1902 octave_cs_list::register_type (); |
2376
|
1903 octave_all_va_args::register_type (); |
|
1904 octave_magic_colon::register_type (); |
2974
|
1905 octave_builtin::register_type (); |
|
1906 octave_mapper::register_type (); |
|
1907 octave_user_function::register_type (); |
4649
|
1908 octave_dld_function::register_type (); |
4643
|
1909 octave_fcn_handle::register_type (); |
|
1910 octave_streamoff::register_type (); |
2376
|
1911 } |
|
1912 |
|
1913 static int |
4455
|
1914 warn_fortran_indexing (void) |
2376
|
1915 { |
4455
|
1916 Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing"); |
2376
|
1917 |
4455
|
1918 liboctave_wfi_flag = Vwarn_fortran_indexing; |
2376
|
1919 |
|
1920 return 0; |
|
1921 } |
|
1922 |
|
1923 static int |
4452
|
1924 warn_imag_to_real (void) |
4257
|
1925 { |
4452
|
1926 Vwarn_imag_to_real = check_preference ("warn_imag_to_real"); |
4257
|
1927 |
|
1928 return 0; |
|
1929 } |
|
1930 |
|
1931 static int |
4452
|
1932 warn_num_to_str (void) |
2376
|
1933 { |
4452
|
1934 Vwarn_num_to_str = check_preference ("warn_num_to_str"); |
2376
|
1935 |
|
1936 return 0; |
|
1937 } |
|
1938 |
|
1939 static int |
4452
|
1940 warn_str_to_num (void) |
2376
|
1941 { |
4452
|
1942 Vwarn_str_to_num = check_preference ("warn_str_to_num"); |
2376
|
1943 |
|
1944 return 0; |
|
1945 } |
|
1946 |
|
1947 static int |
|
1948 print_answer_id_name (void) |
|
1949 { |
|
1950 Vprint_answer_id_name = check_preference ("print_answer_id_name"); |
|
1951 |
|
1952 return 0; |
|
1953 } |
|
1954 |
|
1955 static int |
4461
|
1956 warn_resize_on_range_error (void) |
2376
|
1957 { |
4461
|
1958 Vwarn_resize_on_range_error |
|
1959 = check_preference ("warn_resize_on_range_error"); |
2376
|
1960 |
4461
|
1961 liboctave_wrore_flag = Vwarn_resize_on_range_error; |
2376
|
1962 |
|
1963 return 0; |
|
1964 } |
|
1965 |
|
1966 static int |
4005
|
1967 silent_functions (void) |
|
1968 { |
|
1969 Vsilent_functions = check_preference ("silent_functions"); |
|
1970 |
|
1971 return 0; |
|
1972 } |
|
1973 |
|
1974 static int |
2376
|
1975 struct_levels_to_print (void) |
|
1976 { |
|
1977 double val; |
|
1978 if (builtin_real_scalar_variable ("struct_levels_to_print", val) |
|
1979 && ! xisnan (val)) |
|
1980 { |
|
1981 int ival = NINT (val); |
3961
|
1982 if (ival == val) |
2376
|
1983 { |
|
1984 Vstruct_levels_to_print = ival; |
|
1985 return 0; |
|
1986 } |
|
1987 } |
|
1988 gripe_invalid_value_specified ("struct_levels_to_print"); |
|
1989 return -1; |
|
1990 } |
|
1991 |
|
1992 static int |
|
1993 warn_divide_by_zero (void) |
|
1994 { |
|
1995 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
1996 |
|
1997 return 0; |
|
1998 } |
|
1999 |
|
2000 void |
2909
|
2001 symbols_of_ov (void) |
2376
|
2002 { |
4233
|
2003 DEFVAR (print_answer_id_name, true, print_answer_id_name, |
3372
|
2004 "-*- texinfo -*-\n\ |
|
2005 @defvr {Built-in Variable} print_answer_id_name\n\ |
|
2006 If the value of @code{print_answer_id_name} is nonzero, variable\n\ |
|
2007 names are printed along with the result. Otherwise, only the result\n\ |
|
2008 values are printed. The default value is 1.\n\ |
|
2009 @end defvr"); |
2376
|
2010 |
4233
|
2011 DEFVAR (silent_functions, false, silent_functions, |
4005
|
2012 "-*- texinfo -*-\n\ |
|
2013 @defvr {Built-in Variable} silent_functions\n\ |
|
2014 If the value of @code{silent_functions} is nonzero, internal output\n\ |
|
2015 from a function is suppressed. Otherwise, the results of expressions\n\ |
|
2016 within a function body that are not terminated with a semicolon will\n\ |
|
2017 have their values printed. The default value is 0.\n\ |
|
2018 \n\ |
|
2019 For example, if the function\n\ |
|
2020 \n\ |
|
2021 @example\n\ |
|
2022 function f ()\n\ |
|
2023 2 + 2\n\ |
|
2024 endfunction\n\ |
|
2025 @end example\n\ |
|
2026 \n\ |
|
2027 @noindent\n\ |
|
2028 is executed, Octave will either print @samp{ans = 4} or nothing\n\ |
|
2029 depending on the value of @code{silent_functions}.\n\ |
|
2030 @end defvr"); |
|
2031 |
3258
|
2032 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, |
3361
|
2033 "-*- texinfo -*-\n\ |
|
2034 @defvr {Built-in Variable} struct_levels_to_print\n\ |
|
2035 You can tell Octave how many structure levels to display by setting the\n\ |
|
2036 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\ |
3363
|
2037 @end defvr"); |
2376
|
2038 |
4233
|
2039 DEFVAR (warn_divide_by_zero, true, warn_divide_by_zero, |
3371
|
2040 "-*- texinfo -*-\n\ |
|
2041 @defvr {Built-in Variable} warn_divide_by_zero\n\ |
|
2042 If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ |
|
2043 is issued when Octave encounters a division by zero. If the value is\n\ |
|
2044 0, the warning is omitted. The default value is 1.\n\ |
|
2045 @end defvr"); |
4451
|
2046 |
4455
|
2047 DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing, |
|
2048 "-*- texinfo -*-\n\ |
|
2049 @defvr {Built-in Variable} warn_fortran_indexing\n\ |
|
2050 If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\ |
|
2051 printed for expressions which select elements of a two-dimensional matrix\n\ |
|
2052 using a single index. The default value is 0.\n\ |
|
2053 @end defvr"); |
|
2054 |
4451
|
2055 DEFVAR (warn_imag_to_real, false, warn_imag_to_real, |
|
2056 "-*- texinfo -*-\n\ |
|
2057 @defvr {Built-in Variable} warn_imag_to_real\n\ |
|
2058 If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\ |
|
2059 printed for implicit conversions of complex numbers to real numbers.\n\ |
|
2060 The default value is 0.\n\ |
|
2061 @end defvr"); |
4452
|
2062 |
|
2063 DEFVAR (warn_num_to_str, true, warn_num_to_str, |
|
2064 "-*- texinfo -*-\n\ |
|
2065 @defvr {Built-in Variable} warn_num_to_str\n\ |
|
2066 If the value of @code{warn_num_to_str} is nonzero, a warning is\n\ |
|
2067 printed for implicit conversions of numbers to their ASCII character\n\ |
|
2068 equivalents when strings are constructed using a mixture of strings and\n\ |
|
2069 numbers in matrix notation. For example,\n\ |
|
2070 \n\ |
|
2071 @example\n\ |
|
2072 @group\n\ |
|
2073 [ \"f\", 111, 111 ]\n\ |
|
2074 @result{} \"foo\"\n\ |
|
2075 @end group\n\ |
|
2076 @end example\n\ |
|
2077 elicits a warning if @code{warn_num_to_str} is nonzero. The default\n\ |
|
2078 value is 1.\n\ |
|
2079 @end defvr"); |
|
2080 |
4461
|
2081 DEFVAR (warn_resize_on_range_error, false, warn_resize_on_range_error, |
|
2082 "-*- texinfo -*-\n\ |
|
2083 @defvr {Built-in Variable} warn_resize_on_range_error\n\ |
|
2084 If the value of @code{warn_resize_on_range_error} is nonzero, print a\n\ |
|
2085 warning when a matrix is resized by an indexed assignment with\n\ |
|
2086 indices outside the current bounds. The default value is 0.\n\ |
|
2087 @end defvr"); |
|
2088 |
4452
|
2089 DEFVAR (warn_str_to_num, false, warn_str_to_num, |
|
2090 "-*- texinfo -*-\n\ |
|
2091 @defvr {Built-in Variable} warn_str_to_num\n\ |
|
2092 If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\ |
|
2093 for implicit conversions of strings to their numeric ASCII equivalents.\n\ |
|
2094 For example,\n\ |
|
2095 @example\n\ |
|
2096 @group\n\ |
|
2097 \"abc\" + 0\n\ |
|
2098 @result{} 97 98 99\n\ |
|
2099 @end group\n\ |
|
2100 @end example\n\ |
|
2101 elicits a warning if @code{warn_str_to_num} is nonzero. The default\n\ |
|
2102 value is 0.\n\ |
|
2103 @end defvr"); |
2376
|
2104 } |
|
2105 |
|
2106 /* |
|
2107 ;;; Local Variables: *** |
|
2108 ;;; mode: C++ *** |
|
2109 ;;; End: *** |
|
2110 */ |