GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
5 
6 This file is part of Octave.
7 
8 Octave is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include "data-conv.h"
29 #include "quit.h"
30 #include "str-vec.h"
31 
32 #include "oct-obj.h"
33 #include "oct-stream.h"
34 #include "ov.h"
35 #include "ov-base.h"
36 #include "ov-bool.h"
37 #include "ov-bool-mat.h"
38 #include "ov-cell.h"
39 #include "ov-scalar.h"
40 #include "ov-float.h"
41 #include "ov-re-mat.h"
42 #include "ov-flt-re-mat.h"
43 #include "ov-re-diag.h"
44 #include "ov-flt-re-diag.h"
45 #include "ov-perm.h"
46 #include "ov-bool-sparse.h"
47 #include "ov-cx-sparse.h"
48 #include "ov-re-sparse.h"
49 #include "ov-int8.h"
50 #include "ov-int16.h"
51 #include "ov-int32.h"
52 #include "ov-int64.h"
53 #include "ov-uint8.h"
54 #include "ov-uint16.h"
55 #include "ov-uint32.h"
56 #include "ov-uint64.h"
57 #include "ov-complex.h"
58 #include "ov-flt-complex.h"
59 #include "ov-cx-mat.h"
60 #include "ov-flt-cx-mat.h"
61 #include "ov-cx-diag.h"
62 #include "ov-flt-cx-diag.h"
63 #include "ov-ch-mat.h"
64 #include "ov-str-mat.h"
65 #include "ov-range.h"
66 #include "ov-struct.h"
67 #include "ov-class.h"
68 #include "ov-classdef.h"
69 #include "ov-oncleanup.h"
70 #include "ov-cs-list.h"
71 #include "ov-colon.h"
72 #include "ov-builtin.h"
73 #include "ov-dld-fcn.h"
74 #include "ov-usr-fcn.h"
75 #include "ov-fcn-handle.h"
76 #include "ov-fcn-inline.h"
77 #include "ov-typeinfo.h"
78 #include "ov-null-mat.h"
79 #include "ov-lazy-idx.h"
80 #ifdef HAVE_JAVA
81 #include "ov-java.h"
82 #endif
83 
84 #include "defun.h"
85 #include "error.h"
86 #include "gripes.h"
87 #include "pager.h"
88 #include "parse.h"
89 #include "pr-output.h"
90 #include "symtab.h"
91 #include "utils.h"
92 #include "variables.h"
93 
94 // We are likely to have a lot of octave_value objects to allocate, so
95 // make the grow_size large.
96 
97 // If TRUE, don't create special diagonal matrix objects.
98 
99 static bool Vdisable_diagonal_matrix = false;
100 
101 // If TRUE, don't create special permutation matrix objects.
102 
103 static bool Vdisable_permutation_matrix = false;
104 
105 // If TRUE, don't create special range objects.
106 
107 static bool Vdisable_range = false;
108 
109 // FIXME
110 
111 // Octave's value type.
112 
113 std::string
115 {
116  std::string retval;
117 
118  switch (op)
119  {
120  case op_not:
121  retval = "!";
122  break;
123 
124  case op_uplus:
125  retval = "+";
126  break;
127 
128  case op_uminus:
129  retval = "-";
130  break;
131 
132  case op_transpose:
133  retval = ".'";
134  break;
135 
136  case op_hermitian:
137  retval = "'";
138  break;
139 
140  case op_incr:
141  retval = "++";
142  break;
143 
144  case op_decr:
145  retval = "--";
146  break;
147 
148  default:
149  retval = "<unknown>";
150  }
151 
152  return retval;
153 }
154 
155 std::string
157 {
158  std::string retval;
159 
160  switch (op)
161  {
162  case op_not:
163  retval = "not";
164  break;
165 
166  case op_uplus:
167  retval = "uplus";
168  break;
169 
170  case op_uminus:
171  retval = "uminus";
172  break;
173 
174  case op_transpose:
175  retval = "transpose";
176  break;
177 
178  case op_hermitian:
179  retval = "ctranspose";
180  break;
181 
182  default:
183  break;
184  }
185 
186  return retval;
187 }
188 
189 std::string
191 {
192  std::string retval;
193 
194  switch (op)
195  {
196  case op_add:
197  retval = "+";
198  break;
199 
200  case op_sub:
201  retval = "-";
202  break;
203 
204  case op_mul:
205  retval = "*";
206  break;
207 
208  case op_div:
209  retval = "/";
210  break;
211 
212  case op_pow:
213  retval = "^";
214  break;
215 
216  case op_ldiv:
217  retval = "\\";
218  break;
219 
220  case op_lshift:
221  retval = "<<";
222  break;
223 
224  case op_rshift:
225  retval = ">>";
226  break;
227 
228  case op_lt:
229  retval = "<";
230  break;
231 
232  case op_le:
233  retval = "<=";
234  break;
235 
236  case op_eq:
237  retval = "==";
238  break;
239 
240  case op_ge:
241  retval = ">=";
242  break;
243 
244  case op_gt:
245  retval = ">";
246  break;
247 
248  case op_ne:
249  retval = "!=";
250  break;
251 
252  case op_el_mul:
253  retval = ".*";
254  break;
255 
256  case op_el_div:
257  retval = "./";
258  break;
259 
260  case op_el_pow:
261  retval = ".^";
262  break;
263 
264  case op_el_ldiv:
265  retval = ".\\";
266  break;
267 
268  case op_el_and:
269  retval = "&";
270  break;
271 
272  case op_el_or:
273  retval = "|";
274  break;
275 
276  case op_struct_ref:
277  retval = ".";
278  break;
279 
280  default:
281  retval = "<unknown>";
282  }
283 
284  return retval;
285 }
286 
287 std::string
289 {
290  std::string retval;
291 
292  switch (op)
293  {
294  case op_add:
295  retval = "plus";
296  break;
297 
298  case op_sub:
299  retval = "minus";
300  break;
301 
302  case op_mul:
303  retval = "mtimes";
304  break;
305 
306  case op_div:
307  retval = "mrdivide";
308  break;
309 
310  case op_pow:
311  retval = "mpower";
312  break;
313 
314  case op_ldiv:
315  retval = "mldivide";
316  break;
317 
318  case op_lt:
319  retval = "lt";
320  break;
321 
322  case op_le:
323  retval = "le";
324  break;
325 
326  case op_eq:
327  retval = "eq";
328  break;
329 
330  case op_ge:
331  retval = "ge";
332  break;
333 
334  case op_gt:
335  retval = "gt";
336  break;
337 
338  case op_ne:
339  retval = "ne";
340  break;
341 
342  case op_el_mul:
343  retval = "times";
344  break;
345 
346  case op_el_div:
347  retval = "rdivide";
348  break;
349 
350  case op_el_pow:
351  retval = "power";
352  break;
353 
354  case op_el_ldiv:
355  retval = "ldivide";
356  break;
357 
358  case op_el_and:
359  retval = "and";
360  break;
361 
362  case op_el_or:
363  retval = "or";
364  break;
365 
366  default:
367  break;
368  }
369 
370  return retval;
371 }
372 
373 std::string
375 {
376  std::string retval;
377 
378  switch (op)
379  {
380  case op_trans_mul:
381  retval = "transtimes";
382  break;
383 
384  case op_mul_trans:
385  retval = "timestrans";
386  break;
387 
388  case op_herm_mul:
389  retval = "hermtimes";
390  break;
391 
392  case op_mul_herm:
393  retval = "timesherm";
394  break;
395 
396  case op_trans_ldiv:
397  retval = "transldiv";
398  break;
399 
400  case op_herm_ldiv:
401  retval = "hermldiv";
402  break;
403 
404  case op_el_and_not:
405  retval = "andnot";
406  break;
407 
408  case op_el_or_not:
409  retval = "ornot";
410  break;
411 
412  case op_el_not_and:
413  retval = "notand";
414  break;
415 
416  case op_el_not_or:
417  retval = "notor";
418  break;
419 
420  default:
421  break;
422  }
423 
424  return retval;
425 }
426 
427 std::string
429 {
430  std::string retval;
431 
432  switch (op)
433  {
434  case op_asn_eq:
435  retval = "=";
436  break;
437 
438  case op_add_eq:
439  retval = "+=";
440  break;
441 
442  case op_sub_eq:
443  retval = "-=";
444  break;
445 
446  case op_mul_eq:
447  retval = "*=";
448  break;
449 
450  case op_div_eq:
451  retval = "/=";
452  break;
453 
454  case op_ldiv_eq:
455  retval = "\\=";
456  break;
457 
458  case op_pow_eq:
459  retval = "^=";
460  break;
461 
462  case op_lshift_eq:
463  retval = "<<=";
464  break;
465 
466  case op_rshift_eq:
467  retval = ">>=";
468  break;
469 
470  case op_el_mul_eq:
471  retval = ".*=";
472  break;
473 
474  case op_el_div_eq:
475  retval = "./=";
476  break;
477 
478  case op_el_ldiv_eq:
479  retval = ".\\=";
480  break;
481 
482  case op_el_pow_eq:
483  retval = ".^=";
484  break;
485 
486  case op_el_and_eq:
487  retval = "&=";
488  break;
489 
490  case op_el_or_eq:
491  retval = "|=";
492  break;
493 
494  default:
495  retval = "<unknown>";
496  }
497 
498  return retval;
499 }
500 
503 {
504  switch (op)
505  {
506  case op_add_eq:
507  return op_add;
508  case op_sub_eq:
509  return op_sub;
510  case op_mul_eq:
511  return op_mul;
512  case op_div_eq:
513  return op_div;
514  case op_ldiv_eq:
515  return op_ldiv;
516  case op_pow_eq:
517  return op_pow;
518  case op_lshift_eq:
519  return op_lshift;
520  case op_rshift_eq:
521  return op_rshift;
522  case op_el_mul_eq:
523  return op_el_mul;
524  case op_el_div_eq:
525  return op_el_div;
526  case op_el_ldiv_eq:
527  return op_el_ldiv;
528  case op_el_pow_eq:
529  return op_el_pow;
530  case op_el_and_eq:
531  return op_el_and;
532  case op_el_or_eq:
533  return op_el_or;
534  default:
535  return unknown_binary_op;
536  }
537 
538 }
539 
542 {
543  assign_op retval;
544 
545  switch (op)
546  {
547  case op_add:
548  retval = op_add_eq;
549  break;
550  case op_sub:
551  retval = op_sub_eq;
552  break;
553  case op_mul:
554  retval = op_mul_eq;
555  break;
556  case op_div:
557  retval = op_div_eq;
558  break;
559  case op_el_mul:
560  retval = op_el_mul_eq;
561  break;
562  case op_el_div:
563  retval = op_el_div_eq;
564  break;
565  case op_el_and:
566  retval = op_el_and_eq;
567  break;
568  case op_el_or:
569  retval = op_el_or_eq;
570  break;
571  default:
572  retval = unknown_assign_op;
573  }
574 
575  return retval;
576 }
577 
579  : rep (new octave_scalar (i))
580 {
581 }
582 
583 octave_value::octave_value (unsigned short int i)
584  : rep (new octave_scalar (i))
585 {
586 }
587 
589  : rep (new octave_scalar (i))
590 {
591 }
592 
594  : rep (new octave_scalar (i))
595 {
596 }
597 
599  : rep (new octave_scalar (i))
600 {
601 }
602 
603 octave_value::octave_value (unsigned long int i)
604  : rep (new octave_scalar (i))
605 {
606 }
607 
608 #if defined (HAVE_LONG_LONG_INT)
609 octave_value::octave_value (long long int i)
610  : rep (new octave_scalar (i))
611 {
612 }
613 #endif
614 
615 #if defined (HAVE_UNSIGNED_LONG_LONG_INT)
616 octave_value::octave_value (unsigned long long int i)
617  : rep (new octave_scalar (i))
618 {
619 }
620 #endif
621 
623  : rep (new octave_scalar (t.double_value ()))
624 {
625 }
626 
628  : rep (new octave_scalar (d))
629 {
630 }
631 
633  : rep (new octave_float_scalar (d))
634 {
635 }
636 
637 octave_value::octave_value (const Cell& c, bool is_csl)
638  : rep (is_csl
639  ? dynamic_cast<octave_base_value *> (new octave_cs_list (c))
640  : dynamic_cast<octave_base_value *> (new octave_cell (c)))
641 {
642 }
643 
645  : rep (is_csl
646  ? dynamic_cast<octave_base_value *> (new octave_cs_list (Cell (a)))
647  : dynamic_cast<octave_base_value *> (new octave_cell (Cell (a))))
648 {
649 }
650 
652  : rep (new octave_matrix (m, t))
653 {
654  maybe_mutate ();
655 }
656 
658  : rep (new octave_float_matrix (m, t))
659 {
660  maybe_mutate ();
661 }
662 
664  : rep (new octave_matrix (a))
665 {
666  maybe_mutate ();
667 }
668 
670  : rep (new octave_float_matrix (a))
671 {
672  maybe_mutate ();
673 }
674 
676  : rep (new octave_matrix (a))
677 {
678  maybe_mutate ();
679 }
680 
682  : rep (new octave_float_matrix (a))
683 {
684  maybe_mutate ();
685 }
686 
689  ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))
690  : dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)))
691 {
692  maybe_mutate ();
693 }
694 
697  ? dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))
698  : dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)))
699 {
700  maybe_mutate ();
701 }
702 
705  ? dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))
706  : dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)))
707 {
708  maybe_mutate ();
709 }
710 
714  : dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)))
715 {
716  maybe_mutate ();
717 }
718 
721  ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))
722  : dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)))
723 {
724  maybe_mutate ();
725 }
726 
729  ? dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))
730  : dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)))
731 {
732  maybe_mutate ();
733 }
734 
736  : rep (new octave_matrix (v))
737 {
738  maybe_mutate ();
739 }
740 
742  : rep (new octave_float_matrix (v))
743 {
744  maybe_mutate ();
745 }
746 
748  : rep (new octave_matrix (v))
749 {
750  maybe_mutate ();
751 }
752 
754  : rep (new octave_float_matrix (v))
755 {
756  maybe_mutate ();
757 }
758 
760  : rep (new octave_complex (C))
761 {
762  maybe_mutate ();
763 }
764 
766  : rep (new octave_float_complex (C))
767 {
768  maybe_mutate ();
769 }
770 
772  : rep (new octave_complex_matrix (m, t))
773 {
774  maybe_mutate ();
775 }
776 
778  : rep (new octave_float_complex_matrix (m, t))
779 {
780  maybe_mutate ();
781 }
782 
784  : rep (new octave_complex_matrix (a))
785 {
786  maybe_mutate ();
787 }
788 
790  : rep (new octave_float_complex_matrix (a))
791 {
792  maybe_mutate ();
793 }
794 
796  : rep (new octave_complex_matrix (a))
797 {
798  maybe_mutate ();
799 }
800 
802  : rep (new octave_float_complex_matrix (a))
803 {
804  maybe_mutate ();
805 }
806 
809  ? dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))
810  : dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)))
811 {
812  maybe_mutate ();
813 }
814 
818  : dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)))
819 {
820  maybe_mutate ();
821 }
822 
824  : rep (new octave_complex_matrix (v))
825 {
826  maybe_mutate ();
827 }
828 
830  : rep (new octave_float_complex_matrix (v))
831 {
832  maybe_mutate ();
833 }
834 
836  : rep (new octave_complex_matrix (v))
837 {
838  maybe_mutate ();
839 }
840 
842  : rep (new octave_float_complex_matrix (v))
843 {
844  maybe_mutate ();
845 }
846 
849  ? dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (p)))
850  : dynamic_cast<octave_base_value *> (new octave_perm_matrix (p)))
851 {
852  maybe_mutate ();
853 }
854 
856  : rep (new octave_bool (b))
857 {
858 }
859 
861  : rep (new octave_bool_matrix (bm, t))
862 {
863  maybe_mutate ();
864 }
865 
867  : rep (new octave_bool_matrix (bnda))
868 {
869  maybe_mutate ();
870 }
871 
873  : rep (new octave_bool_matrix (bnda))
874 {
875  maybe_mutate ();
876 }
877 
879  : rep (type == '"'
880  ? new octave_char_matrix_dq_str (c)
881  : new octave_char_matrix_sq_str (c))
882 {
883  maybe_mutate ();
884 }
885 
886 octave_value::octave_value (const char *s, char type)
887  : rep (type == '"'
888  ? new octave_char_matrix_dq_str (s)
889  : new octave_char_matrix_sq_str (s))
890 {
891  maybe_mutate ();
892 }
893 
894 octave_value::octave_value (const std::string& s, char type)
895  : rep (type == '"'
896  ? new octave_char_matrix_dq_str (s)
897  : new octave_char_matrix_sq_str (s))
898 {
899  maybe_mutate ();
900 }
901 
903  : rep (type == '"'
904  ? new octave_char_matrix_dq_str (s)
905  : new octave_char_matrix_sq_str (s))
906 {
907  maybe_mutate ();
908 }
909 
911  : rep (type == '"'
912  ? new octave_char_matrix_dq_str (chm)
913  : new octave_char_matrix_sq_str (chm))
914 {
915  maybe_mutate ();
916 }
917 
919  : rep (type == '"'
920  ? new octave_char_matrix_dq_str (chm)
921  : new octave_char_matrix_sq_str (chm))
922 {
923  maybe_mutate ();
924 }
925 
927  : rep (type == '"'
928  ? new octave_char_matrix_dq_str (chm)
929  : new octave_char_matrix_sq_str (chm))
930 {
931  maybe_mutate ();
932 }
933 
934 octave_value::octave_value (const charMatrix& chm, bool, char type)
935  : rep (type == '"'
936  ? new octave_char_matrix_dq_str (chm)
937  : new octave_char_matrix_sq_str (chm))
938 {
939  maybe_mutate ();
940 }
941 
943  : rep (type == '"'
944  ? new octave_char_matrix_dq_str (chm)
945  : new octave_char_matrix_sq_str (chm))
946 {
947  maybe_mutate ();
948 }
949 
950 octave_value::octave_value (const Array<char>& chm, bool, char type)
951  : rep (type == '"'
952  ? new octave_char_matrix_dq_str (chm)
953  : new octave_char_matrix_sq_str (chm))
954 {
955  maybe_mutate ();
956 }
957 
959  : rep (new octave_sparse_matrix (m, t))
960 {
961  maybe_mutate ();
962 }
963 
965  : rep (new octave_sparse_matrix (m, t))
966 {
967  maybe_mutate ();
968 }
969 
971  : rep (new octave_sparse_complex_matrix (m, t))
972 {
973  maybe_mutate ();
974 }
975 
977  : rep (new octave_sparse_complex_matrix (m, t))
978 {
979  maybe_mutate ();
980 }
981 
983  : rep (new octave_sparse_bool_matrix (bm, t))
984 {
985  maybe_mutate ();
986 }
987 
989  : rep (new octave_sparse_bool_matrix (bm, t))
990 {
991  maybe_mutate ();
992 }
993 
995  : rep (new octave_int8_scalar (i))
996 {
997  maybe_mutate ();
998 }
999 
1001  : rep (new octave_uint8_scalar (i))
1002 {
1003  maybe_mutate ();
1004 }
1005 
1007  : rep (new octave_int16_scalar (i))
1008 {
1009  maybe_mutate ();
1010 }
1011 
1013  : rep (new octave_uint16_scalar (i))
1014 {
1015  maybe_mutate ();
1016 }
1017 
1019  : rep (new octave_int32_scalar (i))
1020 {
1021  maybe_mutate ();
1022 }
1023 
1025  : rep (new octave_uint32_scalar (i))
1026 {
1027  maybe_mutate ();
1028 }
1029 
1031  : rep (new octave_int64_scalar (i))
1032 {
1033  maybe_mutate ();
1034 }
1035 
1037  : rep (new octave_uint64_scalar (i))
1038 {
1039  maybe_mutate ();
1040 }
1041 
1043  : rep (new octave_int8_matrix (inda))
1044 {
1045  maybe_mutate ();
1046 }
1047 
1049  : rep (new octave_int8_matrix (inda))
1050 {
1051  maybe_mutate ();
1052 }
1053 
1055  : rep (new octave_uint8_matrix (inda))
1056 {
1057  maybe_mutate ();
1058 }
1059 
1061  : rep (new octave_uint8_matrix (inda))
1062 {
1063  maybe_mutate ();
1064 }
1065 
1067  : rep (new octave_int16_matrix (inda))
1068 {
1069  maybe_mutate ();
1070 }
1071 
1073  : rep (new octave_int16_matrix (inda))
1074 {
1075  maybe_mutate ();
1076 }
1077 
1079  : rep (new octave_uint16_matrix (inda))
1080 {
1081  maybe_mutate ();
1082 }
1083 
1085  : rep (new octave_uint16_matrix (inda))
1086 {
1087  maybe_mutate ();
1088 }
1089 
1091  : rep (new octave_int32_matrix (inda))
1092 {
1093  maybe_mutate ();
1094 }
1095 
1097  : rep (new octave_int32_matrix (inda))
1098 {
1099  maybe_mutate ();
1100 }
1101 
1103  : rep (new octave_uint32_matrix (inda))
1104 {
1105  maybe_mutate ();
1106 }
1107 
1109  : rep (new octave_uint32_matrix (inda))
1110 {
1111  maybe_mutate ();
1112 }
1113 
1115  : rep (new octave_int64_matrix (inda))
1116 {
1117  maybe_mutate ();
1118 }
1119 
1121  : rep (new octave_int64_matrix (inda))
1122 {
1123  maybe_mutate ();
1124 }
1125 
1127  : rep (new octave_uint64_matrix (inda))
1128 {
1129  maybe_mutate ();
1130 }
1131 
1133  : rep (new octave_uint64_matrix (inda))
1134 {
1135  maybe_mutate ();
1136 }
1137 
1139  bool cache_index)
1140  : rep (new octave_matrix (inda, zero_based, cache_index))
1141 {
1142  maybe_mutate ();
1143 }
1144 
1146  : rep ()
1147 {
1148  double scalar;
1149  Range range;
1150  NDArray array;
1151  boolNDArray mask;
1152  idx_vector::idx_class_type idx_class;
1153 
1154  if (lazy)
1155  {
1156  // Only make lazy indices out of ranges and index vectors.
1157  switch (idx.idx_class ())
1158  {
1161  rep = new octave_lazy_index (idx);
1162  maybe_mutate ();
1163  return;
1164  default:
1165  break;
1166  }
1167  }
1168 
1169  idx.unconvert (idx_class, scalar, range, array, mask);
1170 
1171  switch (idx_class)
1172  {
1174  rep = new octave_magic_colon ();
1175  break;
1177  rep = new octave_range (range, idx);
1178  break;
1180  rep = new octave_scalar (scalar);
1181  break;
1183  rep = new octave_matrix (array, idx);
1184  break;
1186  rep = new octave_bool_matrix (mask, idx);
1187  break;
1188  default:
1189  assert (false);
1190  break;
1191  }
1192 
1193  // FIXME: needed?
1194  maybe_mutate ();
1195 }
1196 
1198  : rep (new octave_cell (cellstr))
1199 {
1200  maybe_mutate ();
1201 }
1202 
1203 octave_value::octave_value (double base, double limit, double inc)
1204  : rep (new octave_range (base, limit, inc))
1205 {
1206  maybe_mutate ();
1207 }
1208 
1209 octave_value::octave_value (const Range& r, bool force_range)
1210  : rep (force_range || ! Vdisable_range
1211  ? dynamic_cast<octave_base_value *> (new octave_range (r))
1212  : dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())))
1213 {
1214  maybe_mutate ();
1215 }
1216 
1218  : rep (new octave_struct (m))
1219 {
1220  maybe_mutate ();
1221 }
1222 
1224  : rep (new octave_scalar_struct (m))
1225 {
1226 }
1227 
1228 octave_value::octave_value (const octave_map& m, const std::string& id,
1229  const std::list<std::string>& plist)
1230  : rep (new octave_class (m, id, plist))
1231 {
1232  maybe_mutate ();
1233 }
1234 
1235 octave_value::octave_value (const octave_scalar_map& m, const std::string& id,
1236  const std::list<std::string>& plist)
1237  : rep (new octave_class (m, id, plist))
1238 {
1239 }
1240 
1242  : rep (new octave_cs_list (l))
1243 {
1244 }
1245 
1247  : rep (new octave_magic_colon ())
1248 {
1249 }
1250 
1252  : rep (new_rep)
1253 {
1254  if (borrow)
1255  rep->count++;
1256 }
1257 
1258 octave_value::octave_value (octave_base_value *new_rep, int xcount)
1259  : rep (new_rep)
1260 {
1261  rep->count = xcount;
1262 }
1263 
1266 {
1267  return rep->clone ();
1268 }
1269 
1270 void
1272 {
1274 
1275  if (tmp && tmp != rep)
1276  {
1277  if (--rep->count == 0)
1278  delete rep;
1279 
1280  rep = tmp;
1281  }
1282 }
1283 
1286  const octave_value_list& idx)
1287 {
1288  std::list<octave_value_list> i;
1289 
1290  i.push_back (idx);
1291 
1292  return rep->subsref (type, i);
1293 }
1294 
1296 octave_value::subsref (const std::string& type,
1297  const std::list<octave_value_list>& idx, int nargout)
1298 {
1299  if (nargout == 1)
1300  return rep->subsref (type, idx);
1301  else
1302  return rep->subsref (type, idx, nargout);
1303 }
1304 
1306 octave_value::subsref (const std::string& type,
1307  const std::list<octave_value_list>& idx, int nargout,
1308  const std::list<octave_lvalue> *lvalue_list)
1309 {
1310  if (lvalue_list)
1311  return rep->subsref (type, idx, nargout, lvalue_list);
1312  else
1313  return subsref (type, idx, nargout);
1314 }
1315 
1317 octave_value::next_subsref (const std::string& type,
1318  const std::list<octave_value_list>& idx,
1319  size_t skip)
1320 {
1321  if (! error_state && idx.size () > skip)
1322  {
1323  std::list<octave_value_list> new_idx (idx);
1324  for (size_t i = 0; i < skip; i++)
1325  new_idx.erase (new_idx.begin ());
1326  return subsref (type.substr (skip), new_idx);
1327  }
1328  else
1329  return *this;
1330 }
1331 
1333 octave_value::next_subsref (int nargout, const std::string& type,
1334  const std::list<octave_value_list>& idx,
1335  size_t skip)
1336 {
1337  if (! error_state && idx.size () > skip)
1338  {
1339  std::list<octave_value_list> new_idx (idx);
1340  for (size_t i = 0; i < skip; i++)
1341  new_idx.erase (new_idx.begin ());
1342  return subsref (type.substr (skip), new_idx, nargout);
1343  }
1344  else
1345  return *this;
1346 }
1347 
1349 octave_value::next_subsref (int nargout, const std::string& type,
1350  const std::list<octave_value_list>& idx,
1351  const std::list<octave_lvalue> *lvalue_list,
1352  size_t skip)
1353 {
1354  if (! error_state && idx.size () > skip)
1355  {
1356  std::list<octave_value_list> new_idx (idx);
1357  for (size_t i = 0; i < skip; i++)
1358  new_idx.erase (new_idx.begin ());
1359  return subsref (type.substr (skip), new_idx, nargout, lvalue_list);
1360  }
1361  else
1362  return *this;
1363 }
1364 
1366 octave_value::next_subsref (bool auto_add, const std::string& type,
1367  const std::list<octave_value_list>& idx,
1368  size_t skip)
1369 {
1370  if (! error_state && idx.size () > skip)
1371  {
1372  std::list<octave_value_list> new_idx (idx);
1373  for (size_t i = 0; i < skip; i++)
1374  new_idx.erase (new_idx.begin ());
1375  return subsref (type.substr (skip), new_idx, auto_add);
1376  }
1377  else
1378  return *this;
1379 }
1380 
1383 {
1384  return rep->do_multi_index_op (nargout, idx);
1385 }
1386 
1389  const std::list<octave_lvalue> *lvalue_list)
1390 {
1391  return rep->do_multi_index_op (nargout, idx, lvalue_list);
1392 }
1393 
1394 #if 0
1395 static void
1396 gripe_assign_failed (const std::string& on, const std::string& tn1,
1397  const std::string& tn2)
1398 {
1399  error ("assignment failed for '%s %s %s'",
1400  tn1.c_str (), on.c_str (), tn2.c_str ());
1401 }
1402 #endif
1403 
1404 static void
1405 gripe_assign_failed_or_no_method (const std::string& on,
1406  const std::string& tn1,
1407  const std::string& tn2)
1408 {
1409  error ("assignment failed, or no method for '%s %s %s'",
1410  tn1.c_str (), on.c_str (), tn2.c_str ());
1411 }
1412 
1414 octave_value::subsasgn (const std::string& type,
1415  const std::list<octave_value_list>& idx,
1416  const octave_value& rhs)
1417 {
1418  return rep->subsasgn (type, idx, rhs);
1419 }
1420 
1422 octave_value::undef_subsasgn (const std::string& type,
1423  const std::list<octave_value_list>& idx,
1424  const octave_value& rhs)
1425 {
1426  return rep->undef_subsasgn (type, idx, rhs);
1427 }
1428 
1429 octave_value&
1430 octave_value::assign (assign_op op, const std::string& type,
1431  const std::list<octave_value_list>& idx,
1432  const octave_value& rhs)
1433 {
1434  octave_value retval;
1435 
1436  make_unique ();
1437 
1438  octave_value t_rhs = rhs;
1439 
1440  if (op != op_asn_eq)
1441  {
1442  if (is_defined ())
1443  {
1444  octave_value t = subsref (type, idx);
1445 
1446  if (! error_state)
1447  {
1448  binary_op binop = op_eq_to_binary_op (op);
1449 
1450  if (! error_state)
1451  t_rhs = do_binary_op (binop, t, rhs);
1452  }
1453  }
1454  else
1455  error ("in computed assignment A(index) OP= X, A must be defined first");
1456  }
1457 
1458  if (! error_state)
1459  {
1460  octave_value tmp = subsasgn (type, idx, t_rhs);
1461 
1462  if (error_state)
1464  type_name (), rhs.type_name ());
1465  else
1466  *this = tmp;
1467  }
1468 
1469  return *this;
1470 }
1471 
1472 octave_value&
1474 {
1475  if (op == op_asn_eq)
1476  // Regularize a null matrix if stored into a variable.
1477  operator = (rhs.storable_value ());
1478  else if (is_defined ())
1479  {
1481 
1482  // Only attempt to operate in-place if this variable is unshared.
1483  if (rep->count == 1)
1484  {
1485  int tthis = this->type_id ();
1486  int trhs = rhs.type_id ();
1487 
1488  f = octave_value_typeinfo::lookup_assign_op (op, tthis, trhs);
1489  }
1490 
1491  if (f)
1492  {
1493  try
1494  {
1495  f (*rep, octave_value_list (), *rhs.rep);
1496  // Usually unnecessary, but may be needed (complex arrays).
1497  maybe_mutate ();
1498  }
1499  catch (octave_execution_exception)
1500  {
1502  }
1503  }
1504  else
1505  {
1506 
1507  binary_op binop = op_eq_to_binary_op (op);
1508 
1509  if (! error_state)
1510  {
1511  octave_value t = do_binary_op (binop, *this, rhs);
1512 
1513  if (! error_state)
1514  operator = (t);
1515  }
1516  }
1517  }
1518  else
1519  error ("in computed assignment A OP= X, A must be defined first");
1520 
1521  return *this;
1522 }
1523 
1526 {
1527  octave_idx_type retval = 0;
1528 
1529  const dim_vector dv = dims ();
1530 
1531  for (int i = 0; i < dv.length (); i++)
1532  {
1533  if (dv(i) == 0)
1534  {
1535  retval = 0;
1536  break;
1537  }
1538 
1539  if (dv(i) > retval)
1540  retval = dv(i);
1541  }
1542 
1543  return retval;
1544 }
1545 
1546 bool
1548 {
1549  bool retval = false;
1550 
1551  // If there is no op_eq for these types, we can't compare values.
1552 
1553  if (rows () == test.rows () && columns () == test.columns ())
1554  {
1555  octave_value tmp = do_binary_op (octave_value::op_eq, *this, test);
1556 
1557  // Empty array also means a match.
1558  if (! error_state && tmp.is_defined ())
1559  retval = tmp.is_true () || tmp.is_empty ();
1560  }
1561 
1562  return retval;
1563 }
1564 
1565 Cell
1567 {
1568  return rep->cell_value ();
1569 }
1570 
1571 // Define the idx_type_value function here instead of in ov.h to avoid
1572 // needing definitions for the SIZEOF_X macros in ov.h.
1573 
1575 octave_value::idx_type_value (bool req_int, bool frc_str_conv) const
1576 {
1577 #if defined (USE_64_BIT_IDX_T)
1578  return int64_value (req_int, frc_str_conv);
1579 #else
1580  return int_value (req_int, frc_str_conv);
1581 #endif
1582 }
1583 
1584 octave_map
1586 {
1587  return rep->map_value ();
1588 }
1589 
1592 {
1593  return rep->scalar_map_value ();
1594 }
1595 
1597 octave_value::function_value (bool silent) const
1598 {
1599  return rep->function_value (silent);
1600 }
1601 
1604 {
1605  return rep->user_function_value (silent);
1606 }
1607 
1610 {
1611  return rep->user_script_value (silent);
1612 }
1613 
1616 {
1617  return rep->user_code_value (silent);
1618 }
1619 
1622 {
1623  return rep->fcn_handle_value (silent);
1624 }
1625 
1628 {
1629  return rep->fcn_inline_value (silent);
1630 }
1631 
1634 {
1635  return rep->list_value ();
1636 }
1637 
1638 static dim_vector
1639 make_vector_dims (const dim_vector& dv, bool force_vector_conversion,
1640  const std::string& my_type, const std::string& wanted_type)
1641 {
1642  dim_vector retval (dv);
1643  retval.chop_trailing_singletons ();
1644  octave_idx_type nel = dv.numel ();
1645 
1646  if (retval.length () > 2 || (retval(0) != 1 && retval(1) != 1))
1647  {
1648  if (!force_vector_conversion)
1649  gripe_implicit_conversion ("Octave:array-to-vector",
1650  my_type.c_str (), wanted_type.c_str ());
1651  retval = dim_vector (nel, 1);
1652  }
1653 
1654  return retval;
1655 }
1656 
1658 octave_value::column_vector_value (bool force_string_conv,
1659  bool frc_vec_conv) const
1660 {
1661  return ColumnVector (vector_value (force_string_conv,
1662  frc_vec_conv));
1663 }
1664 
1667  bool frc_vec_conv) const
1668 {
1669  return ComplexColumnVector (complex_vector_value (force_string_conv,
1670  frc_vec_conv));
1671 }
1672 
1673 RowVector
1674 octave_value::row_vector_value (bool force_string_conv,
1675  bool frc_vec_conv) const
1676 {
1677  return RowVector (vector_value (force_string_conv,
1678  frc_vec_conv));
1679 }
1680 
1683  bool frc_vec_conv) const
1684 {
1685  return ComplexRowVector (complex_vector_value (force_string_conv,
1686  frc_vec_conv));
1687 }
1688 
1690 octave_value::vector_value (bool force_string_conv,
1691  bool force_vector_conversion) const
1692 {
1693  Array<double> retval = array_value (force_string_conv);
1694 
1695  if (error_state)
1696  return retval;
1697  else
1698  return retval.reshape (make_vector_dims (retval.dims (),
1699  force_vector_conversion,
1700  type_name (), "real vector"));
1701 }
1702 
1703 template <class T>
1704 static Array<int>
1706 {
1707  Array<int> retval (A.dims ());
1708  octave_idx_type n = A.numel ();
1709 
1710  for (octave_idx_type i = 0; i < n; i++)
1711  retval.xelem (i) = octave_int<int> (A.xelem (i));
1712 
1713  return retval;
1714 }
1715 
1716 Array<int>
1717 octave_value::int_vector_value (bool force_string_conv, bool require_int,
1718  bool force_vector_conversion) const
1719 {
1720  Array<int> retval;
1721 
1722  if (is_integer_type ())
1723  {
1724  if (is_int32_type ())
1726  else if (is_int64_type ())
1728  else if (is_int16_type ())
1730  else if (is_int8_type ())
1731  retval = convert_to_int_array (int8_array_value ());
1732  else if (is_uint32_type ())
1734  else if (is_uint64_type ())
1736  else if (is_uint16_type ())
1738  else if (is_uint8_type ())
1740  else
1741  retval = array_value (force_string_conv);
1742  }
1743  else
1744  {
1745  const NDArray a = array_value (force_string_conv);
1746  if (! error_state)
1747  {
1748  if (require_int)
1749  {
1750  retval.resize (a.dims ());
1751  for (octave_idx_type i = 0; i < a.numel (); i++)
1752  {
1753  double ai = a.elem (i);
1754  int v = static_cast<int> (ai);
1755  if (ai == v)
1756  retval.xelem (i) = v;
1757  else
1758  {
1759  error_with_cfn ("conversion to integer value failed");
1760  break;
1761  }
1762  }
1763  }
1764  else
1765  retval = Array<int> (a);
1766  }
1767  }
1768 
1769 
1770  if (error_state)
1771  return retval;
1772  else
1773  return retval.reshape (make_vector_dims (retval.dims (),
1774  force_vector_conversion,
1775  type_name (), "integer vector"));
1776 }
1777 
1778 template <class T>
1781 {
1782  Array<octave_idx_type> retval (A.dims ());
1783  octave_idx_type n = A.numel ();
1784 
1785  for (octave_idx_type i = 0; i < n; i++)
1786  retval.xelem (i) = octave_int<octave_idx_type> (A.xelem (i));
1787 
1788  return retval;
1789 }
1790 
1793  bool force_string_conv,
1794  bool force_vector_conversion) const
1795 {
1796  Array<octave_idx_type> retval;
1797 
1798  if (is_integer_type ())
1799  {
1800  if (is_int32_type ())
1802  else if (is_int64_type ())
1804  else if (is_int16_type ())
1806  else if (is_int8_type ())
1808  else if (is_uint32_type ())
1810  else if (is_uint64_type ())
1812  else if (is_uint16_type ())
1814  else if (is_uint8_type ())
1816  else
1817  retval = array_value (force_string_conv);
1818  }
1819  else
1820  {
1821  const NDArray a = array_value (force_string_conv);
1822  if (! error_state)
1823  {
1824  if (require_int)
1825  {
1826  retval.resize (a.dims ());
1827  for (octave_idx_type i = 0; i < a.numel (); i++)
1828  {
1829  double ai = a.elem (i);
1830  octave_idx_type v = static_cast<octave_idx_type> (ai);
1831  if (ai == v)
1832  retval.xelem (i) = v;
1833  else
1834  {
1835  error_with_cfn ("conversion to integer value failed");
1836  break;
1837  }
1838  }
1839  }
1840  else
1841  retval = Array<octave_idx_type> (a);
1842  }
1843  }
1844 
1845 
1846  if (error_state)
1847  return retval;
1848  else
1849  return retval.reshape (make_vector_dims (retval.dims (),
1850  force_vector_conversion,
1851  type_name (), "integer vector"));
1852 }
1853 
1855 octave_value::complex_vector_value (bool force_string_conv,
1856  bool force_vector_conversion) const
1857 {
1858  Array<Complex> retval = complex_array_value (force_string_conv);
1859 
1860  if (error_state)
1861  return retval;
1862  else
1863  return retval.reshape (make_vector_dims (retval.dims (),
1864  force_vector_conversion,
1865  type_name (), "complex vector"));
1866 }
1867 
1870  bool frc_vec_conv) const
1871 {
1872  return FloatColumnVector (float_vector_value (force_string_conv,
1873  frc_vec_conv));
1874 }
1875 
1878  bool frc_vec_conv) const
1879 {
1880  return
1882  frc_vec_conv));
1883 }
1884 
1887  bool frc_vec_conv) const
1888 {
1889  return FloatRowVector (float_vector_value (force_string_conv,
1890  frc_vec_conv));
1891 }
1892 
1895  bool frc_vec_conv) const
1896 {
1897  return FloatComplexRowVector (float_complex_vector_value (force_string_conv,
1898  frc_vec_conv));
1899 }
1900 
1902 octave_value::float_vector_value (bool force_string_conv,
1903  bool force_vector_conversion) const
1904 {
1905  Array<float> retval = float_array_value (force_string_conv);
1906 
1907  if (error_state)
1908  return retval;
1909  else
1910  return retval.reshape (make_vector_dims (retval.dims (),
1911  force_vector_conversion,
1912  type_name (), "real vector"));
1913 }
1914 
1917  bool force_vector_conversion) const
1918 {
1919  Array<FloatComplex> retval = float_complex_array_value (force_string_conv);
1920 
1921  if (error_state)
1922  return retval;
1923  else
1924  return retval.reshape (make_vector_dims (retval.dims (),
1925  force_vector_conversion,
1926  type_name (), "complex vector"));
1927 }
1928 
1931 {
1932  octave_value retval = *this;
1933  if (is_null_value ())
1934  retval = octave_value (rep->empty_clone ());
1935  else
1936  retval.maybe_economize ();
1937 
1938  return retval;
1939 }
1940 
1941 void
1943 {
1944  if (is_null_value ())
1945  {
1946  octave_base_value *rc = rep->empty_clone ();
1947  if (--rep->count == 0)
1948  delete rep;
1949  rep = rc;
1950  }
1951  else
1952  maybe_economize ();
1953 }
1954 
1955 int
1956 octave_value::write (octave_stream& os, int block_size,
1957  oct_data_conv::data_type output_type, int skip,
1958  oct_mach_info::float_format flt_fmt) const
1959 {
1960  return rep->write (os, block_size, output_type, skip, flt_fmt);
1961 }
1962 
1963 static void
1964 gripe_binary_op (const std::string& on, const std::string& tn1,
1965  const std::string& tn2)
1966 {
1967  error ("binary operator '%s' not implemented for '%s' by '%s' operations",
1968  on.c_str (), tn1.c_str (), tn2.c_str ());
1969 }
1970 
1971 static void
1972 gripe_binary_op_conv (const std::string& on)
1973 {
1974  error ("type conversion failed for binary operator '%s'", on.c_str ());
1975 }
1976 
1979  const octave_value& v1, const octave_value& v2)
1980 {
1981  octave_value retval;
1982 
1983  int t1 = v1.type_id ();
1984  int t2 = v2.type_id ();
1985 
1986  if (t1 == octave_class::static_type_id ()
1987  || t2 == octave_class::static_type_id ()
1989  || t2 == octave_classdef::static_type_id ())
1990  {
1993 
1994  if (f)
1995  {
1996  try
1997  {
1998  retval = f (v1, v2);
1999  }
2000  catch (octave_execution_exception)
2001  {
2003  }
2004  }
2005  else
2007  v1.class_name (), v2.class_name ());
2008  }
2009  else
2010  {
2011  // FIXME: we need to handle overloading operators for built-in
2012  // classes (double, char, int8, etc.)
2013 
2016 
2017  if (f)
2018  {
2019  try
2020  {
2021  retval = f (*v1.rep, *v2.rep);
2022  }
2023  catch (octave_execution_exception)
2024  {
2026  }
2027  }
2028  else
2029  {
2030  octave_value tv1;
2033 
2034  octave_value tv2;
2037 
2038  // Try biased (one-sided) conversions first.
2039  if (cf2.type_id () >= 0
2041  cf2.type_id ()))
2042  cf1 = 0;
2043  else if (cf1.type_id () >= 0
2045  cf1.type_id (),
2046  t2))
2047  cf2 = 0;
2048 
2049  if (cf1)
2050  {
2051  octave_base_value *tmp = cf1 (*v1.rep);
2052 
2053  if (tmp)
2054  {
2055  tv1 = octave_value (tmp);
2056  t1 = tv1.type_id ();
2057  }
2058  else
2059  {
2061  return retval;
2062  }
2063  }
2064  else
2065  tv1 = v1;
2066 
2067  if (cf2)
2068  {
2069  octave_base_value *tmp = cf2 (*v2.rep);
2070 
2071  if (tmp)
2072  {
2073  tv2 = octave_value (tmp);
2074  t2 = tv2.type_id ();
2075  }
2076  else
2077  {
2079  return retval;
2080  }
2081  }
2082  else
2083  tv2 = v2;
2084 
2085  if (cf1 || cf2)
2086  {
2087  retval = do_binary_op (op, tv1, tv2);
2088  }
2089  else
2090  {
2091  //demote double -> single and try again
2092  cf1 = tv1.numeric_demotion_function ();
2093 
2094  cf2 = tv2.numeric_demotion_function ();
2095 
2096  // Try biased (one-sided) conversions first.
2097  if (cf2.type_id () >= 0
2099  cf2.type_id ()))
2100  cf1 = 0;
2101  else if (cf1.type_id () >= 0
2103  cf1.type_id (),
2104  t2))
2105  cf2 = 0;
2106 
2107  if (cf1)
2108  {
2109  octave_base_value *tmp = cf1 (*tv1.rep);
2110 
2111  if (tmp)
2112  {
2113  tv1 = octave_value (tmp);
2114  t1 = tv1.type_id ();
2115  }
2116  else
2117  {
2120  return retval;
2121  }
2122  }
2123 
2124  if (cf2)
2125  {
2126  octave_base_value *tmp = cf2 (*tv2.rep);
2127 
2128  if (tmp)
2129  {
2130  tv2 = octave_value (tmp);
2131  t2 = tv2.type_id ();
2132  }
2133  else
2134  {
2137  return retval;
2138  }
2139  }
2140 
2141  if (cf1 || cf2)
2142  {
2143  f = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
2144 
2145  if (f)
2146  {
2147  try
2148  {
2149  retval = f (*tv1.rep, *tv2.rep);
2150  }
2151  catch (octave_execution_exception)
2152  {
2154  }
2155  }
2156  else
2158  v1.type_name (), v2.type_name ());
2159  }
2160  else
2162  v1.type_name (), v2.type_name ());
2163  }
2164  }
2165  }
2166 
2167  return retval;
2168 }
2169 
2170 static octave_value
2172  const octave_value& v1, const octave_value& v2)
2173 {
2174  octave_value retval;
2175 
2176  switch (op)
2177  {
2181  v2);
2182  break;
2185  v1,
2187  break;
2191  v2);
2192  break;
2195  v1,
2197  break;
2201  v2);
2202  break;
2206  v2);
2207  break;
2211  v2);
2212  break;
2216  v2);
2217  break;
2220  v1,
2222  break;
2225  v1,
2227  break;
2228  default:
2229  error ("invalid compound operator");
2230  break;
2231  }
2232 
2233  return retval;
2234 }
2235 
2238  const octave_value& v1, const octave_value& v2)
2239 {
2240  octave_value retval;
2241 
2242  int t1 = v1.type_id ();
2243  int t2 = v2.type_id ();
2244 
2245  if (t1 == octave_class::static_type_id ()
2246  || t2 == octave_class::static_type_id ()
2248  || t2 == octave_classdef::static_type_id ())
2249  {
2252 
2253  if (f)
2254  {
2255  try
2256  {
2257  retval = f (v1, v2);
2258  }
2259  catch (octave_execution_exception)
2260  {
2262  }
2263  }
2264  else
2265  retval = decompose_binary_op (op, v1, v2);
2266  }
2267  else
2268  {
2271 
2272  if (f)
2273  {
2274  try
2275  {
2276  retval = f (*v1.rep, *v2.rep);
2277  }
2278  catch (octave_execution_exception)
2279  {
2281  }
2282  }
2283  else
2284  retval = decompose_binary_op (op, v1, v2);
2285  }
2286 
2287  return retval;
2288 }
2289 
2290 static void
2291 gripe_cat_op (const std::string& tn1, const std::string& tn2)
2292 {
2293  error ("concatenation operator not implemented for '%s' by '%s' operations",
2294  tn1.c_str (), tn2.c_str ());
2295 }
2296 
2297 static void
2299 {
2300  error ("type conversion failed for concatenation operator");
2301 }
2302 
2306 {
2307  octave_value retval;
2308 
2309  // Can't rapid return for concatenation with an empty object here as
2310  // something like cat(1,[],single([]) must return the correct type.
2311 
2312  int t1 = v1.type_id ();
2313  int t2 = v2.type_id ();
2314 
2317 
2318  if (f)
2319  {
2320  try
2321  {
2322  retval = f (*v1.rep, *v2.rep, ra_idx);
2323  }
2324  catch (octave_execution_exception)
2325  {
2327  }
2328  }
2329  else
2330  {
2331  octave_value tv1;
2333 
2334  octave_value tv2;
2336 
2337  // Try biased (one-sided) conversions first.
2338  if (cf2.type_id () >= 0
2340  cf1 = 0;
2341  else if (cf1.type_id () >= 0
2343  cf2 = 0;
2344 
2345  if (cf1)
2346  {
2347  octave_base_value *tmp = cf1 (*v1.rep);
2348 
2349  if (tmp)
2350  {
2351  tv1 = octave_value (tmp);
2352  t1 = tv1.type_id ();
2353  }
2354  else
2355  {
2356  gripe_cat_op_conv ();
2357  return retval;
2358  }
2359  }
2360  else
2361  tv1 = v1;
2362 
2363  if (cf2)
2364  {
2365  octave_base_value *tmp = cf2 (*v2.rep);
2366 
2367  if (tmp)
2368  {
2369  tv2 = octave_value (tmp);
2370  t2 = tv2.type_id ();
2371  }
2372  else
2373  {
2374  gripe_cat_op_conv ();
2375  return retval;
2376  }
2377  }
2378  else
2379  tv2 = v2;
2380 
2381  if (cf1 || cf2)
2382  {
2383  retval = do_cat_op (tv1, tv2, ra_idx);
2384  }
2385  else
2386  gripe_cat_op (v1.type_name (), v2.type_name ());
2387  }
2388 
2389  return retval;
2390 }
2391 
2393 do_colon_op (const octave_value& base, const octave_value& increment,
2394  const octave_value& limit, bool is_for_cmd_expr)
2395 {
2396  octave_value retval;
2397 
2398  if (base.is_object () || increment.is_object () || limit.is_object ())
2399  {
2400  std::string dispatch_type;
2401 
2402  if (base.is_object ())
2403  dispatch_type = base.class_name ();
2404  else if (increment.is_defined () && increment.is_object ())
2405  dispatch_type = increment.class_name ();
2406  else
2407  dispatch_type = limit.class_name ();
2408 
2409  octave_value meth = symbol_table::find_method ("colon", dispatch_type);
2410 
2411  if (meth.is_defined ())
2412  {
2413  octave_value_list args;
2414 
2415  if (increment.is_defined ())
2416  {
2417  args(2) = limit;
2418  args(1) = increment;
2419  }
2420  else
2421  args(1) = limit;
2422 
2423  args(0) = base;
2424 
2425  octave_value_list tmp = feval (meth.function_value (), args, 1);
2426 
2427  if (tmp.length () > 0)
2428  retval = tmp(0);
2429  }
2430  else
2431  error ("colon method not defined for %s class", dispatch_type.c_str ());
2432  }
2433  else
2434  {
2435  bool result_is_str = (base.is_string () && limit.is_string ());
2436  bool dq_str = (base.is_dq_string () || limit.is_dq_string ());
2437 
2438  Matrix m_base = base.matrix_value (true);
2439 
2440  if (error_state)
2441  {
2442  error ("invalid base value in colon expression");
2443  return retval;
2444  }
2445 
2446  Matrix m_limit = limit.matrix_value (true);
2447 
2448  if (error_state)
2449  {
2450  error ("invalid limit value in colon expression");
2451  return retval;
2452  }
2453 
2454  Matrix m_increment = (increment.is_defined ()
2455  ? increment.matrix_value (true)
2456  : Matrix (1, 1, 1.0));
2457 
2458  if (error_state)
2459  {
2460  error ("invalid increment value in colon expression");
2461  return retval;
2462  }
2463 
2464  bool base_empty = m_base.is_empty ();
2465  bool limit_empty = m_limit.is_empty ();
2466  bool increment_empty = m_increment.is_empty ();
2467 
2468  if (base_empty || limit_empty || increment_empty)
2469  retval = Range ();
2470  else
2471  {
2472  Range r (m_base(0), m_limit(0), m_increment(0));
2473 
2474  // For compatibility with Matlab, don't allow the range used in
2475  // a FOR loop expression to be converted to a Matrix.
2476 
2477  retval = octave_value (r, is_for_cmd_expr);
2478 
2479  if (result_is_str)
2480  retval = retval.convert_to_str (false, true, dq_str ? '"' : '\'');
2481  }
2482  }
2483 
2484  return retval;
2485 }
2486 
2487 void
2488 octave_value::print_info (std::ostream& os, const std::string& prefix) const
2489 {
2490  os << prefix << "type_name: " << type_name () << "\n"
2491  << prefix << "count: " << get_count () << "\n"
2492  << prefix << "rep info: ";
2493 
2494  rep->print_info (os, prefix + " ");
2495 }
2496 
2497 static void
2498 gripe_unary_op (const std::string& on, const std::string& tn)
2499 {
2500  error ("unary operator '%s' not implemented for '%s' operands",
2501  on.c_str (), tn.c_str ());
2502 }
2503 
2504 static void
2505 gripe_unary_op_conv (const std::string& on)
2506 {
2507  error ("type conversion failed for unary operator '%s'", on.c_str ());
2508 }
2509 
2512 {
2513  octave_value retval;
2514 
2515  int t = v.type_id ();
2516 
2517  if (t == octave_class::static_type_id ()
2519  {
2522 
2523  if (f)
2524  {
2525  try
2526  {
2527  retval = f (v);
2528  }
2529  catch (octave_execution_exception)
2530  {
2532  }
2533  }
2534  else
2536  v.class_name ());
2537  }
2538  else
2539  {
2540  // FIXME: we need to handle overloading operators for built-in
2541  // classes (double, char, int8, etc.)
2542 
2545 
2546  if (f)
2547  {
2548  try
2549  {
2550  retval = f (*v.rep);
2551  }
2552  catch (octave_execution_exception)
2553  {
2555  }
2556  }
2557  else
2558  {
2559  octave_value tv;
2562 
2563  if (cf)
2564  {
2565  octave_base_value *tmp = cf (*v.rep);
2566 
2567  if (tmp)
2568  {
2569  tv = octave_value (tmp);
2570  retval = do_unary_op (op, tv);
2571  }
2572  else
2574  }
2575  else
2577  v.type_name ());
2578  }
2579  }
2580 
2581  return retval;
2582 }
2583 
2584 static void
2585 gripe_unary_op_conversion_failed (const std::string& op,
2586  const std::string& tn)
2587 {
2588  error ("operator %s: type conversion for '%s' failed",
2589  op.c_str (), tn.c_str ());
2590 }
2591 
2592 octave_value&
2594 {
2595  if (op == op_incr || op == op_decr)
2596  {
2597  // We want the gripe just here, because in the other branch this should
2598  // not happen, and if it did anyway (internal error), the message would
2599  // be confusing.
2600  if (is_undefined ())
2601  {
2602  std::string op_str = unary_op_as_string (op);
2603  error ("in x%s or %sx, x must be defined first",
2604  op_str.c_str (), op_str.c_str ());
2605  return *this;
2606  }
2607 
2608  // Genuine.
2609  int t = type_id ();
2610 
2613 
2614  if (f)
2615  {
2616  make_unique ();
2617 
2618  try
2619  {
2620  f (*rep);
2621  }
2622  catch (octave_execution_exception)
2623  {
2625  }
2626  }
2627  else
2628  {
2630 
2631  if (cf)
2632  {
2633  octave_base_value *tmp = cf (*rep);
2634 
2635  if (tmp)
2636  {
2637  octave_base_value *old_rep = rep;
2638  rep = tmp;
2639 
2640  t = type_id ();
2641 
2643 
2644  if (f)
2645  {
2646  try
2647  {
2648  f (*rep);
2649  }
2650  catch (octave_execution_exception)
2651  {
2653  }
2654 
2655  if (old_rep && --old_rep->count == 0)
2656  delete old_rep;
2657  }
2658  else
2659  {
2660  if (old_rep)
2661  {
2662  if (--rep->count == 0)
2663  delete rep;
2664 
2665  rep = old_rep;
2666  }
2667 
2669  type_name ());
2670  }
2671  }
2672  else
2675  }
2676  else
2678  type_name ());
2679  }
2680  }
2681  else
2682  {
2683  // Non-genuine.
2684  int t = type_id ();
2685 
2687 
2688  // Only attempt to operate in-place if this variable is unshared.
2689  if (rep->count == 1)
2691 
2692  if (f)
2693  {
2694  try
2695  {
2696  f (*rep);
2697  }
2698  catch (octave_execution_exception)
2699  {
2701  }
2702  }
2703  else
2704  *this = do_unary_op (op, *this);
2705  }
2706 
2707  return *this;
2708 }
2709 
2710 octave_value&
2711 octave_value::do_non_const_unary_op (unary_op op, const std::string& type,
2712  const std::list<octave_value_list>& idx)
2713 {
2714  if (idx.empty ())
2715  do_non_const_unary_op (op);
2716  else
2717  {
2718  // FIXME: only do the following stuff if we can't find a
2719  // specific function to call to handle the op= operation for the
2720  // types we have.
2721 
2722  assign_op assop = unary_op_to_assign_op (op);
2723 
2724  assign (assop, type, idx, 1.0);
2725  }
2726 
2727  return *this;
2728 }
2729 
2732 {
2733  assign_op binop = unknown_assign_op;
2734 
2735  switch (op)
2736  {
2737  case op_incr:
2738  binop = op_add_eq;
2739  break;
2740 
2741  case op_decr:
2742  binop = op_sub_eq;
2743  break;
2744 
2745  default:
2746  {
2747  std::string on = unary_op_as_string (op);
2748  error ("operator %s: no assign operator found", on.c_str ());
2749  }
2750  }
2751 
2752  return binop;
2753 }
2754 
2757 {
2758  binary_op binop = unknown_binary_op;
2759 
2760  switch (op)
2761  {
2762  case op_add_eq:
2763  binop = op_add;
2764  break;
2765 
2766  case op_sub_eq:
2767  binop = op_sub;
2768  break;
2769 
2770  case op_mul_eq:
2771  binop = op_mul;
2772  break;
2773 
2774  case op_div_eq:
2775  binop = op_div;
2776  break;
2777 
2778  case op_ldiv_eq:
2779  binop = op_ldiv;
2780  break;
2781 
2782  case op_pow_eq:
2783  binop = op_pow;
2784  break;
2785 
2786  case op_lshift_eq:
2787  binop = op_lshift;
2788  break;
2789 
2790  case op_rshift_eq:
2791  binop = op_rshift;
2792  break;
2793 
2794  case op_el_mul_eq:
2795  binop = op_el_mul;
2796  break;
2797 
2798  case op_el_div_eq:
2799  binop = op_el_div;
2800  break;
2801 
2802  case op_el_ldiv_eq:
2803  binop = op_el_ldiv;
2804  break;
2805 
2806  case op_el_pow_eq:
2807  binop = op_el_pow;
2808  break;
2809 
2810  case op_el_and_eq:
2811  binop = op_el_and;
2812  break;
2813 
2814  case op_el_or_eq:
2815  binop = op_el_or;
2816  break;
2817 
2818  default:
2819  {
2820  std::string on = assign_op_as_string (op);
2821  error ("operator %s: no binary operator found", on.c_str ());
2822  }
2823  }
2824 
2825  return binop;
2826 }
2827 
2829 octave_value::empty_conv (const std::string& type, const octave_value& rhs)
2830 {
2831  octave_value retval;
2832 
2833  if (type.length () > 0)
2834  {
2835  switch (type[0])
2836  {
2837  case '(':
2838  {
2839  if (type.length () > 1 && type[1] == '.')
2840  retval = octave_map ();
2841  else
2842  retval = octave_value (rhs.empty_clone ());
2843  }
2844  break;
2845 
2846  case '{':
2847  retval = Cell ();
2848  break;
2849 
2850  case '.':
2851  retval = octave_scalar_map ();
2852  break;
2853 
2854  default:
2855  panic_impossible ();
2856  }
2857  }
2858  else
2859  retval = octave_value (rhs.empty_clone ());
2860 
2861  return retval;
2862 }
2863 
2864 void
2866 {
2880  octave_int8_scalar::register_type ();
2881  octave_int16_scalar::register_type ();
2882  octave_int32_scalar::register_type ();
2883  octave_int64_scalar::register_type ();
2884  octave_uint8_scalar::register_type ();
2885  octave_uint16_scalar::register_type ();
2886  octave_uint32_scalar::register_type ();
2887  octave_uint64_scalar::register_type ();
2888  octave_int8_matrix::register_type ();
2889  octave_int16_matrix::register_type ();
2890  octave_int32_matrix::register_type ();
2891  octave_int64_matrix::register_type ();
2892  octave_uint8_matrix::register_type ();
2893  octave_uint16_matrix::register_type ();
2894  octave_uint32_matrix::register_type ();
2895  octave_uint64_matrix::register_type ();
2921 #ifdef HAVE_JAVA
2923 #endif
2924 }
2925 
2926 DEFUN (sizeof, args, ,
2927  "-*- texinfo -*-\n\
2928 @deftypefn {Built-in Function} {} sizeof (@var{val})\n\
2929 Return the size of @var{val} in bytes.\n\
2930 @seealso{whos}\n\
2931 @end deftypefn")
2932 {
2933  octave_value retval;
2934 
2935  if (args.length () == 1)
2936  retval = args(0).byte_size ();
2937  else
2938  print_usage ();
2939 
2940  return retval;
2941 }
2942 
2943 /*
2944 %!assert (sizeof (uint64 (ones (3))), 72)
2945 %!assert (sizeof (double (zeros (2,4))), 64)
2946 %!assert (sizeof ({"foo", "bar", "baaz"}), 10)
2947 */
2948 
2949 static void
2950 decode_subscripts (const char* name, const octave_value& arg,
2951  std::string& type_string,
2952  std::list<octave_value_list>& idx)
2953 {
2954  const octave_map m = arg.map_value ();
2955 
2956  if (! error_state
2957  && m.nfields () == 2 && m.contains ("type") && m.contains ("subs"))
2958  {
2959  octave_idx_type nel = m.numel ();
2960 
2961  type_string = std::string (nel, '\0');
2962  idx = std::list<octave_value_list> ();
2963 
2964  if (nel == 0)
2965  return;
2966 
2967  const Cell type = m.contents ("type");
2968  const Cell subs = m.contents ("subs");
2969 
2970  for (int k = 0; k < nel; k++)
2971  {
2972  if (type(k).is_string ())
2973  {
2974  std::string item = type(k).string_value ();
2975  if (item == "{}")
2976  type_string[k] = '{';
2977  else if (item == "()")
2978  type_string[k] = '(';
2979  else if (item == ".")
2980  type_string[k] = '.';
2981  else
2982  {
2983  error ("%s: invalid indexing type '%s'", name, item.c_str ());
2984  return;
2985  }
2986  }
2987  else
2988  {
2989  error ("%s: type(%d) must be a string", name, k+1);
2990  return;
2991  }
2992 
2993  octave_value_list idx_item;
2994 
2995  if (subs(k).is_string ())
2996  idx_item(0) = subs(k);
2997  else if (subs(k).is_cell ())
2998  {
2999  Cell subs_cell = subs(k).cell_value ();
3000 
3001  for (int n = 0; n < subs_cell.length (); n++)
3002  {
3003  if (subs_cell(n).is_string ()
3004  && subs_cell(n).string_value () == ":")
3006  else
3007  idx_item(n) = subs_cell(n);
3008  }
3009  }
3010  else
3011  {
3012  error ("%s: subs(%d) must be a string or cell array", name, k+1);
3013  return;
3014  }
3015 
3016  idx.push_back (idx_item);
3017  }
3018  }
3019  else
3020  error ("%s: second argument must be a structure with fields 'type' and 'subs'",
3021  name);
3022 }
3023 
3024 DEFUN (subsref, args, nargout,
3025  "-*- texinfo -*-\n\
3026 @deftypefn {Built-in Function} {} subsref (@var{val}, @var{idx})\n\
3027 Perform the subscripted element selection operation according to the\n\
3028 subscript specified by @var{idx}.\n\
3029 \n\
3030 The subscript @var{idx} is expected to be a structure array with fields\n\
3031 @samp{type} and @samp{subs}. Valid values for @samp{type} are\n\
3032 @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}. The @samp{subs} field may\n\
3033 be either @samp{\":\"} or a cell array of index values.\n\
3034 \n\
3035 The following example shows how to extract the first two columns of a matrix\n\
3036 \n\
3037 @example\n\
3038 @group\n\
3039 val = magic (3)\n\
3040  @result{} val = [ 8 1 6\n\
3041  3 5 7\n\
3042  4 9 2 ]\n\
3043 idx.type = \"()\";\n\
3044 idx.subs = @{\":\", 1:2@};\n\
3045 subsref (val, idx)\n\
3046  @result{} [ 8 1\n\
3047  3 5\n\
3048  4 9 ]\n\
3049 @end group\n\
3050 @end example\n\
3051 \n\
3052 @noindent\n\
3053 Note that this is the same as writing @code{val(:,1:2)}.\n\
3054 \n\
3055 If @var{idx} is an empty structure array with fields @samp{type} and\n\
3056 @samp{subs}, return @var{val}.\n\
3057 @seealso{subsasgn, substruct}\n\
3058 @end deftypefn")
3059 {
3060  octave_value_list retval;
3061 
3062  if (args.length () == 2)
3063  {
3064  std::string type;
3065  std::list<octave_value_list> idx;
3066 
3067  decode_subscripts ("subsref", args(1), type, idx);
3068 
3069  if (! error_state)
3070  {
3071  octave_value arg0 = args(0);
3072 
3073  if (type.empty ())
3074  retval = arg0;
3075  else
3076  retval = arg0.subsref (type, idx, nargout);
3077  }
3078  }
3079  else
3080  print_usage ();
3081 
3082  return retval;
3083 }
3084 
3085 DEFUN (subsasgn, args, ,
3086  "-*- texinfo -*-\n\
3087 @deftypefn {Built-in Function} {} subsasgn (@var{val}, @var{idx}, @var{rhs})\n\
3088 Perform the subscripted assignment operation according to the subscript\n\
3089 specified by @var{idx}.\n\
3090 \n\
3091 The subscript @var{idx} is expected to be a structure array with fields\n\
3092 @samp{type} and @samp{subs}. Valid values for @samp{type} are\n\
3093 @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}. The @samp{subs} field may\n\
3094 be either @samp{\":\"} or a cell array of index values.\n\
3095 \n\
3096 The following example shows how to set the two first columns of a 3-by-3\n\
3097 matrix to zero.\n\
3098 \n\
3099 @example\n\
3100 @group\n\
3101 val = magic (3);\n\
3102 idx.type = \"()\";\n\
3103 idx.subs = @{\":\", 1:2@};\n\
3104 subsasgn (val, idx, 0)\n\
3105  @result{} [ 0 0 6\n\
3106  0 0 7\n\
3107  0 0 2 ]\n\
3108 @end group\n\
3109 @end example\n\
3110 \n\
3111 Note that this is the same as writing @code{val(:,1:2) = 0}.\n\
3112 \n\
3113 If @var{idx} is an empty structure array with fields @samp{type} and\n\
3114 @samp{subs}, return @var{rhs}.\n\
3115 @seealso{subsref, substruct}\n\
3116 @end deftypefn")
3117 {
3118  octave_value retval;
3119 
3120  if (args.length () == 3)
3121  {
3122  std::string type;
3123  std::list<octave_value_list> idx;
3124 
3125  decode_subscripts ("subsasgn", args(1), type, idx);
3126 
3127  if (! error_state)
3128  {
3129  if (type.empty ())
3130  {
3131  // Regularize a null matrix if stored into a variable.
3132 
3133  retval = args(2).storable_value ();
3134  }
3135  else
3136  {
3137  octave_value arg0 = args(0);
3138 
3139  arg0.make_unique ();
3140 
3141  if (! error_state)
3142  retval= arg0.subsasgn (type, idx, args(2));
3143  }
3144  }
3145  }
3146  else
3147  print_usage ();
3148 
3149  return retval;
3150 }
3151 
3152 /*
3153 %!test
3154 %! a = reshape ([1:25], 5,5);
3155 %! idx1 = substruct ("()", {3, 3});
3156 %! idx2 = substruct ("()", {2:2:5, 2:2:5});
3157 %! idx3 = substruct ("()", {":", [1,5]});
3158 %! idx4 = struct ("type", {}, "subs", {});
3159 %! assert (subsref (a, idx1), 13);
3160 %! assert (subsref (a, idx2), [7 17; 9 19]);
3161 %! assert (subsref (a, idx3), [1:5; 21:25]');
3162 %! assert (subsref (a, idx4), a);
3163 %! a = subsasgn (a, idx1, 0);
3164 %! a = subsasgn (a, idx2, 0);
3165 %! a = subsasgn (a, idx3, 0);
3166 %!# a = subsasgn (a, idx4, 0);
3167 %! b = [0 6 11 16 0
3168 %! 0 0 12 0 0
3169 %! 0 8 0 18 0
3170 %! 0 0 14 0 0
3171 %! 0 10 15 20 0];
3172 %! assert (a, b);
3173 
3174 %!test
3175 %! c = num2cell (reshape ([1:25],5,5));
3176 %! idx1 = substruct ("{}", {3, 3});
3177 %! idx2 = substruct ("()", {2:2:5, 2:2:5});
3178 %! idx3 = substruct ("()", {":", [1,5]});
3179 %! idx2p = substruct ("{}", {2:2:5, 2:2:5});
3180 %! idx3p = substruct ("{}", {":", [1,5]});
3181 %! idx4 = struct ("type", {}, "subs", {});
3182 %! assert ({ subsref(c, idx1) }, {13});
3183 %! assert ({ subsref(c, idx2p) }, {7 9 17 19});
3184 %! assert ({ subsref(c, idx3p) }, num2cell ([1:5, 21:25]));
3185 %! assert (subsref (c, idx4), c);
3186 %! c = subsasgn (c, idx1, 0);
3187 %! c = subsasgn (c, idx2, 0);
3188 %! c = subsasgn (c, idx3, 0);
3189 %!# c = subsasgn (c, idx4, 0);
3190 %! d = {0 6 11 16 0
3191 %! 0 0 12 0 0
3192 %! 0 8 0 18 0
3193 %! 0 0 14 0 0
3194 %! 0 10 15 20 0};
3195 %! assert (c, d);
3196 
3197 %!test
3198 %! s.a = "ohai";
3199 %! s.b = "dere";
3200 %! s.c = 42;
3201 %! idx1 = substruct (".", "a");
3202 %! idx2 = substruct (".", "b");
3203 %! idx3 = substruct (".", "c");
3204 %! idx4 = struct ("type", {}, "subs", {});
3205 %! assert (subsref (s, idx1), "ohai");
3206 %! assert (subsref (s, idx2), "dere");
3207 %! assert (subsref (s, idx3), 42);
3208 %! assert (subsref (s, idx4), s);
3209 %! s = subsasgn (s, idx1, "Hello");
3210 %! s = subsasgn (s, idx2, "There");
3211 %! s = subsasgn (s, idx3, 163);
3212 %!# s = subsasgn (s, idx4, 163);
3213 %! t.a = "Hello";
3214 %! t.b = "There";
3215 %! t.c = 163;
3216 %! assert (s, t);
3217 */
3218 
3219 DEFUN (is_sq_string, args, ,
3220  "-*- texinfo -*-\n\
3221 @deftypefn {Built-in Function} {} is_sq_string (@var{x})\n\
3222 Return true if @var{x} is a single-quoted character string.\n\
3223 @seealso{is_dq_string, ischar}\n\
3224 @end deftypefn")
3225 {
3226  octave_value retval;
3227 
3228  if (args.length () == 1)
3229  retval = args(0).is_sq_string ();
3230  else
3231  print_usage ();
3232 
3233  return retval;
3234 }
3235 
3236 /*
3237 %!assert (is_sq_string ('foo'), true)
3238 %!assert (is_sq_string ("foo"), false)
3239 %!assert (is_sq_string (1.0), false)
3240 %!assert (is_sq_string ({2.0}), false)
3241 
3242 %!error is_sq_string ()
3243 %!error is_sq_string ('foo', 2)
3244 */
3245 
3246 DEFUN (is_dq_string, args, ,
3247  "-*- texinfo -*-\n\
3248 @deftypefn {Built-in Function} {} is_dq_string (@var{x})\n\
3249 Return true if @var{x} is a double-quoted character string.\n\
3250 @seealso{is_sq_string, ischar}\n\
3251 @end deftypefn")
3252 {
3253  octave_value retval;
3254 
3255  if (args.length () == 1)
3256  retval = args(0).is_dq_string ();
3257  else
3258  print_usage ();
3259 
3260  return retval;
3261 }
3262 
3263 /*
3264 %!assert (is_dq_string ("foo"), true)
3265 %!assert (is_dq_string ('foo'), false)
3266 %!assert (is_dq_string (1.0), false)
3267 %!assert (is_dq_string ({2.0}), false)
3268 
3269 %!error is_dq_string ()
3270 %!error is_dq_string ("foo", 2)
3271 */
3272 
3273 DEFUN (disable_permutation_matrix, args, nargout,
3274  "-*- texinfo -*-\n\
3275 @deftypefn {Built-in Function} {@var{val} =} disable_permutation_matrix ()\n\
3276 @deftypefnx {Built-in Function} {@var{old_val} =} disable_permutation_matrix (@var{new_val})\n\
3277 @deftypefnx {Built-in Function} {} disable_permutation_matrix (@var{new_val}, \"local\")\n\
3278 Query or set the internal variable that controls whether permutation\n\
3279 matrices are stored in a special space-efficient format.\n\
3280 \n\
3281 The default value is true. If this option is disabled Octave will store\n\
3282 permutation matrices as full matrices.\n\
3283 \n\
3284 When called from inside a function with the @qcode{\"local\"} option, the\n\
3285 variable is changed locally for the function and any subroutines it calls.\n\
3286 The original variable value is restored when exiting the function.\n\
3287 @seealso{disable_range, disable_diagonal_matrix}\n\
3288 @end deftypefn")
3289 {
3290  return SET_INTERNAL_VARIABLE (disable_permutation_matrix);
3291 }
3292 
3293 /*
3294 %!function p = __test_dpm__ (dpm)
3295 %! disable_permutation_matrix (dpm, "local");
3296 %! [~, ~, p] = lu ([1,2;3,4]);
3297 %!endfunction
3298 
3299 %!assert (typeinfo (__test_dpm__ (false)), "permutation matrix");
3300 %!assert (typeinfo (__test_dpm__ (true)), "matrix");
3301 */
3302 
3303 DEFUN (disable_diagonal_matrix, args, nargout,
3304  "-*- texinfo -*-\n\
3305 @deftypefn {Built-in Function} {@var{val} =} disable_diagonal_matrix ()\n\
3306 @deftypefnx {Built-in Function} {@var{old_val} =} disable_diagonal_matrix (@var{new_val})\n\
3307 @deftypefnx {Built-in Function} {} disable_diagonal_matrix (@var{new_val}, \"local\")\n\
3308 Query or set the internal variable that controls whether diagonal\n\
3309 matrices are stored in a special space-efficient format.\n\
3310 \n\
3311 The default value is true. If this option is disabled Octave will store\n\
3312 diagonal matrices as full matrices.\n\
3313 \n\
3314 When called from inside a function with the @qcode{\"local\"} option, the\n\
3315 variable is changed locally for the function and any subroutines it calls.\n\
3316 The original variable value is restored when exiting the function.\n\
3317 @seealso{disable_range, disable_permutation_matrix}\n\
3318 @end deftypefn")
3319 {
3320  return SET_INTERNAL_VARIABLE (disable_diagonal_matrix);
3321 }
3322 
3323 /*
3324 %!function [x, xi, fx, fxi] = __test_ddm__ (ddm)
3325 %! disable_diagonal_matrix (ddm, "local");
3326 %! x = eye (2);
3327 %! xi = x*i;
3328 %! fx = single (x);
3329 %! fxi = single (xi);
3330 %!endfunction
3331 
3332 %!shared x, xi, fx, fxi
3333 %! [x, xi, fx, fxi] = __test_ddm__ (false);
3334 %!assert (typeinfo (x), "diagonal matrix");
3335 %!assert (typeinfo (xi), "complex diagonal matrix");
3336 %!assert (typeinfo (fx), "float diagonal matrix");
3337 %!assert (typeinfo (fxi), "float complex diagonal matrix");
3338 
3339 %!shared x, xi, fx, fxi
3340 %! [x, xi, fx, fxi] = __test_ddm__ (true);
3341 %!assert (typeinfo (x), "matrix");
3342 %!assert (typeinfo (xi), "complex matrix");
3343 %!assert (typeinfo (fx), "float matrix");
3344 %!assert (typeinfo (fxi), "float complex matrix");
3345 */
3346 
3347 DEFUN (disable_range, args, nargout,
3348  "-*- texinfo -*-\n\
3349 @deftypefn {Built-in Function} {@var{val} =} disable_range ()\n\
3350 @deftypefnx {Built-in Function} {@var{old_val} =} disable_range (@var{new_val})\n\
3351 @deftypefnx {Built-in Function} {} disable_range (@var{new_val}, \"local\")\n\
3352 Query or set the internal variable that controls whether ranges are stored\n\
3353 in a special space-efficient format.\n\
3354 \n\
3355 The default value is true. If this option is disabled Octave will store\n\
3356 ranges as full matrices.\n\
3357 \n\
3358 When called from inside a function with the @qcode{\"local\"} option, the\n\
3359 variable is changed locally for the function and any subroutines it calls.\n\
3360 The original variable value is restored when exiting the function.\n\
3361 @seealso{disable_diagonal_matrix, disable_permutation_matrix}\n\
3362 @end deftypefn")
3363 {
3364  return SET_INTERNAL_VARIABLE (disable_range);
3365 }
3366 
3367 /*
3368 %!function r = __test_dr__ (dr)
3369 %! disable_range (dr, "local");
3370 %! ## Constant folding will produce range for 1:13.
3371 %! base = 1;
3372 %! limit = 13;
3373 %! r = base:limit;
3374 %!endfunction
3375 
3376 %!assert (typeinfo (__test_dr__ (false)), "range");
3377 %!assert (typeinfo (__test_dr__ (true)), "matrix");
3378 */
3379 
uint8NDArray uint8_array_value(void) const
Definition: ov.h:882
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
Definition: gripes.cc:180
static void register_type(void)
Definition: ov-null-mat.cc:75
bool is_object(void) const
Definition: ov.h:577
ColumnVector column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1658
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
Definition: ov.h:798
const Cell & contents(const_iterator p) const
Definition: oct-map.h:314
bool is_empty(void) const
Definition: Array.h:472
octave_value(void)
Definition: ov.h:171
static void register_type(void)
virtual int write(octave_stream &os, int block_size, oct_data_conv::data_type output_type, int skip, oct_mach_info::float_format flt_fmt) const
Definition: ov-base.cc:1111
void(* non_const_unary_op_fcn)(octave_base_value &)
Definition: ov-typeinfo.h:44
Definition: Cell.h:35
virtual octave_fcn_handle * fcn_handle_value(bool silent=false)
Definition: ov-base.cc:1036
octave_refcount< octave_idx_type > count
Definition: ov-base.h:818
assign_op
Definition: ov.h:131
octave_value(* binary_op_fcn)(const octave_base_value &, const octave_base_value &)
Definition: ov-typeinfo.h:50
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov.h:401
#define C(a, b)
Definition: Faddeeva.cc:255
virtual octave_value_list do_multi_index_op(int nargout, const octave_value_list &idx)
Definition: ov-base.cc:203
octave_value & operator=(const octave_value &a)
Definition: ov.h:357
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_idx_type rows(void) const
Definition: ov.h:473
octave_value do_cat_op(const octave_value &v1, const octave_value &v2, const Array< octave_idx_type > &ra_idx)
Definition: ov.cc:2304
int8NDArray int8_array_value(void) const
Definition: ov.h:870
void print_info(std::ostream &os, const std::string &prefix=std::string()) const
Definition: ov.cc:2488
virtual octave_map map_value(void) const
Definition: ov-base.cc:934
octave_base_value * empty_clone(void) const
Definition: ov.h:314
static octave_value find_method(const std::string &name, const std::string &dispatch_type)
Definition: symtab.h:1501
FloatColumnVector float_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1869
bool is_uint16_type(void) const
Definition: ov.h:634
static void register_type(void)
Definition: ov-builtin.cc:39
static void register_type(void)
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
static std::string binary_op_as_string(binary_op)
Definition: ov.cc:190
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
static bool Vdisable_range
Definition: ov.cc:107
int16NDArray int16_array_value(void) const
Definition: ov.h:873
octave_idx_type length(void) const
Definition: oct-obj.h:89
octave_map map_value(void) const
Definition: ov.cc:1585
octave_value do_unary_op(octave_value::unary_op op, const octave_value &v)
Definition: ov.cc:2511
octave_user_code * user_code_value(bool silent=false) const
Definition: ov.cc:1615
F77_RET_T const octave_idx_type Complex * A
Definition: CmplxGEPBAL.cc:39
static void register_type(void)
Definition: ov-float.cc:59
static assign_op binary_op_to_assign_op(binary_op)
Definition: ov.cc:541
bool contains(const std::string &name) const
Definition: oct-map.h:333
bool is_defined(void) const
Definition: ov.h:520
static non_const_unary_op_fcn lookup_non_const_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.h:122
static void register_type(void)
Definition: ov-lazy-idx.cc:33
static void register_type(void)
Definition: ov-re-diag.cc:40
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:730
Definition: Range.h:31
uint64NDArray uint64_array_value(void) const
Definition: ov.h:891
binary_op
Definition: ov.h:87
int64_t int64_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:749
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
void error(const char *fmt,...)
Definition: error.cc:476
int32NDArray int32_array_value(void) const
Definition: ov.h:876
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:120
static std::string unary_op_fcn_name(unary_op)
Definition: ov.cc:156
bool is_int8_type(void) const
Definition: ov.h:619
octave_value_list feval(const std::string &name, const octave_value_list &args, int nargout)
Definition: oct-parse.cc:8625
void install_types(void)
Definition: ov.cc:2865
int type_id(void) const
Definition: ov.h:1045
static void register_type(void)
Definition: ov-usr-fcn.cc:185
static void register_type(void)
Definition: ov-cell.cc:129
void make_unique(void)
Definition: ov.h:326
static void register_type(void)
Definition: ov-struct.cc:1146
static binary_op assign_op_to_binary_op(assign_op)
Definition: ov.cc:502
octave_value(* binary_class_op_fcn)(const octave_value &, const octave_value &)
Definition: ov-typeinfo.h:47
static void register_type(void)
static std::string assign_op_as_string(assign_op)
Definition: ov.cc:428
void gripe_library_execution_error(void)
Definition: gripes.cc:208
T & elem(octave_idx_type n)
Definition: Array.h:380
static binary_op_fcn lookup_binary_op(octave_value::binary_op op, int t1, int t2)
Definition: ov-typeinfo.h:134
octave_idx_type numel(void) const
Definition: oct-map.h:372
static void gripe_cat_op_conv(void)
Definition: ov.cc:2298
static void register_type(void)
Definition: ov-str-mat.cc:60
const octave_base_value const Array< octave_idx_type > &ra_idx octave_int16_scalar & v1
static void register_type(void)
bool is_int32_type(void) const
Definition: ov.h:625
octave_fcn_handle * fcn_handle_value(bool silent=false) const
Definition: ov.cc:1621
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-base.cc:158
octave_idx_type idx_type_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.cc:1575
static void register_type(void)
binary_op op_eq_to_binary_op(assign_op op)
Definition: ov.cc:2756
Array< Complex > complex_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1855
octave_value & do_non_const_unary_op(unary_op op)
Definition: ov.cc:2593
octave_base_value * clone(void) const
Definition: ov.cc:1265
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:361
F77_RET_T const double const double double * d
virtual octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-base.cc:227
octave_base_value * rep
Definition: ov.h:1248
virtual void print_info(std::ostream &os, const std::string &prefix) const
Definition: ov-base.cc:449
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov.cc:1414
int64NDArray int64_array_value(void) const
Definition: ov.h:879
Cell cell_value(void) const
Definition: ov.cc:1566
static unary_class_op_fcn lookup_unary_class_op(octave_value::unary_op op)
Definition: ov-typeinfo.h:110
octave_base_value::type_conv_info numeric_demotion_function(void) const
Definition: ov.h:376
static bool Vdisable_permutation_matrix
Definition: ov.cc:103
virtual octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-base.cc:295
virtual octave_value_list list_value(void) const
Definition: ov-base.cc:1058
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
static void register_type(void)
Definition: ov-bool.cc:51
octave_value single_subsref(const std::string &type, const octave_value_list &idx)
Definition: ov.cc:1285
static void register_type(void)
Definition: ov-cx-sparse.cc:56
octave_value_list do_multi_index_op(int nargout, const octave_value_list &idx)
Definition: ov.cc:1382
virtual octave_fcn_inline * fcn_inline_value(bool silent=false)
Definition: ov-base.cc:1047
static void register_type(void)
Definition: ov-perm.cc:420
virtual octave_base_value * clone(void) const
Definition: ov-base.h:216
octave_value(* cat_op_fcn)(octave_base_value &, const octave_base_value &, const Array< octave_idx_type > &ra_idx)
Definition: ov-typeinfo.h:53
octave_idx_type columns(void) const
Definition: ov.h:475
virtual octave_base_value * try_narrowing_conversion(void)
Definition: ov-base.h:240
static void register_type(void)
Definition: ov-str-mat.cc:58
FloatNDArray float_array_value(bool frc_str_conv=false) const
Definition: ov.h:782
static void register_type(void)
Definition: ov-oncleanup.cc:35
virtual octave_user_function * user_function_value(bool silent=false)
Definition: ov-base.cc:1003
bool is_null_value(void) const
Definition: ov.h:592
F77_RET_T const double const double * f
static void register_type(void)
Definition: ov-cx-mat.cc:64
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
Definition: ov.h:1017
virtual octave_scalar_map scalar_map_value(void) const
Definition: ov-base.cc:942
octave_idx_type nfields(void) const
Definition: oct-map.h:327
static void register_type(void)
Definition: ov-struct.cc:52
octave_value(* unary_op_fcn)(const octave_base_value &)
Definition: ov-typeinfo.h:42
static void register_type(void)
Definition: ov-scalar.cc:58
void error_with_cfn(const char *fmt,...)
Definition: error.cc:491
static void register_type(void)
Definition: ov-class.cc:67
static void register_type(void)
Definition: ov-re-mat.cc:75
octave_base_value::type_conv_info numeric_conversion_function(void) const
Definition: ov.h:373
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
Definition: ov.h:802
bool is_string(void) const
Definition: ov.h:562
octave_user_function * user_function_value(bool silent=false) const
Definition: ov.cc:1603
void maybe_economize(void)
Definition: ov.h:999
static std::string binary_op_fcn_name(binary_op)
Definition: ov.cc:288
static void register_type(void)
Definition: ov-re-sparse.cc:55
int error_state
Definition: error.cc:101
static void register_type(void)
Definition: ov-null-mat.cc:32
static void register_type(void)
Array< octave_idx_type > octave_idx_type_vector_value(bool req_int=false, bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1792
friend OCTINTERP_API octave_value do_binary_op(binary_op op, const octave_value &a, const octave_value &b)
Definition: ov.cc:1978
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1033
octave_value & assign(assign_op op, const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov.cc:1430
bool is_int64_type(void) const
Definition: ov.h:628
virtual octave_base_value * empty_clone(void) const
Definition: ov-base.cc:121
#define panic_impossible()
Definition: error.h:33
FloatComplexRowVector float_complex_row_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1894
static void register_type(void)
static int static_type_id(void)
Definition: ov-classdef.h:1486
assign_op unary_op_to_assign_op(unary_op op)
Definition: ov.cc:2731
octave_idx_type length(void) const
Definition: ov.cc:1525
static void register_type(void)
Definition: ov-base.cc:114
static binary_class_op_fcn lookup_binary_class_op(octave_value::binary_op op)
Definition: ov-typeinfo.h:128
Definition: dMatrix.h:35
dim_vector dims(void) const
Definition: ov.h:470
virtual octave_user_code * user_code_value(bool silent=false)
Definition: ov-base.cc:1025
Matrix matrix_value(bool frc_str_conv=false) const
Definition: ov.h:773
int write(octave_stream &os, int block_size, oct_data_conv::data_type output_type, int skip, oct_mach_info::float_format flt_fmt) const
Definition: ov.cc:1956
static void register_type(void)
Definition: ov-complex.cc:56
void make_storable_value(void)
Definition: ov.cc:1942
static void register_type(void)
double arg(double x)
Definition: lo-mappers.h:37
octave_function * function_value(bool silent=false) const
Definition: ov.cc:1597
static void gripe_unary_op_conv(const std::string &on)
Definition: ov.cc:2505
T & xelem(octave_idx_type n)
Definition: Array.h:353
bool is_int16_type(void) const
Definition: ov.h:622
static void gripe_binary_op_conv(const std::string &on)
Definition: ov.cc:1972
bool is_true(void) const
Definition: ov.h:671
static void gripe_unary_op(const std::string &on, const std::string &tn)
Definition: ov.cc:2498
magic_colon
Definition: ov.h:169
std::string type_name(void) const
Definition: ov.h:1047
idx_class_type idx_class(void) const
Definition: idx-vector.h:549
static Array< octave_idx_type > convert_to_octave_idx_type_array(const Array< octave_int< T > > &A)
Definition: ov.cc:1780
octave_idx_type length(void) const
Number of elements in the array.
Definition: Array.h:267
octave_value(* assign_op_fcn)(octave_base_value &, const octave_value_list &, const octave_base_value &)
Definition: ov-typeinfo.h:57
bool is_empty(void) const
Definition: ov.h:526
octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov.cc:1422
const octave_char_matrix & v2
bool is_sq_string(void) const
Definition: ov.h:565
NDArray array_value(bool frc_str_conv=false) const
Definition: ov.h:779
static cat_op_fcn lookup_cat_op(int t1, int t2)
Definition: ov-typeinfo.h:152
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
Definition: ov-base.h:185
FloatRowVector float_row_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1886
octave_scalar_map scalar_map_value(void) const
Definition: ov.cc:1591
ComplexRowVector complex_row_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1682
bool is_dq_string(void) const
Definition: ov.h:568
static void gripe_cat_op(const std::string &tn1, const std::string &tn2)
Definition: ov.cc:2291
void maybe_mutate(void)
Definition: ov.cc:1271
bool is_uint8_type(void) const
Definition: ov.h:631
RowVector row_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1674
static bool Vdisable_diagonal_matrix
Definition: ov.cc:99
FloatComplexColumnVector float_complex_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1877
octave_value(* unary_class_op_fcn)(const octave_value &)
Definition: ov-typeinfo.h:40
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1690
static void gripe_assign_failed_or_no_method(const std::string &on, const std::string &tn1, const std::string &tn2)
Definition: ov.cc:1405
compound_binary_op
Definition: ov.h:114
std::string class_name(void) const
Definition: ov.h:1049
octave_idx_type get_count(void) const
Definition: ov.h:371
static void register_type(void)
Definition: ov-cs-list.cc:39
bool is_undefined(void) const
Definition: ov.h:523
bool is_uint64_type(void) const
Definition: ov.h:640
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Definition: Array.h:460
void unconvert(idx_class_type &iclass, double &scalar, Range &range, Array< double > &array, Array< bool > &mask) const
Definition: idx-vector.cc:1232
static void decode_subscripts(const char *name, const octave_value &arg, std::string &type_string, std::list< octave_value_list > &idx)
Definition: ov.cc:2950
octave_value_list list_value(void) const
Definition: ov.cc:1633
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
ComplexColumnVector complex_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1666
Array< int > int_vector_value(bool req_int=false, bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1717
friend OCTINTERP_API octave_value do_unary_op(unary_op op, const octave_value &a)
Definition: ov.cc:2511
Array< FloatComplex > float_complex_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1916
static assign_op_fcn lookup_assign_op(octave_value::assign_op op, int t_lhs, int t_rhs)
Definition: ov-typeinfo.h:158
std::complex< double > Complex
Definition: oct-cmplx.h:29
virtual octave_function * function_value(bool silent=false)
Definition: ov-base.cc:992
octave_fcn_inline * fcn_inline_value(bool silent=false) const
Definition: ov.cc:1627
static void gripe_unary_op_conversion_failed(const std::string &op, const std::string &tn)
Definition: ov.cc:2585
static std::string unary_op_as_string(unary_op)
Definition: ov.cc:114
static Array< int > convert_to_int_array(const Array< octave_int< T > > &A)
Definition: ov.cc:1705
bool is_uint32_type(void) const
Definition: ov.h:637
static void register_type(void)
Definition: ov-colon.cc:35
octave_user_script * user_script_value(bool silent=false) const
Definition: ov.cc:1609
virtual Cell cell_value(void) const
Definition: ov-base.cc:533
octave_value storable_value(void) const
Definition: ov.cc:1930
unary_op
Definition: ov.h:74
bool is_equal(const octave_value &) const
Definition: ov.cc:1547
static void register_type(void)
Definition: ov-dld-fcn.cc:39
void chop_trailing_singletons(void)
Definition: dim-vector.h:214
octave_value do_colon_op(const octave_value &base, const octave_value &increment, const octave_value &limit, bool is_for_cmd_expr)
Definition: ov.cc:2393
uint32NDArray uint32_array_value(void) const
Definition: ov.h:888
static dim_vector make_vector_dims(const dim_vector &dv, bool force_vector_conversion, const std::string &my_type, const std::string &wanted_type)
Definition: ov.cc:1639
int length(void) const
Definition: dim-vector.h:281
virtual octave_user_script * user_script_value(bool silent=false)
Definition: ov-base.cc:1014
static int static_type_id(void)
Definition: ov-class.h:213
uint16NDArray uint16_array_value(void) const
Definition: ov.h:885
static void register_type(void)
Definition: ov-null-mat.cc:53
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
Definition: ov.cc:1317
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
Definition: ov.cc:2829
static bool scalar(const dim_vector &dims)
Definition: ov-struct.cc:736
Array< float > float_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1902
octave_value do_binary_op(octave_value::binary_op op, const octave_value &v1, const octave_value &v2)
Definition: ov.cc:1978
static void gripe_binary_op(const std::string &on, const std::string &tn1, const std::string &tn2)
Definition: ov.cc:1964
static void register_type(void)
Definition: ov-range.cc:53
size_t byte_size(void) const
Definition: ov.h:489
static void register_type(void)
Definition: ov-cx-diag.cc:41
static octave_value decompose_binary_op(octave_value::compound_binary_op op, const octave_value &v1, const octave_value &v2)
Definition: ov.cc:2171
static unary_op_fcn lookup_unary_op(octave_value::unary_op op, int t)
Definition: ov-typeinfo.h:116
bool is_integer_type(void) const
Definition: ov.h:648
static void register_type(void)
Definition: ov-bool-mat.cc:58