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 |
|
23 #if defined (__GNUG__) |
|
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" |
2376
|
33 |
2974
|
34 #include "oct-obj.h" |
2979
|
35 #include "oct-lvalue.h" |
2376
|
36 #include "ov.h" |
|
37 #include "ov-base.h" |
2825
|
38 #include "ov-bool.h" |
|
39 #include "ov-bool-mat.h" |
2376
|
40 #include "ov-scalar.h" |
|
41 #include "ov-re-mat.h" |
|
42 #include "ov-complex.h" |
|
43 #include "ov-cx-mat.h" |
|
44 #include "ov-ch-mat.h" |
|
45 #include "ov-str-mat.h" |
|
46 #include "ov-range.h" |
|
47 #include "ov-struct.h" |
2903
|
48 #include "ov-file.h" |
2880
|
49 #include "ov-list.h" |
2376
|
50 #include "ov-colon.h" |
|
51 #include "ov-va-args.h" |
2974
|
52 #include "ov-builtin.h" |
|
53 #include "ov-mapper.h" |
|
54 #include "ov-usr-fcn.h" |
2376
|
55 #include "ov-typeinfo.h" |
|
56 |
|
57 #include "defun.h" |
2880
|
58 #include "error.h" |
2376
|
59 #include "gripes.h" |
|
60 #include "pager.h" |
|
61 #include "pr-output.h" |
|
62 #include "utils.h" |
|
63 #include "variables.h" |
|
64 |
2477
|
65 // We are likely to have a lot of octave_value objects to allocate, so |
|
66 // make the grow_size large. |
|
67 octave_allocator |
|
68 octave_value::allocator (sizeof (octave_value), 1024); |
|
69 |
2376
|
70 // If TRUE, allow assignments like |
|
71 // |
|
72 // octave> A(1) = 3; A(2) = 5 |
|
73 // |
|
74 // for A already defined and a matrix type. |
|
75 bool Vdo_fortran_indexing; |
|
76 |
|
77 // Should we allow things like: |
|
78 // |
|
79 // octave> 'abc' + 0 |
|
80 // 97 98 99 |
|
81 // |
|
82 // to happen? A positive value means yes. A negative value means |
|
83 // yes, but print a warning message. Zero means it should be |
|
84 // considered an error. |
|
85 int Vimplicit_str_to_num_ok; |
|
86 |
|
87 // Should we allow silent conversion of complex to real when a real |
|
88 // type is what we're really looking for? A positive value means yes. |
|
89 // A negative value means yes, but print a warning message. Zero |
|
90 // means it should be considered an error. |
|
91 int Vok_to_lose_imaginary_part; |
|
92 |
|
93 // If TRUE, create column vectors when doing assignments like: |
|
94 // |
|
95 // octave> A(1) = 3; A(2) = 5 |
|
96 // |
|
97 // (for A undefined). Only matters when resize_on_range_error is also |
|
98 // TRUE. |
|
99 bool Vprefer_column_vectors; |
|
100 |
|
101 // If TRUE, print the name along with the value. |
|
102 bool Vprint_answer_id_name; |
|
103 |
|
104 // Should operations on empty matrices return empty matrices or an |
|
105 // error? A positive value means yes. A negative value means yes, |
|
106 // but print a warning message. Zero means it should be considered an |
|
107 // error. |
|
108 int Vpropagate_empty_matrices; |
|
109 |
|
110 // How many levels of structure elements should we print? |
|
111 int Vstruct_levels_to_print; |
|
112 |
|
113 // Allow divide by zero errors to be suppressed. |
|
114 bool Vwarn_divide_by_zero; |
|
115 |
2948
|
116 // If TRUE, resize matrices when performing and indexed assignment and |
|
117 // the indices are outside the current bounds. |
3196
|
118 bool Vresize_on_range_error; |
2948
|
119 |
2880
|
120 // XXX FIXME XXX |
|
121 |
2376
|
122 // Octave's value type. |
|
123 |
|
124 string |
3203
|
125 octave_value::unary_op_as_string (unary_op op) |
|
126 { |
|
127 string retval; |
|
128 |
|
129 switch (op) |
|
130 { |
|
131 case not: |
|
132 retval = "!"; |
|
133 break; |
|
134 |
|
135 case uminus: |
|
136 retval = "-"; |
|
137 break; |
|
138 |
|
139 case transpose: |
|
140 retval = ".'"; |
|
141 break; |
|
142 |
|
143 case hermitian: |
|
144 retval = "'"; |
|
145 break; |
|
146 |
|
147 case incr: |
|
148 retval = "++"; |
|
149 break; |
|
150 |
|
151 case decr: |
|
152 retval = "--"; |
|
153 break; |
|
154 |
|
155 default: |
|
156 retval = "<unknown>"; |
|
157 } |
|
158 |
|
159 return retval; |
|
160 } |
|
161 |
|
162 string |
2376
|
163 octave_value::binary_op_as_string (binary_op op) |
|
164 { |
|
165 string retval; |
|
166 |
|
167 switch (op) |
|
168 { |
|
169 case add: |
|
170 retval = "+"; |
|
171 break; |
|
172 |
|
173 case sub: |
|
174 retval = "-"; |
|
175 break; |
|
176 |
|
177 case mul: |
|
178 retval = "*"; |
|
179 break; |
|
180 |
|
181 case div: |
|
182 retval = "/"; |
|
183 break; |
|
184 |
|
185 case pow: |
|
186 retval = "^"; |
|
187 break; |
|
188 |
|
189 case ldiv: |
|
190 retval = "\\"; |
|
191 break; |
|
192 |
2903
|
193 case lshift: |
|
194 retval = "<<"; |
|
195 break; |
|
196 |
|
197 case rshift: |
|
198 retval = ">>"; |
|
199 break; |
|
200 |
2376
|
201 case lt: |
|
202 retval = "<"; |
|
203 break; |
|
204 |
|
205 case le: |
|
206 retval = "<="; |
|
207 break; |
|
208 |
|
209 case eq: |
|
210 retval = "=="; |
|
211 break; |
|
212 |
|
213 case ge: |
|
214 retval = ">="; |
|
215 break; |
|
216 |
|
217 case gt: |
|
218 retval = ">"; |
|
219 break; |
|
220 |
|
221 case ne: |
|
222 retval = "!="; |
|
223 break; |
|
224 |
|
225 case el_mul: |
|
226 retval = ".*"; |
|
227 break; |
|
228 |
|
229 case el_div: |
|
230 retval = "./"; |
|
231 break; |
|
232 |
|
233 case el_pow: |
|
234 retval = ".^"; |
|
235 break; |
|
236 |
|
237 case el_ldiv: |
|
238 retval = ".\\"; |
|
239 break; |
|
240 |
|
241 case el_and: |
|
242 retval = "&"; |
|
243 break; |
|
244 |
|
245 case el_or: |
|
246 retval = "|"; |
|
247 break; |
|
248 |
|
249 case struct_ref: |
|
250 retval = "."; |
|
251 break; |
|
252 |
|
253 default: |
|
254 retval = "<unknown>"; |
|
255 } |
|
256 |
|
257 return retval; |
|
258 } |
|
259 |
2880
|
260 string |
|
261 octave_value::assign_op_as_string (assign_op op) |
|
262 { |
|
263 string retval; |
|
264 |
|
265 switch (op) |
|
266 { |
|
267 case asn_eq: |
|
268 retval = "="; |
|
269 break; |
|
270 |
|
271 case add_eq: |
|
272 retval = "+="; |
|
273 break; |
|
274 |
|
275 case sub_eq: |
|
276 retval = "-="; |
|
277 break; |
|
278 |
|
279 case mul_eq: |
|
280 retval = "*="; |
|
281 break; |
|
282 |
|
283 case div_eq: |
|
284 retval = "/="; |
|
285 break; |
|
286 |
3204
|
287 case ldiv_eq: |
|
288 retval = "\\="; |
|
289 break; |
|
290 |
2903
|
291 case lshift_eq: |
|
292 retval = "<<="; |
|
293 break; |
|
294 |
|
295 case rshift_eq: |
|
296 retval = ">>="; |
|
297 break; |
|
298 |
2880
|
299 case el_mul_eq: |
|
300 retval = ".*="; |
|
301 break; |
|
302 |
|
303 case el_div_eq: |
|
304 retval = "./="; |
|
305 break; |
|
306 |
3204
|
307 case el_ldiv_eq: |
|
308 retval = ".\\="; |
|
309 break; |
|
310 |
2880
|
311 case el_and_eq: |
|
312 retval = "&="; |
|
313 break; |
|
314 |
|
315 case el_or_eq: |
|
316 retval = "|="; |
|
317 break; |
|
318 |
|
319 default: |
|
320 retval = "<unknown>"; |
|
321 } |
|
322 |
|
323 return retval; |
|
324 } |
|
325 |
2376
|
326 octave_value::octave_value (void) |
2825
|
327 : rep (new octave_base_value ()) |
|
328 { |
|
329 rep->count = 1; |
|
330 } |
2376
|
331 |
|
332 octave_value::octave_value (double d) |
2825
|
333 : rep (new octave_scalar (d)) |
|
334 { |
|
335 rep->count = 1; |
|
336 } |
2376
|
337 |
|
338 octave_value::octave_value (const Matrix& m) |
2423
|
339 : rep (new octave_matrix (m)) |
|
340 { |
|
341 rep->count = 1; |
|
342 maybe_mutate (); |
|
343 } |
2376
|
344 |
|
345 octave_value::octave_value (const DiagMatrix& d) |
2423
|
346 : rep (new octave_matrix (d)) |
|
347 { |
|
348 rep->count = 1; |
|
349 maybe_mutate (); |
|
350 } |
2376
|
351 |
|
352 octave_value::octave_value (const RowVector& v, int pcv) |
2423
|
353 : rep (new octave_matrix (v, pcv)) |
|
354 { |
|
355 rep->count = 1; |
|
356 maybe_mutate (); |
|
357 } |
2376
|
358 |
|
359 octave_value::octave_value (const ColumnVector& v, int pcv) |
2423
|
360 : rep (new octave_matrix (v, pcv)) |
|
361 { |
|
362 rep->count = 1; |
|
363 maybe_mutate (); |
|
364 } |
2376
|
365 |
|
366 octave_value::octave_value (const Complex& C) |
2423
|
367 : rep (new octave_complex (C)) |
|
368 { |
|
369 rep->count = 1; |
|
370 maybe_mutate (); |
|
371 } |
2376
|
372 |
|
373 octave_value::octave_value (const ComplexMatrix& m) |
2423
|
374 : rep (new octave_complex_matrix (m)) |
|
375 { |
|
376 rep->count = 1; |
|
377 maybe_mutate (); |
|
378 } |
2376
|
379 |
|
380 octave_value::octave_value (const ComplexDiagMatrix& d) |
2423
|
381 : rep (new octave_complex_matrix (d)) |
|
382 { |
|
383 rep->count = 1; |
|
384 maybe_mutate (); |
|
385 } |
2376
|
386 |
|
387 octave_value::octave_value (const ComplexRowVector& v, int pcv) |
2423
|
388 : rep (new octave_complex_matrix (v, pcv)) |
|
389 { |
|
390 rep->count = 1; |
|
391 maybe_mutate (); |
|
392 } |
2376
|
393 |
|
394 octave_value::octave_value (const ComplexColumnVector& v, int pcv) |
2423
|
395 : rep (new octave_complex_matrix (v, pcv)) |
|
396 { |
|
397 rep->count = 1; |
|
398 maybe_mutate (); |
|
399 } |
2376
|
400 |
2825
|
401 octave_value::octave_value (bool b) |
|
402 : rep (new octave_bool (b)) |
|
403 { |
|
404 rep->count = 1; |
|
405 } |
|
406 |
|
407 octave_value::octave_value (const boolMatrix& bm) |
|
408 : rep (new octave_bool_matrix (bm)) |
|
409 { |
|
410 rep->count = 1; |
|
411 maybe_mutate (); |
|
412 } |
|
413 |
3189
|
414 octave_value::octave_value (char c) |
|
415 : rep (new octave_char_matrix_str (c)) |
|
416 { |
|
417 rep->count = 1; |
|
418 maybe_mutate (); |
|
419 } |
|
420 |
2376
|
421 octave_value::octave_value (const char *s) |
2423
|
422 : rep (new octave_char_matrix_str (s)) |
|
423 { |
|
424 rep->count = 1; |
|
425 maybe_mutate (); |
|
426 } |
2376
|
427 |
|
428 octave_value::octave_value (const string& s) |
2423
|
429 : rep (new octave_char_matrix_str (s)) |
|
430 { |
|
431 rep->count = 1; |
|
432 maybe_mutate (); |
|
433 } |
2376
|
434 |
|
435 octave_value::octave_value (const string_vector& s) |
2423
|
436 : rep (new octave_char_matrix_str (s)) |
|
437 { |
|
438 rep->count = 1; |
|
439 maybe_mutate (); |
|
440 } |
2376
|
441 |
|
442 octave_value::octave_value (const charMatrix& chm, bool is_string) |
2409
|
443 : rep (0) |
|
444 { |
|
445 if (is_string) |
|
446 rep = new octave_char_matrix_str (chm); |
|
447 else |
|
448 rep = new octave_char_matrix (chm); |
2376
|
449 |
2409
|
450 rep->count = 1; |
2423
|
451 maybe_mutate (); |
2409
|
452 } |
2376
|
453 |
|
454 octave_value::octave_value (double base, double limit, double inc) |
2423
|
455 : rep (new octave_range (base, limit, inc)) |
|
456 { |
|
457 rep->count = 1; |
|
458 maybe_mutate (); |
|
459 } |
2376
|
460 |
|
461 octave_value::octave_value (const Range& r) |
2423
|
462 : rep (new octave_range (r)) |
|
463 { |
|
464 rep->count = 1; |
|
465 maybe_mutate (); |
|
466 } |
2376
|
467 |
|
468 octave_value::octave_value (const Octave_map& m) |
2825
|
469 : rep (new octave_struct (m)) |
|
470 { |
|
471 rep->count = 1; |
2880
|
472 } |
|
473 |
2903
|
474 octave_value::octave_value (octave_stream *s, int n) |
|
475 : rep (new octave_file (s, n)) |
|
476 { |
|
477 rep->count = 1; |
|
478 } |
|
479 |
2974
|
480 octave_value::octave_value (octave_function *f) |
|
481 : rep (f) |
|
482 { |
|
483 rep->count = 1; |
|
484 } |
|
485 |
2880
|
486 octave_value::octave_value (const octave_value_list& l) |
|
487 : rep (new octave_list (l)) |
|
488 { |
|
489 rep->count = 1; |
|
490 } |
2376
|
491 |
|
492 octave_value::octave_value (octave_value::magic_colon) |
2825
|
493 : rep (new octave_magic_colon ()) |
|
494 { |
|
495 rep->count = 1; |
|
496 } |
2376
|
497 |
|
498 octave_value::octave_value (octave_value::all_va_args) |
2825
|
499 : rep (new octave_all_va_args ()) |
|
500 { |
|
501 rep->count = 1; |
|
502 } |
2376
|
503 |
|
504 octave_value::octave_value (octave_value *new_rep) |
2825
|
505 : rep (new_rep) |
|
506 { |
|
507 rep->count = 1; |
|
508 } |
2376
|
509 |
|
510 octave_value::~octave_value (void) |
|
511 { |
|
512 #if defined (MDEBUG) |
|
513 cerr << "~octave_value: rep: " << rep |
|
514 << " rep->count: " << rep->count << "\n"; |
|
515 #endif |
|
516 |
|
517 if (rep && --rep->count == 0) |
|
518 { |
|
519 delete rep; |
|
520 rep = 0; |
|
521 } |
|
522 } |
|
523 |
2880
|
524 octave_value * |
|
525 octave_value::clone (void) |
|
526 { |
|
527 panic_impossible (); |
|
528 } |
|
529 |
2409
|
530 void |
|
531 octave_value::maybe_mutate (void) |
|
532 { |
2410
|
533 octave_value *tmp = rep->try_narrowing_conversion (); |
2409
|
534 |
|
535 if (tmp && tmp != rep) |
|
536 { |
|
537 if (--rep->count == 0) |
|
538 delete rep; |
|
539 |
|
540 rep = tmp; |
|
541 rep->count = 1; |
|
542 } |
|
543 } |
|
544 |
2974
|
545 octave_value_list |
|
546 octave_value::do_index_op (int nargout, const octave_value_list& idx) |
|
547 { |
|
548 return rep->do_index_op (nargout, idx); |
|
549 } |
|
550 |
2376
|
551 static void |
3203
|
552 gripe_no_conversion (const string& on, const string& tn1, const string& tn2) |
2376
|
553 { |
3203
|
554 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", |
|
555 on.c_str (), tn2.c_str (), tn1.c_str ()); |
2376
|
556 } |
|
557 |
3204
|
558 static void |
|
559 gripe_assign_failed (const string& on, const string& tn1, const string& tn2) |
|
560 { |
|
561 error ("assignment failed for `%s %s %s'", |
|
562 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
563 } |
|
564 |
|
565 static void |
|
566 gripe_assign_failed_or_no_method (const string& on, const string& tn1, |
|
567 const string& tn2) |
|
568 { |
|
569 error ("assignment failed, or no method for `%s %s %s'", |
|
570 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
571 } |
|
572 |
2963
|
573 void |
3203
|
574 octave_value::assign (assign_op op, const octave_value& rhs) |
2880
|
575 { |
3203
|
576 if (op == asn_eq) |
|
577 operator = (rhs); |
|
578 else |
|
579 { |
3204
|
580 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
581 // a specific function to call to handle the op= operation for |
|
582 // the types we have. |
|
583 |
|
584 binary_op binop = op_eq_to_binary_op (op); |
|
585 |
|
586 if (! error_state) |
|
587 { |
|
588 octave_value t = do_binary_op (binop, *this, rhs); |
|
589 |
|
590 if (! error_state) |
|
591 operator = (t); |
|
592 } |
|
593 |
|
594 if (error_state) |
|
595 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
596 type_name (), rhs.type_name ()); |
|
597 } |
|
598 } |
|
599 |
|
600 void |
|
601 octave_value::simple_assign (octave_value::assign_op orig_op, |
|
602 const octave_value_list& idx, |
|
603 const octave_value& rhs) |
|
604 { |
|
605 make_unique (); |
|
606 |
|
607 bool assignment_ok = try_assignment (asn_eq, idx, rhs); |
|
608 |
|
609 if (! (error_state || assignment_ok)) |
|
610 { |
|
611 assignment_ok = try_assignment_with_conversion (asn_eq, idx, rhs); |
|
612 |
|
613 if (! (error_state || assignment_ok)) |
|
614 gripe_no_conversion (assign_op_as_string (orig_op), |
|
615 type_name (), rhs.type_name ()); |
3203
|
616 } |
2880
|
617 } |
|
618 |
2963
|
619 void |
2880
|
620 octave_value::assign (octave_value::assign_op op, |
|
621 const octave_value_list& idx, |
|
622 const octave_value& rhs) |
2409
|
623 { |
2948
|
624 if (Vresize_on_range_error || is_defined ()) |
|
625 { |
3204
|
626 if (op == asn_eq) |
|
627 simple_assign (op, idx, rhs); |
|
628 else |
|
629 { |
|
630 // XXX FIXME XXX -- only do the following stuff if we can't |
|
631 // find a specific function to call to handle the op= |
|
632 // operation for the types we have. |
|
633 |
|
634 octave_value t1 = *this; |
2948
|
635 |
3204
|
636 t1 = t1.do_index_op (idx); |
|
637 |
|
638 if (! error_state) |
|
639 { |
|
640 binary_op binop = op_eq_to_binary_op (op); |
|
641 |
|
642 if (! error_state) |
|
643 { |
|
644 octave_value t2 = do_binary_op (binop, t1, rhs); |
2948
|
645 |
3204
|
646 if (! error_state) |
|
647 { |
|
648 simple_assign (op, idx, t2); |
2948
|
649 |
3204
|
650 if (error_state) |
|
651 gripe_assign_failed (assign_op_as_string (op), |
|
652 type_name (), rhs.type_name ()); |
|
653 } |
|
654 else |
|
655 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
656 type_name (), |
|
657 rhs.type_name ()); |
|
658 } |
|
659 else |
|
660 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
661 type_name (), |
|
662 rhs.type_name ()); |
|
663 } |
|
664 else |
|
665 gripe_assign_failed (assign_op_as_string (op), |
3203
|
666 type_name (), rhs.type_name ()); |
2948
|
667 } |
|
668 |
|
669 if (! error_state) |
|
670 maybe_mutate (); |
|
671 } |
|
672 else |
|
673 { |
|
674 error ("indexed assignment to previously undefined variables"); |
|
675 error ("is only possible when resize_on_range_error is true"); |
|
676 } |
|
677 } |
|
678 |
|
679 void |
|
680 octave_value::assign_struct_elt (assign_op op, const string& elt_nm, |
|
681 const octave_value& rhs) |
|
682 { |
2409
|
683 make_unique (); |
2376
|
684 |
2948
|
685 rep->assign_struct_elt (op, elt_nm, rhs); |
|
686 } |
|
687 |
2409
|
688 |
2948
|
689 void |
|
690 octave_value::assign_struct_elt (assign_op op, const string& elt_nm, |
|
691 const octave_value_list& idx, |
|
692 const octave_value& rhs) |
|
693 { |
|
694 make_unique (); |
2409
|
695 |
2948
|
696 rep->assign_struct_elt (op, elt_nm, idx, rhs); |
|
697 } |
2376
|
698 |
2979
|
699 octave_lvalue |
2948
|
700 octave_value::struct_elt_ref (const string& nm) |
|
701 { |
|
702 return rep->struct_elt_ref (this, nm); |
|
703 } |
2409
|
704 |
2979
|
705 octave_lvalue |
2948
|
706 octave_value::struct_elt_ref (octave_value *, const string&) |
|
707 { |
|
708 panic_impossible (); |
|
709 |
2979
|
710 return octave_lvalue (); |
2376
|
711 } |
|
712 |
|
713 Octave_map |
|
714 octave_value::map_value (void) const |
|
715 { |
|
716 return rep->map_value (); |
|
717 } |
|
718 |
2903
|
719 octave_stream * |
|
720 octave_value::stream_value (void) const |
|
721 { |
|
722 return rep->stream_value (); |
|
723 } |
|
724 |
|
725 int |
|
726 octave_value::stream_number (void) const |
|
727 { |
|
728 return rep->stream_number (); |
|
729 } |
|
730 |
2974
|
731 octave_function * |
|
732 octave_value::function_value (bool silent) |
|
733 { |
|
734 return rep->function_value (silent); |
|
735 } |
|
736 |
2880
|
737 octave_value_list |
|
738 octave_value::list_value (void) const |
|
739 { |
|
740 return rep->list_value (); |
|
741 } |
|
742 |
2376
|
743 ColumnVector |
|
744 octave_value::vector_value (bool force_string_conv, |
|
745 bool force_vector_conversion) const |
|
746 { |
|
747 ColumnVector retval; |
|
748 |
|
749 Matrix m = matrix_value (force_string_conv); |
|
750 |
|
751 if (error_state) |
|
752 return retval; |
|
753 |
|
754 int nr = m.rows (); |
|
755 int nc = m.columns (); |
|
756 |
|
757 if (nr == 1) |
|
758 { |
|
759 retval.resize (nc); |
|
760 for (int i = 0; i < nc; i++) |
|
761 retval (i) = m (0, i); |
|
762 } |
|
763 else if (nc == 1) |
|
764 { |
|
765 retval.resize (nr); |
|
766 for (int i = 0; i < nr; i++) |
|
767 retval (i) = m (i, 0); |
|
768 } |
|
769 else if (nr > 0 && nc > 0 |
|
770 && (Vdo_fortran_indexing || force_vector_conversion)) |
|
771 { |
|
772 retval.resize (nr * nc); |
|
773 int k = 0; |
|
774 for (int j = 0; j < nc; j++) |
|
775 for (int i = 0; i < nr; i++) |
|
776 retval (k++) = m (i, j); |
|
777 } |
|
778 else |
|
779 { |
|
780 string tn = type_name (); |
|
781 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
782 } |
|
783 |
|
784 return retval; |
|
785 } |
|
786 |
|
787 ComplexColumnVector |
|
788 octave_value::complex_vector_value (bool force_string_conv, |
|
789 bool force_vector_conversion) const |
|
790 { |
|
791 ComplexColumnVector retval; |
|
792 |
|
793 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
794 |
|
795 if (error_state) |
|
796 return retval; |
|
797 |
|
798 int nr = m.rows (); |
|
799 int nc = m.columns (); |
|
800 |
|
801 if (nr == 1) |
|
802 { |
|
803 retval.resize (nc); |
|
804 for (int i = 0; i < nc; i++) |
|
805 retval (i) = m (0, i); |
|
806 } |
|
807 else if (nc == 1) |
|
808 { |
|
809 retval.resize (nr); |
|
810 for (int i = 0; i < nr; i++) |
|
811 retval (i) = m (i, 0); |
|
812 } |
|
813 else if (nr > 0 && nc > 0 |
|
814 && (Vdo_fortran_indexing || force_vector_conversion)) |
|
815 { |
|
816 retval.resize (nr * nc); |
|
817 int k = 0; |
|
818 for (int j = 0; j < nc; j++) |
|
819 for (int i = 0; i < nr; i++) |
|
820 retval (k++) = m (i, j); |
|
821 } |
|
822 else |
|
823 { |
|
824 string tn = type_name (); |
|
825 gripe_invalid_conversion (tn.c_str (), "complex vector"); |
|
826 } |
|
827 |
|
828 return retval; |
|
829 } |
|
830 |
|
831 void |
|
832 octave_value::print_with_name (ostream& output_buf, const string& name, |
2903
|
833 bool print_padding) const |
2376
|
834 { |
2903
|
835 bool pad_after = print_name_tag (output_buf, name); |
2376
|
836 |
|
837 print (output_buf); |
|
838 |
|
839 if (print_padding && pad_after) |
2903
|
840 newline (output_buf); |
2376
|
841 } |
|
842 |
|
843 static void |
2413
|
844 gripe_indexed_assignment (const string& tn1, const string& tn2) |
|
845 { |
2903
|
846 error ("assignment of `%s' to indexed `%s' not implemented", |
2413
|
847 tn2.c_str (), tn1.c_str ()); |
|
848 } |
|
849 |
|
850 static void |
3203
|
851 gripe_assign_conversion_failed (const string& tn1, const string& tn2) |
2413
|
852 { |
2903
|
853 error ("type conversion for assignment of `%s' to indexed `%s' failed", |
2413
|
854 tn2.c_str (), tn1.c_str ()); |
|
855 } |
|
856 |
|
857 bool |
2880
|
858 octave_value::convert_and_assign (octave_value::assign_op op, |
|
859 const octave_value_list& idx, |
2413
|
860 const octave_value& rhs) |
|
861 { |
|
862 bool assignment_ok = false; |
|
863 |
|
864 int t_lhs = type_id (); |
|
865 int t_rhs = rhs.type_id (); |
|
866 |
|
867 int t_result |
|
868 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); |
|
869 |
|
870 if (t_result >= 0) |
|
871 { |
2427
|
872 type_conv_fcn cf |
2413
|
873 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); |
|
874 |
|
875 if (cf) |
|
876 { |
|
877 octave_value *tmp = cf (*rep); |
|
878 |
|
879 if (tmp) |
|
880 { |
2589
|
881 octave_value *old_rep = rep; |
|
882 rep = tmp; |
|
883 rep->count = 1; |
|
884 |
2880
|
885 assignment_ok = try_assignment (op, idx, rhs); |
2589
|
886 |
|
887 if (! assignment_ok && old_rep) |
2413
|
888 { |
|
889 if (--rep->count == 0) |
|
890 delete rep; |
|
891 |
2589
|
892 rep = old_rep; |
|
893 old_rep = 0; |
2413
|
894 } |
|
895 |
2589
|
896 if (old_rep && --old_rep->count == 0) |
|
897 delete old_rep; |
2413
|
898 } |
|
899 else |
3203
|
900 gripe_assign_conversion_failed (type_name (), rhs.type_name ()); |
2413
|
901 } |
|
902 else |
|
903 gripe_indexed_assignment (type_name (), rhs.type_name ()); |
|
904 } |
|
905 |
|
906 return (assignment_ok && ! error_state); |
|
907 } |
|
908 |
|
909 bool |
2880
|
910 octave_value::try_assignment_with_conversion (octave_value::assign_op op, |
|
911 const octave_value_list& idx, |
2413
|
912 const octave_value& rhs) |
|
913 { |
2880
|
914 bool assignment_ok = convert_and_assign (op, idx, rhs); |
2413
|
915 |
|
916 if (! (error_state || assignment_ok)) |
|
917 { |
|
918 octave_value tmp_rhs; |
2427
|
919 type_conv_fcn cf_rhs = rhs.numeric_conversion_function (); |
2413
|
920 |
|
921 if (cf_rhs) |
3203
|
922 { |
|
923 octave_value *tmp = cf_rhs (*rhs.rep); |
|
924 |
|
925 if (tmp) |
|
926 tmp_rhs = octave_value (tmp); |
|
927 else |
|
928 { |
|
929 gripe_assign_conversion_failed (type_name (), rhs.type_name ()); |
|
930 return false; |
|
931 } |
|
932 } |
2413
|
933 else |
|
934 tmp_rhs = rhs; |
|
935 |
|
936 octave_value *old_rep = 0; |
2427
|
937 type_conv_fcn cf_this = numeric_conversion_function (); |
2413
|
938 |
|
939 if (cf_this) |
|
940 { |
|
941 old_rep = rep; |
3203
|
942 |
|
943 octave_value *tmp = cf_this (*rep); |
|
944 |
|
945 if (tmp) |
|
946 { |
|
947 rep = tmp; |
|
948 rep->count = 1; |
|
949 } |
|
950 else |
|
951 { |
|
952 gripe_assign_conversion_failed (type_name (), rhs.type_name ()); |
|
953 return false; |
|
954 } |
2413
|
955 } |
|
956 |
|
957 if (cf_this || cf_rhs) |
|
958 { |
2880
|
959 assignment_ok = try_assignment (op, idx, tmp_rhs); |
2413
|
960 |
|
961 if (! (error_state || assignment_ok)) |
2880
|
962 assignment_ok = convert_and_assign (op, idx, tmp_rhs); |
2413
|
963 } |
|
964 |
|
965 if (! assignment_ok && old_rep) |
|
966 { |
|
967 if (--rep->count == 0) |
|
968 delete rep; |
|
969 |
|
970 rep = old_rep; |
|
971 old_rep = 0; |
|
972 } |
|
973 |
|
974 if (old_rep && --old_rep->count == 0) |
|
975 delete old_rep; |
|
976 } |
|
977 |
|
978 return (assignment_ok && ! error_state); |
|
979 } |
|
980 |
|
981 bool |
2880
|
982 octave_value::try_assignment (octave_value::assign_op op, |
|
983 const octave_value_list& idx, |
2413
|
984 const octave_value& rhs) |
|
985 { |
|
986 bool retval = false; |
|
987 |
|
988 int t_lhs = type_id (); |
|
989 int t_rhs = rhs.type_id (); |
|
990 |
2880
|
991 assign_op_fcn f |
|
992 = octave_value_typeinfo::lookup_assign_op (op, t_lhs, t_rhs); |
2413
|
993 |
|
994 if (f) |
|
995 { |
|
996 f (*rep, idx, *(rhs.rep)); |
|
997 |
|
998 retval = (! error_state); |
|
999 } |
3196
|
1000 else |
|
1001 { |
|
1002 f = octave_value_typeinfo::lookup_assignany_op (op, t_lhs); |
|
1003 |
|
1004 if (f) |
|
1005 { |
|
1006 f (*rep, idx, rhs); |
|
1007 |
|
1008 retval = (! error_state); |
|
1009 } |
|
1010 } |
2413
|
1011 |
|
1012 return retval; |
|
1013 } |
|
1014 |
|
1015 static void |
2376
|
1016 gripe_binary_op (const string& on, const string& tn1, const string& tn2) |
|
1017 { |
2903
|
1018 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
2376
|
1019 on.c_str (), tn1.c_str (), tn2.c_str ()); |
|
1020 } |
|
1021 |
3203
|
1022 static void |
|
1023 gripe_binary_op_conv (const string& on) |
|
1024 { |
|
1025 error ("type conversion failed for binary operator `%s'", on.c_str ()); |
|
1026 } |
|
1027 |
2376
|
1028 octave_value |
|
1029 do_binary_op (octave_value::binary_op op, const octave_value& v1, |
|
1030 const octave_value& v2) |
|
1031 { |
|
1032 octave_value retval; |
|
1033 |
|
1034 int t1 = v1.type_id (); |
|
1035 int t2 = v2.type_id (); |
|
1036 |
2427
|
1037 binary_op_fcn f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1038 |
|
1039 if (f) |
|
1040 retval = f (*v1.rep, *v2.rep); |
|
1041 else |
|
1042 { |
|
1043 octave_value tv1; |
2427
|
1044 type_conv_fcn cf1 = v1.numeric_conversion_function (); |
2376
|
1045 |
|
1046 if (cf1) |
|
1047 { |
3203
|
1048 octave_value *tmp = cf1 (*v1.rep); |
|
1049 |
|
1050 if (tmp) |
|
1051 { |
|
1052 tv1 = octave_value (tmp); |
|
1053 t1 = tv1.type_id (); |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1058 return retval; |
|
1059 } |
2376
|
1060 } |
|
1061 else |
|
1062 tv1 = v1; |
|
1063 |
|
1064 octave_value tv2; |
2427
|
1065 type_conv_fcn cf2 = v2.numeric_conversion_function (); |
2376
|
1066 |
|
1067 if (cf2) |
|
1068 { |
3203
|
1069 octave_value *tmp = cf2 (*v2.rep); |
|
1070 |
|
1071 if (tmp) |
|
1072 { |
|
1073 tv2 = octave_value (tmp); |
|
1074 t2 = tv2.type_id (); |
|
1075 } |
|
1076 else |
|
1077 { |
|
1078 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1079 return retval; |
|
1080 } |
2376
|
1081 } |
|
1082 else |
|
1083 tv2 = v2; |
|
1084 |
|
1085 if (cf1 || cf2) |
|
1086 { |
2427
|
1087 binary_op_fcn f |
2376
|
1088 = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
|
1089 |
|
1090 if (f) |
|
1091 retval = f (*tv1.rep, *tv2.rep); |
|
1092 else |
|
1093 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1094 v1.type_name (), v2.type_name ()); |
|
1095 } |
|
1096 else |
|
1097 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1098 v1.type_name (), v2.type_name ()); |
|
1099 } |
|
1100 |
|
1101 return retval; |
|
1102 } |
|
1103 |
3203
|
1104 static void |
|
1105 gripe_unary_op (const string& on, const string& tn) |
|
1106 { |
|
1107 error ("unary operator `%s' not implemented for `%s' operands", |
|
1108 on.c_str (), tn.c_str ()); |
|
1109 } |
|
1110 |
|
1111 static void |
|
1112 gripe_unary_op_conv (const string& on) |
|
1113 { |
|
1114 error ("type conversion failed for unary operator `%s'", on.c_str ()); |
|
1115 } |
|
1116 |
|
1117 octave_value |
|
1118 do_unary_op (octave_value::unary_op op, const octave_value& v) |
|
1119 { |
|
1120 octave_value retval; |
|
1121 |
|
1122 int t = v.type_id (); |
|
1123 |
|
1124 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1125 |
|
1126 if (f) |
|
1127 retval = f (*v.rep); |
|
1128 else |
|
1129 { |
|
1130 octave_value tv; |
|
1131 type_conv_fcn cf = v.numeric_conversion_function (); |
|
1132 |
|
1133 if (cf) |
|
1134 { |
|
1135 octave_value *tmp = cf (*v.rep); |
|
1136 |
|
1137 if (tmp) |
|
1138 { |
|
1139 tv = octave_value (tmp); |
|
1140 t = tv.type_id (); |
|
1141 |
|
1142 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1143 |
|
1144 if (f) |
|
1145 retval = f (*tv.rep); |
|
1146 else |
|
1147 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1148 v.type_name ()); |
|
1149 } |
|
1150 else |
|
1151 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
|
1152 } |
|
1153 else |
|
1154 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1155 v.type_name ()); |
|
1156 } |
|
1157 |
|
1158 return retval; |
|
1159 } |
|
1160 |
|
1161 static void |
|
1162 gripe_unary_op_conversion_failed (const string& op, const string& tn) |
|
1163 { |
|
1164 error ("operator %s: type conversion for `%s' failed", |
|
1165 op.c_str (), tn.c_str ()); |
|
1166 } |
|
1167 |
|
1168 void |
|
1169 octave_value::do_non_const_unary_op (octave_value::unary_op op) |
|
1170 { |
|
1171 octave_value retval; |
|
1172 |
|
1173 int t = type_id (); |
|
1174 |
|
1175 non_const_unary_op_fcn f |
|
1176 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1177 |
|
1178 if (f) |
|
1179 { |
|
1180 make_unique (); |
|
1181 |
|
1182 f (*rep); |
|
1183 } |
|
1184 else |
|
1185 { |
|
1186 type_conv_fcn cf = numeric_conversion_function (); |
|
1187 |
|
1188 if (cf) |
|
1189 { |
|
1190 octave_value *tmp = cf (*rep); |
|
1191 |
|
1192 if (tmp) |
|
1193 { |
|
1194 octave_value *old_rep = rep; |
|
1195 rep = tmp; |
|
1196 rep->count = 1; |
|
1197 |
|
1198 t = type_id (); |
|
1199 |
|
1200 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1201 |
|
1202 if (f) |
|
1203 { |
|
1204 f (*rep); |
|
1205 |
|
1206 if (old_rep && --old_rep->count == 0) |
|
1207 delete old_rep; |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 if (old_rep) |
|
1212 { |
|
1213 if (--rep->count == 0) |
|
1214 delete rep; |
|
1215 |
|
1216 rep = old_rep; |
|
1217 } |
|
1218 |
|
1219 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1220 type_name ()); |
|
1221 } |
|
1222 } |
|
1223 else |
|
1224 gripe_unary_op_conversion_failed |
|
1225 (octave_value::unary_op_as_string (op), type_name ()); |
|
1226 } |
|
1227 else |
|
1228 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
|
1229 } |
|
1230 } |
|
1231 |
2903
|
1232 // Current indentation. |
|
1233 int octave_value::curr_print_indent_level = 0; |
|
1234 |
3018
|
1235 // TRUE means we are at the beginning of a line. |
2903
|
1236 bool octave_value::beginning_of_line = true; |
|
1237 |
|
1238 // Each print() function should call this before printing anything. |
|
1239 // |
|
1240 // This doesn't need to be fast, but isn't there a better way? |
|
1241 |
|
1242 void |
|
1243 octave_value::indent (ostream& os) const |
|
1244 { |
|
1245 assert (curr_print_indent_level >= 0); |
|
1246 |
|
1247 if (beginning_of_line) |
|
1248 { |
|
1249 // XXX FIXME XXX -- do we need this? |
|
1250 // os << prefix; |
|
1251 |
|
1252 for (int i = 0; i < curr_print_indent_level; i++) |
|
1253 os << " "; |
|
1254 |
|
1255 beginning_of_line = false; |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 // All print() functions should use this to print new lines. |
|
1260 |
|
1261 void |
|
1262 octave_value::newline (ostream& os) const |
|
1263 { |
|
1264 os << "\n"; |
|
1265 |
|
1266 beginning_of_line = true; |
|
1267 } |
|
1268 |
|
1269 // For ressetting print state. |
|
1270 |
|
1271 void |
|
1272 octave_value::reset (void) const |
|
1273 { |
|
1274 beginning_of_line = true; |
|
1275 curr_print_indent_level = 0; |
|
1276 } |
|
1277 |
3204
|
1278 octave_value::binary_op |
|
1279 octave_value::op_eq_to_binary_op (assign_op op) |
|
1280 { |
|
1281 binary_op binop = unknown_binary_op; |
|
1282 |
|
1283 switch (op) |
|
1284 { |
|
1285 case add_eq: |
|
1286 binop = add; |
|
1287 break; |
|
1288 |
|
1289 case sub_eq: |
|
1290 binop = sub; |
|
1291 break; |
|
1292 |
|
1293 case mul_eq: |
|
1294 binop = mul; |
|
1295 break; |
|
1296 |
|
1297 case div_eq: |
|
1298 binop = div; |
|
1299 break; |
|
1300 |
|
1301 case ldiv_eq: |
|
1302 binop = ldiv; |
|
1303 break; |
|
1304 |
|
1305 case lshift_eq: |
|
1306 binop = lshift; |
|
1307 break; |
|
1308 |
|
1309 case rshift_eq: |
|
1310 binop = rshift; |
|
1311 break; |
|
1312 |
|
1313 case el_mul_eq: |
|
1314 binop = el_mul; |
|
1315 break; |
|
1316 |
|
1317 case el_div_eq: |
|
1318 binop = el_div; |
|
1319 break; |
|
1320 |
|
1321 case el_ldiv_eq: |
|
1322 binop = el_ldiv; |
|
1323 break; |
|
1324 |
|
1325 case el_and_eq: |
|
1326 binop = el_and; |
|
1327 break; |
|
1328 |
|
1329 case el_or_eq: |
|
1330 binop = el_or; |
|
1331 break; |
|
1332 |
|
1333 default: |
|
1334 { |
|
1335 string on = assign_op_as_string (op); |
|
1336 error ("operator %s: no binary operator found", on.c_str ()); |
|
1337 } |
|
1338 } |
|
1339 |
|
1340 return binop; |
|
1341 } |
|
1342 |
2376
|
1343 void |
|
1344 install_types (void) |
|
1345 { |
|
1346 octave_base_value::register_type (); |
|
1347 octave_scalar::register_type (); |
|
1348 octave_complex::register_type (); |
|
1349 octave_matrix::register_type (); |
|
1350 octave_complex_matrix::register_type (); |
|
1351 octave_range::register_type (); |
2825
|
1352 octave_bool::register_type (); |
|
1353 octave_bool_matrix::register_type (); |
2376
|
1354 octave_char_matrix::register_type (); |
|
1355 octave_char_matrix_str::register_type (); |
|
1356 octave_struct::register_type (); |
2903
|
1357 octave_file::register_type (); |
2880
|
1358 octave_list::register_type (); |
2376
|
1359 octave_all_va_args::register_type (); |
|
1360 octave_magic_colon::register_type (); |
2974
|
1361 octave_builtin::register_type (); |
|
1362 octave_mapper::register_type (); |
|
1363 octave_user_function::register_type (); |
2376
|
1364 } |
|
1365 |
|
1366 static int |
|
1367 do_fortran_indexing (void) |
|
1368 { |
|
1369 Vdo_fortran_indexing = check_preference ("do_fortran_indexing"); |
|
1370 |
|
1371 liboctave_dfi_flag = Vdo_fortran_indexing; |
|
1372 |
|
1373 return 0; |
|
1374 } |
|
1375 |
|
1376 static int |
|
1377 implicit_str_to_num_ok (void) |
|
1378 { |
|
1379 Vimplicit_str_to_num_ok = check_preference ("implicit_str_to_num_ok"); |
|
1380 |
|
1381 return 0; |
|
1382 } |
|
1383 |
|
1384 static int |
|
1385 ok_to_lose_imaginary_part (void) |
|
1386 { |
|
1387 Vok_to_lose_imaginary_part = check_preference ("ok_to_lose_imaginary_part"); |
|
1388 |
|
1389 return 0; |
|
1390 } |
|
1391 |
|
1392 static int |
|
1393 prefer_column_vectors (void) |
|
1394 { |
|
1395 Vprefer_column_vectors |
|
1396 = check_preference ("prefer_column_vectors"); |
|
1397 |
|
1398 liboctave_pcv_flag = Vprefer_column_vectors; |
|
1399 |
|
1400 return 0; |
|
1401 } |
|
1402 |
|
1403 static int |
|
1404 print_answer_id_name (void) |
|
1405 { |
|
1406 Vprint_answer_id_name = check_preference ("print_answer_id_name"); |
|
1407 |
|
1408 return 0; |
|
1409 } |
|
1410 |
|
1411 static int |
|
1412 propagate_empty_matrices (void) |
|
1413 { |
|
1414 Vpropagate_empty_matrices = check_preference ("propagate_empty_matrices"); |
|
1415 |
|
1416 return 0; |
|
1417 } |
|
1418 |
|
1419 static int |
|
1420 resize_on_range_error (void) |
|
1421 { |
|
1422 Vresize_on_range_error = check_preference ("resize_on_range_error"); |
|
1423 |
|
1424 liboctave_rre_flag = Vresize_on_range_error; |
|
1425 |
|
1426 return 0; |
|
1427 } |
|
1428 |
|
1429 static int |
|
1430 struct_levels_to_print (void) |
|
1431 { |
|
1432 double val; |
|
1433 if (builtin_real_scalar_variable ("struct_levels_to_print", val) |
|
1434 && ! xisnan (val)) |
|
1435 { |
|
1436 int ival = NINT (val); |
2800
|
1437 if (ival >= 0 && ival == val) |
2376
|
1438 { |
|
1439 Vstruct_levels_to_print = ival; |
|
1440 return 0; |
|
1441 } |
|
1442 } |
|
1443 gripe_invalid_value_specified ("struct_levels_to_print"); |
|
1444 return -1; |
|
1445 } |
|
1446 |
|
1447 static int |
|
1448 warn_divide_by_zero (void) |
|
1449 { |
|
1450 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
1451 |
|
1452 return 0; |
|
1453 } |
|
1454 |
|
1455 void |
2909
|
1456 symbols_of_ov (void) |
2376
|
1457 { |
|
1458 DEFVAR (do_fortran_indexing, 0.0, 0, do_fortran_indexing, |
|
1459 "allow single indices for matrices"); |
|
1460 |
|
1461 DEFVAR (implicit_str_to_num_ok, 0.0, 0, implicit_str_to_num_ok, |
|
1462 "allow implicit string to number conversion"); |
|
1463 |
|
1464 DEFVAR (ok_to_lose_imaginary_part, "warn", 0, ok_to_lose_imaginary_part, |
|
1465 "silently convert from complex to real by dropping imaginary part"); |
|
1466 |
|
1467 DEFVAR (prefer_column_vectors, 1.0, 0, prefer_column_vectors, |
|
1468 "prefer column/row vectors"); |
|
1469 |
|
1470 DEFVAR (print_answer_id_name, 1.0, 0, print_answer_id_name, |
|
1471 "set output style to print `var_name = ...'"); |
|
1472 |
|
1473 DEFVAR (propagate_empty_matrices, 1.0, 0, propagate_empty_matrices, |
|
1474 "operations on empty matrices return an empty matrix, not an error"); |
|
1475 |
|
1476 DEFVAR (resize_on_range_error, 1.0, 0, resize_on_range_error, |
|
1477 "enlarge matrices on assignment"); |
|
1478 |
|
1479 DEFVAR (struct_levels_to_print, 2.0, 0, struct_levels_to_print, |
|
1480 "number of levels of structure elements to print"); |
|
1481 |
|
1482 DEFVAR (warn_divide_by_zero, 1.0, 0, warn_divide_by_zero, |
2957
|
1483 "if TRUE, warn about division by zero"); |
2376
|
1484 } |
|
1485 |
|
1486 /* |
|
1487 ;;; Local Variables: *** |
|
1488 ;;; mode: C++ *** |
|
1489 ;;; End: *** |
|
1490 */ |