Mercurial > octave
annotate libinterp/parse-tree/pt-mat.cc @ 23075:4e3d47dc7e25
move parse tree classes inside octave namespace
* lex.h, lex.ll, oct-parse.in.yy, parse.h, pt-all.h, pt-arg-list.cc,
pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc,
pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc,
pt-cbinop.h, pt.cc, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc,
pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h,
pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h,
pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt.h,
pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h,
pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h,
pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc,
pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, token.cc, token.h:
Move classes and most functions inside octave namespace.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Jan 2017 23:41:54 -0500 |
parents | 27e4ec3b0b49 |
children | ef4d915df748 |
rev | line source |
---|---|
1741 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
3 Copyright (C) 1996-2016 John W. Eaton |
1741 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
1741 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
1741 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1741 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21261
diff
changeset
|
24 # include "config.h" |
1741 | 25 #endif |
26 | |
3503 | 27 #include <iostream> |
1741 | 28 |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
29 #include "oct-locbuf.h" |
5502 | 30 #include "quit.h" |
31 | |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
32 #include "data.h" |
2172 | 33 #include "defun.h" |
1741 | 34 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
35 #include "errwarn.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
36 #include "oct-map.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
37 #include "ovl.h" |
2982 | 38 #include "pt-arg-list.h" |
3770 | 39 #include "pt-bp.h" |
1741 | 40 #include "pt-exp.h" |
41 #include "pt-mat.h" | |
2124 | 42 #include "pt-walk.h" |
2201 | 43 #include "utils.h" |
2371 | 44 #include "ov.h" |
45 #include "variables.h" | |
1741 | 46 |
9460
1fddcf651559
avoid complex -> real conversion when constructing arrays with []
John W. Eaton <jwe@octave.org>
parents:
9389
diff
changeset
|
47 #include "ov-cx-mat.h" |
1fddcf651559
avoid complex -> real conversion when constructing arrays with []
John W. Eaton <jwe@octave.org>
parents:
9389
diff
changeset
|
48 #include "ov-flt-cx-mat.h" |
5630 | 49 #include "ov-re-sparse.h" |
50 #include "ov-cx-sparse.h" | |
51 | |
2254 | 52 // The character to fill with when creating string arrays. |
3836 | 53 char Vstring_fill_char = ' '; |
2254 | 54 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
55 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
56 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
57 // General matrices. This list type is much more work to handle than |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
58 // constant matrices, but it allows us to construct matrices from |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
59 // other matrices, variables, and functions. |
1741 | 60 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
61 // But first, some internal classes that make our job much easier. |
1827 | 62 |
63 class | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
64 tm_row_const |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
65 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
66 private: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
67 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
68 class |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
69 tm_row_const_rep : public octave::base_list<octave_value> |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
70 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
71 public: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
72 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
73 tm_row_const_rep (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
74 : count (1), dv (0, 0), all_str (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
75 all_sq_str (false), all_dq_str (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
76 some_str (false), all_real (false), all_cmplx (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
77 all_mt (true), any_cell (false), any_sparse (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
78 any_class (false), all_1x1 (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
79 first_elem_is_struct (false), class_nm (), ok (false) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
80 { } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
81 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
82 tm_row_const_rep (const tree_argument_list& row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
83 : count (1), dv (0, 0), all_str (false), all_sq_str (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
84 some_str (false), all_real (false), all_cmplx (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
85 all_mt (true), any_cell (false), any_sparse (false), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
86 any_class (false), all_1x1 (! row.empty ()), |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
87 first_elem_is_struct (false), class_nm (), ok (false) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
88 { init (row); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
89 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
90 ~tm_row_const_rep (void) = default; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
91 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
92 octave::refcount<int> count; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
93 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
94 dim_vector dv; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
95 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
96 bool all_str; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
97 bool all_sq_str; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
98 bool all_dq_str; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
99 bool some_str; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
100 bool all_real; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
101 bool all_cmplx; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
102 bool all_mt; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
103 bool any_cell; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
104 bool any_sparse; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
105 bool any_class; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
106 bool all_1x1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
107 bool first_elem_is_struct; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
108 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
109 std::string class_nm; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
110 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
111 bool ok; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
112 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
113 void do_init_element (const octave_value&, bool&); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
114 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
115 void init (const tree_argument_list&); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
116 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
117 void cellify (void); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
118 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
119 private: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
120 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
121 tm_row_const_rep (const tm_row_const_rep&); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
122 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
123 tm_row_const_rep& operator = (const tm_row_const_rep&); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
124 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
125 }; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
126 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
127 public: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
128 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
129 typedef tm_row_const_rep::iterator iterator; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
130 typedef tm_row_const_rep::const_iterator const_iterator; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
131 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
132 tm_row_const (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
133 : rep (0) { } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
134 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
135 tm_row_const (const tree_argument_list& row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
136 : rep (new tm_row_const_rep (row)) { } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
137 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
138 tm_row_const (const tm_row_const& x) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
139 : rep (x.rep) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
140 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
141 if (rep) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
142 rep->count++; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
143 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
144 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
145 tm_row_const& operator = (const tm_row_const& x) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
146 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
147 if (this != &x && rep != x.rep) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
148 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
149 if (rep && --rep->count == 0) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
150 delete rep; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
151 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
152 rep = x.rep; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
153 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
154 if (rep) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
155 rep->count++; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
156 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
157 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
158 return *this; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
159 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
160 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
161 ~tm_row_const (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
162 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
163 if (rep && --rep->count == 0) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
164 delete rep; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
165 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
166 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
167 octave_idx_type rows (void) { return rep->dv(0); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
168 octave_idx_type cols (void) { return rep->dv(1); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
169 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
170 bool empty (void) const { return rep->empty (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
171 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
172 size_t length (void) const { return rep->length (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
173 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
174 dim_vector dims (void) { return rep->dv; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
175 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
176 bool all_strings_p (void) const { return rep->all_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
177 bool all_sq_strings_p (void) const { return rep->all_sq_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
178 bool all_dq_strings_p (void) const { return rep->all_dq_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
179 bool some_strings_p (void) const { return rep->some_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
180 bool all_real_p (void) const { return rep->all_real; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
181 bool all_complex_p (void) const { return rep->all_cmplx; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
182 bool all_empty_p (void) const { return rep->all_mt; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
183 bool any_cell_p (void) const { return rep->any_cell; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
184 bool any_sparse_p (void) const { return rep->any_sparse; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
185 bool any_class_p (void) const { return rep->any_class; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
186 bool all_1x1_p (void) const { return rep->all_1x1; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
187 bool first_elem_struct_p (void) const { return rep->first_elem_is_struct; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
188 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
189 std::string class_name (void) const { return rep->class_nm; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
190 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
191 void cellify (void) { rep->cellify (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
192 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
193 operator bool () const { return (rep && rep->ok); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
194 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
195 iterator begin (void) { return rep->begin (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
196 const_iterator begin (void) const { return rep->begin (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
197 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
198 iterator end (void) { return rep->end (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
199 const_iterator end (void) const { return rep->end (); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
200 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
201 private: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
202 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
203 tm_row_const_rep *rep; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
204 }; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
205 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
206 std::string |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
207 get_concat_class (const std::string& c1, const std::string& c2) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
208 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
209 std::string retval = octave_base_value::static_class_name (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
210 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
211 if (c1 == c2) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
212 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
213 else if (c1.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
214 retval = c2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
215 else if (c2.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
216 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
217 else if (c1 == "class" || c2 == "class") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
218 retval = "class"; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
219 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
220 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
221 bool c1_is_int = (c1 == "int8" || c1 == "uint8" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
222 || c1 == "int16" || c1 == "uint16" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
223 || c1 == "int32" || c1 == "uint32" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
224 || c1 == "int64" || c1 == "uint64"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
225 bool c2_is_int = (c2 == "int8" || c2 == "uint8" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
226 || c2 == "int16" || c2 == "uint16" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
227 || c2 == "int32" || c2 == "uint32" |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
228 || c2 == "int64" || c2 == "uint64"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
229 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
230 bool c1_is_char = (c1 == "char"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
231 bool c2_is_char = (c2 == "char"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
232 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
233 bool c1_is_double = (c1 == "double"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
234 bool c2_is_double = (c2 == "double"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
235 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
236 bool c1_is_single = (c1 == "single"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
237 bool c2_is_single = (c2 == "single"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
238 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
239 bool c1_is_logical = (c1 == "logical"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
240 bool c2_is_logical = (c2 == "logical"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
241 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
242 bool c1_is_built_in_type |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
243 = (c1_is_int || c1_is_char || c1_is_double || c1_is_single |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
244 || c1_is_logical); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
245 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
246 bool c2_is_built_in_type |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
247 = (c2_is_int || c2_is_char || c2_is_double || c2_is_single |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
248 || c2_is_logical); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
249 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
250 // Order is important here... |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
251 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
252 if (c1 == "struct" && c2 == c1) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
253 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
254 else if (c1 == "cell" || c2 == "cell") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
255 retval = "cell"; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
256 else if (c1_is_char && c2_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
257 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
258 else if (c2_is_char && c1_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
259 retval = c2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
260 else if (c1_is_int && c2_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
261 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
262 else if (c2_is_int && c1_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
263 retval = c2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
264 else if (c1_is_single && c2_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
265 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
266 else if (c2_is_single && c1_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
267 retval = c2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
268 else if (c1_is_double && c2_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
269 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
270 else if (c2_is_double && c1_is_built_in_type) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
271 retval = c2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
272 else if (c1_is_logical && c2_is_logical) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
273 retval = c1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
274 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
275 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
276 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
277 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
278 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
279 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
280 OCTAVE_NORETURN static |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
281 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
282 eval_error (const char *msg, const dim_vector& x, const dim_vector& y) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
283 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
284 error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
285 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
286 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
287 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
288 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
289 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
290 tm_row_const::tm_row_const_rep::do_init_element (const octave_value& val, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
291 bool& first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
292 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
293 std::string this_elt_class_nm |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
294 = val.is_object () ? std::string ("class") : val.class_name (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
295 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
296 class_nm = get_concat_class (class_nm, this_elt_class_nm); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
297 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
298 dim_vector this_elt_dv = val.dims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
299 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
300 if (! this_elt_dv.zero_by_zero ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
301 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
302 all_mt = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
303 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
304 if (first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
305 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
306 if (val.is_map ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
307 first_elem_is_struct = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
308 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
309 first_elem = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
310 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
311 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
312 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
313 append (val); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
314 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
315 if (all_str && ! val.is_string ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
316 all_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
317 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
318 if (all_sq_str && ! val.is_sq_string ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
319 all_sq_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
320 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
321 if (all_dq_str && ! val.is_dq_string ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
322 all_dq_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
323 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
324 if (! some_str && val.is_string ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
325 some_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
326 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
327 if (all_real && ! val.is_real_type ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
328 all_real = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
329 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
330 if (all_cmplx && ! (val.is_complex_type () || val.is_real_type ())) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
331 all_cmplx = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
332 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
333 if (! any_cell && val.is_cell ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
334 any_cell = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
335 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
336 if (! any_sparse && val.is_sparse_type ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
337 any_sparse = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
338 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
339 if (! any_class && val.is_object ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
340 any_class = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
341 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
342 // Special treatment of sparse matrices to avoid out-of-memory error |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
343 all_1x1 = all_1x1 && ! val.is_sparse_type () && val.numel () == 1; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
344 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
345 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
346 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
347 tm_row_const::tm_row_const_rep::init (const tree_argument_list& row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
348 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
349 all_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
350 all_sq_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
351 all_dq_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
352 all_real = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
353 all_cmplx = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
354 any_cell = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
355 any_sparse = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
356 any_class = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
357 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
358 bool first_elem = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
359 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
360 for (tree_expression* elt : row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
361 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
362 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
363 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
364 octave_value tmp = elt->rvalue1 (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
365 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
366 if (tmp.is_undefined ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
367 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
368 ok = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
369 return; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
370 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
371 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
372 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
373 if (tmp.is_cs_list ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
374 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
375 octave_value_list tlst = tmp.list_value (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
376 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
377 for (octave_idx_type i = 0; i < tlst.length (); i++) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
378 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
379 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
380 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
381 do_init_element (tlst(i), first_elem); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
382 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
383 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
384 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
385 do_init_element (tmp, first_elem); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
386 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
387 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
388 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
389 if (any_cell && ! any_class && ! first_elem_is_struct) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
390 cellify (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
391 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
392 first_elem = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
393 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
394 for (const octave_value& val : *this) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
395 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
396 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
397 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
398 dim_vector this_elt_dv = val.dims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
399 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
400 if (! this_elt_dv.zero_by_zero ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
401 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
402 all_mt = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
403 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
404 if (first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
405 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
406 first_elem = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
407 dv = this_elt_dv; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
408 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
409 else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1))) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
410 eval_error ("horizontal dimensions mismatch", dv, this_elt_dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
411 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
412 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
413 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
414 ok = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
415 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
416 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
417 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
418 tm_row_const::tm_row_const_rep::cellify (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
419 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
420 bool elt_changed = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
421 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
422 for (auto& elt : *this) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
423 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
424 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
425 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
426 if (! elt.is_cell ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
427 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
428 elt_changed = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
429 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
430 if (elt.is_empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
431 elt = Cell (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
432 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
433 elt = Cell (elt); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
434 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
435 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
436 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
437 if (elt_changed) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
438 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
439 bool first_elem = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
440 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
441 for (const octave_value& val : *this) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
442 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
443 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
444 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
445 dim_vector this_elt_dv = val.dims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
446 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
447 if (! this_elt_dv.zero_by_zero ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
448 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
449 if (first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
450 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
451 first_elem = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
452 dv = this_elt_dv; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
453 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
454 else if (! dv.hvcat (this_elt_dv, 1)) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
455 eval_error ("horizontal dimensions mismatch", dv, this_elt_dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
456 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
457 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
458 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
459 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
460 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
461 class |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
462 tm_const : public octave::base_list<tm_row_const> |
1827 | 463 { |
464 public: | |
465 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
466 tm_const (const tree_matrix& tm) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
467 : dv (0, 0), all_str (false), all_sq_str (false), all_dq_str (false), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
468 some_str (false), all_real (false), all_cmplx (false), |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
469 all_mt (true), any_cell (false), any_sparse (false), |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
470 any_class (false), class_nm (), ok (false) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
471 { init (tm); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
472 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
473 ~tm_const (void) = default; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
474 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
475 octave_idx_type rows (void) const { return dv.elem (0); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
476 octave_idx_type cols (void) const { return dv.elem (1); } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
477 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
478 dim_vector dims (void) const { return dv; } |
1827 | 479 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
480 bool all_strings_p (void) const { return all_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
481 bool all_sq_strings_p (void) const { return all_sq_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
482 bool all_dq_strings_p (void) const { return all_dq_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
483 bool some_strings_p (void) const { return some_str; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
484 bool all_real_p (void) const { return all_real; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
485 bool all_complex_p (void) const { return all_cmplx; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
486 bool all_empty_p (void) const { return all_mt; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
487 bool any_cell_p (void) const { return any_cell; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
488 bool any_sparse_p (void) const { return any_sparse; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
489 bool any_class_p (void) const { return any_class; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
490 bool all_1x1_p (void) const { return all_1x1; } |
1827 | 491 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
492 std::string class_name (void) const { return class_nm; } |
1827 | 493 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
494 operator bool () const { return ok; } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
495 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
496 private: |
1827 | 497 |
4765 | 498 dim_vector dv; |
1741 | 499 |
1827 | 500 bool all_str; |
5280 | 501 bool all_sq_str; |
502 bool all_dq_str; | |
3110 | 503 bool some_str; |
5502 | 504 bool all_real; |
505 bool all_cmplx; | |
2602 | 506 bool all_mt; |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
507 bool any_cell; |
5630 | 508 bool any_sparse; |
8147
9a5ef4f632a3
Add class dispatch for [] operator to vertcat/horzcat methods
David Bateman <dbateman@free.fr>
parents:
8107
diff
changeset
|
509 bool any_class; |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
510 bool all_1x1; |
1827 | 511 |
5533 | 512 std::string class_nm; |
513 | |
1827 | 514 bool ok; |
515 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
516 tm_const (void); |
4501 | 517 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
518 tm_const (const tm_const&); |
13144
c99f24c10ca3
fix vertical concatenation involving cell arrays
John W. Eaton <jwe@octave.org>
parents:
13142
diff
changeset
|
519 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
520 tm_const& operator = (const tm_const&); |
1827 | 521 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
522 void init (const tree_matrix& tm); |
1827 | 523 }; |
524 | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
525 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
526 tm_const::init (const tree_matrix& tm) |
2990 | 527 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
528 all_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
529 all_sq_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
530 all_dq_str = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
531 all_real = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
532 all_cmplx = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
533 any_cell = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
534 any_sparse = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
535 any_class = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
536 all_1x1 = ! tm.empty (); |
1827 | 537 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
538 bool first_elem = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
539 bool first_elem_is_struct = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
540 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
541 // Just eval and figure out if what we have is complex or all strings. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
542 // We can't check columns until we know that this is a numeric matrix -- |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
543 // collections of strings can have elements of different lengths. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
544 for (const tree_argument_list* elt : tm) |
2990 | 545 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
546 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
547 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
548 tm_row_const tmp (*elt); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
549 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
550 if (first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
551 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
552 first_elem_is_struct = tmp.first_elem_struct_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
553 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
554 first_elem = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
555 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
556 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
557 if (tmp && ! tmp.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
558 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
559 if (all_str && ! tmp.all_strings_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
560 all_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
561 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
562 if (all_sq_str && ! tmp.all_sq_strings_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
563 all_sq_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
564 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
565 if (all_dq_str && ! tmp.all_dq_strings_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
566 all_dq_str = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
567 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
568 if (! some_str && tmp.some_strings_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
569 some_str = true; |
1741 | 570 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
571 if (all_real && ! tmp.all_real_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
572 all_real = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
573 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
574 if (all_cmplx && ! tmp.all_complex_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
575 all_cmplx = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
576 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
577 if (all_mt && ! tmp.all_empty_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
578 all_mt = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
579 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
580 if (! any_cell && tmp.any_cell_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
581 any_cell = true; |
1827 | 582 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
583 if (! any_sparse && tmp.any_sparse_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
584 any_sparse = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
585 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
586 if (! any_class && tmp.any_class_p ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
587 any_class = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
588 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
589 all_1x1 = all_1x1 && tmp.all_1x1_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
590 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
591 append (tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
592 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
593 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
594 break; |
2990 | 595 } |
1741 | 596 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
597 if (any_cell && ! any_class && ! first_elem_is_struct) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
598 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
599 for (auto& elt : *this) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
600 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
601 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
602 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
603 elt.cellify (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
604 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
605 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
606 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
607 first_elem = true; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
608 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
609 for (tm_row_const& elt : *this) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
610 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
611 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
612 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
613 octave_idx_type this_elt_nr = elt.rows (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
614 octave_idx_type this_elt_nc = elt.cols (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
615 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
616 std::string this_elt_class_nm = elt.class_name (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
617 class_nm = get_concat_class (class_nm, this_elt_class_nm); |
1827 | 618 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
619 dim_vector this_elt_dv = elt.dims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
620 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
621 all_mt = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
622 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
623 if (first_elem) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
624 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
625 first_elem = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
626 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
627 dv = this_elt_dv; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
628 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
629 else if (all_str && dv.ndims () == 2 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
630 && this_elt_dv.ndims () == 2) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
631 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
632 // FIXME: this is Octave's specialty. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
633 // Character matrices allow rows of unequal length. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
634 if (this_elt_nc > cols ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
635 dv(1) = this_elt_nc; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
636 dv(0) += this_elt_nr; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
637 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
638 else if ((! any_class) && (! dv.hvcat (this_elt_dv, 0))) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
639 eval_error ("vertical dimensions mismatch", dv, this_elt_dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
640 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
641 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
642 ok = true; |
2990 | 643 } |
1741 | 644 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
645 octave_value_list |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
646 tree_matrix::rvalue (int nargout) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
647 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
648 if (nargout > 1) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
649 error ("invalid number of output arguments for matrix list"); |
1827 | 650 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
651 return rvalue1 (nargout); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
652 } |
1827 | 653 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
654 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
655 maybe_warn_string_concat (bool all_dq_strings_p, bool all_sq_strings_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
656 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
657 if (! (all_dq_strings_p || all_sq_strings_p)) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
658 warning_with_id ("Octave:mixed-string-concat", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
659 "concatenation of different character string types may have unintended consequences"); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
660 } |
5280 | 661 } |
662 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
663 template <typename TYPE, typename T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
664 static void |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
665 single_type_concat (Array<T>& result, octave::tm_const& tmp) |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
666 { |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
667 octave_idx_type r = 0; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
668 octave_idx_type c = 0; |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
669 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
670 for (octave::tm_row_const& row : tmp) |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
671 { |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
672 // Skip empty arrays to allow looser rules. |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
673 if (row.dims ().any_zero ()) |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
674 continue; |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
675 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
676 for (auto& elt : row) |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
677 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10116
diff
changeset
|
678 octave_quit (); |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
679 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
680 TYPE ra = octave_value_extract<TYPE> (elt); |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
681 |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
682 // Skip empty arrays to allow looser rules. |
5502 | 683 |
20558
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
684 if (! ra.is_empty ()) |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
685 { |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
686 result.insert (ra, r, c); |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
687 |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
688 c += ra.columns (); |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
689 } |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
690 } |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
691 |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
692 r += row.rows (); |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
693 c = 0; |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
694 } |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
695 } |
5533 | 696 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
697 template <typename TYPE, typename T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
698 static void |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
699 single_type_concat (Array<T>& result, const dim_vector& dv, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
700 octave::tm_const& tmp) |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
701 { |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
702 if (dv.any_zero ()) |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
703 { |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
704 result = Array<T> (dv); |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
705 return; |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
706 } |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
707 |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
708 if (tmp.length () == 1) |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
709 { |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
710 // If possible, forward the operation to liboctave. |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
711 // Single row. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
712 octave::tm_row_const& row = tmp.front (); |
10939
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
713 if (! (equal_types<T, char>::value || equal_types<T, octave_value>::value) |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
714 && row.all_1x1_p ()) |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
715 { |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
716 // Optimize all scalars case. |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
717 result.clear (dv); |
14592
b99cb1b0ee7c
Silence warning about signed comparsion
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14429
diff
changeset
|
718 assert (static_cast<size_t> (result.numel ()) == row.length ()); |
10939
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
719 octave_idx_type i = 0; |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
720 for (const auto& elt : row) |
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
721 result(i++) = octave_value_extract<T> (elt); |
10939
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
722 |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
723 return; |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
724 } |
c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
Jaroslav Hajek <highegg@gmail.com>
parents:
10937
diff
changeset
|
725 |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
726 octave_idx_type ncols = row.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
727 octave_idx_type i = 0; |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
728 OCTAVE_LOCAL_BUFFER (Array<T>, array_list, ncols); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
729 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
730 for (const auto& elt : row) |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
731 { |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
732 octave_quit (); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
733 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
734 array_list[i++] = octave_value_extract<TYPE> (elt); |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
735 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
736 |
20558
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
737 result = Array<T>::cat (-2, ncols, array_list); |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
738 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
739 else |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
740 { |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
741 result = Array<T> (dv); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
742 single_type_concat<TYPE> (result, tmp); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
743 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
744 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
745 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
746 template <typename TYPE, typename T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
747 static void |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
748 single_type_concat (Sparse<T>& result, const dim_vector& dv, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
749 octave::tm_const& tmp) |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
750 { |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
751 if (dv.any_zero ()) |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
752 { |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
753 result = Sparse<T> (dv); |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
754 return; |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
755 } |
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
756 |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
757 // Sparse matrices require preallocation for efficient indexing; besides, |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
758 // only horizontal concatenation can be efficiently handled by indexing. |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
759 // So we just cat all rows through liboctave, then cat the final column. |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
760 octave_idx_type nrows = tmp.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
761 octave_idx_type j = 0; |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
762 OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_row_list, nrows); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
763 for (octave::tm_row_const& row : tmp) |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
764 { |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
765 octave_idx_type ncols = row.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
766 octave_idx_type i = 0; |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
767 OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_list, ncols); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
768 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
769 for (auto& elt : row) |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
770 { |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
771 octave_quit (); |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
772 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
773 sparse_list[i] = octave_value_extract<TYPE> (elt); |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
774 i++; |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
775 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
776 |
10937
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
777 Sparse<T> stmp = Sparse<T>::cat (-2, ncols, sparse_list); |
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
778 sparse_row_list[j] = stmp; |
10715
53253f796351
make [] (hopefully) more Matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
10535
diff
changeset
|
779 j++; |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
780 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
781 |
10937
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
782 result = Sparse<T>::cat (-1, nrows, sparse_row_list); |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
783 } |
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
784 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
785 template <typename MAP> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
786 static void |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
787 single_type_concat (octave_map& result, const dim_vector& dv, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
788 octave::tm_const& tmp) |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
789 { |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
790 if (dv.any_zero ()) |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
791 { |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
792 result = octave_map (dv); |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
793 return; |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
794 } |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
795 |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
796 octave_idx_type nrows = tmp.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
797 octave_idx_type j = 0; |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
798 OCTAVE_LOCAL_BUFFER (octave_map, map_row_list, nrows); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
799 for (octave::tm_row_const& row : tmp) |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
800 { |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
801 octave_idx_type ncols = row.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
802 octave_idx_type i = 0; |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
803 OCTAVE_LOCAL_BUFFER (MAP, map_list, ncols); |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
804 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
805 for (auto& elt : row) |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
806 { |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
807 octave_quit (); |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
808 |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
809 map_list[i] = octave_value_extract<MAP> (elt); |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
810 i++; |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
811 } |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
812 |
10937
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
813 octave_map mtmp = octave_map::cat (-2, ncols, map_list); |
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
814 map_row_list[j] = mtmp; |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
815 j++; |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
816 } |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
817 |
10937
f42e8c6196c3
tweaks in concatenation of empty structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
818 result = octave_map::cat (-1, nrows, map_row_list); |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
819 } |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
820 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
821 template <typename TYPE> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
822 static octave_value |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
823 do_single_type_concat (const dim_vector& dv, octave::tm_const& tmp) |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
824 { |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
825 TYPE result; |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
826 |
10535
3f973f6c841c
improve sparse concatenation operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
827 single_type_concat<TYPE> (result, dv, tmp); |
10116
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
828 |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
829 return result; |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
830 } |
fecebef27388
improve concatenation code using templates instead of macros
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
831 |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21100
diff
changeset
|
832 template <> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
833 octave_value |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
834 do_single_type_concat<octave_map> (const dim_vector& dv, octave::tm_const& tmp) |
10764
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
835 { |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
836 octave_map result; |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
837 |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
838 if (tmp.all_1x1_p ()) |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
839 single_type_concat<octave_scalar_map> (result, dv, tmp); |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
840 else |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
841 single_type_concat<octave_map> (result, dv, tmp); |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
842 |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
843 return result; |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
844 } |
e141bcb1befd
implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents:
10758
diff
changeset
|
845 |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
846 static octave_value |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
847 do_class_concat (octave::tm_const& tmc) |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
848 { |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
849 octave_value retval; |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
850 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
851 octave_value_list rows (tmc.length (), octave_value ()); |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
852 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
853 octave_idx_type j = 0; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
854 for (octave::tm_row_const& tmrc : tmc) |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
855 { |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
856 octave_quit (); |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
857 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
858 if (tmrc.length () == 1) |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
859 rows(j++) = *(tmrc.begin ()); |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
860 else |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
861 { |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
862 octave_value_list row (tmrc.length (), octave_value ()); |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
863 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
864 octave_idx_type i = 0; |
22872
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
865 for (auto& elt : tmrc) |
551ac93c984c
maint: Use C++ range feature to simplify some for loops in libinterp/parse-tree
Rik <rik@octave.org>
parents:
22868
diff
changeset
|
866 row(i++) = elt; |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
867 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
868 rows(j++) = do_class_concat (row, "horzcat", 1); |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
869 } |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
870 } |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
871 |
20558
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
872 if (rows.length () == 1) |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
873 retval = rows(0); |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
874 else |
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
875 retval = do_class_concat (rows, "vertcat", 0); |
13294
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
876 |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
877 return retval; |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
878 } |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13219
diff
changeset
|
879 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
880 namespace octave |
1741 | 881 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
882 octave_value |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
883 tree_matrix::rvalue1 (int) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
884 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
885 octave_value retval = Matrix (); |
1741 | 886 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
887 bool all_strings_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
888 bool all_sq_strings_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
889 bool all_dq_strings_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
890 bool all_empty_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
891 bool all_real_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
892 bool any_sparse_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
893 bool any_class_p = false; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
894 bool frc_str_conv = false; |
3110 | 895 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
896 tm_const tmp (*this); |
1741 | 897 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
898 if (tmp && ! tmp.empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
899 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
900 dim_vector dv = tmp.dims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
901 all_strings_p = tmp.all_strings_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
902 all_sq_strings_p = tmp.all_sq_strings_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
903 all_dq_strings_p = tmp.all_dq_strings_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
904 all_empty_p = tmp.all_empty_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
905 all_real_p = tmp.all_real_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
906 any_sparse_p = tmp.any_sparse_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
907 any_class_p = tmp.any_class_p (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
908 frc_str_conv = tmp.some_strings_p (); |
4915 | 909 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
910 // Try to speed up the common cases. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
911 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
912 std::string result_type = tmp.class_name (); |
5533 | 913 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
914 if (any_class_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
915 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
916 retval = do_class_concat (tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
917 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
918 else if (result_type == "double") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
919 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
920 if (any_sparse_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
921 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
922 if (all_real_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
923 retval = do_single_type_concat<SparseMatrix> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
924 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
925 retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
926 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
927 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
928 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
929 if (all_real_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
930 retval = do_single_type_concat<NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
931 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
932 retval = do_single_type_concat<ComplexNDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
933 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
934 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
935 else if (result_type == "single") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
936 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
937 if (all_real_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
938 retval = do_single_type_concat<FloatNDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
939 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
940 retval = do_single_type_concat<FloatComplexNDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
941 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
942 else if (result_type == "char") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
943 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
944 char type = all_dq_strings_p ? '"' : '\''; |
5280 | 945 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
946 if (! all_strings_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
947 warn_implicit_conversion ("Octave:num-to-str", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
948 "numeric", result_type); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
949 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
950 maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p); |
5280 | 951 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
952 charNDArray result (dv, Vstring_fill_char); |
5502 | 953 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
954 single_type_concat<charNDArray> (result, tmp); |
5502 | 955 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
956 retval = octave_value (result, type); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
957 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
958 else if (result_type == "logical") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
959 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
960 if (any_sparse_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
961 retval = do_single_type_concat<SparseBoolMatrix> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
962 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
963 retval = do_single_type_concat<boolNDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
964 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
965 else if (result_type == "int8") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
966 retval = do_single_type_concat<int8NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
967 else if (result_type == "int16") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
968 retval = do_single_type_concat<int16NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
969 else if (result_type == "int32") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
970 retval = do_single_type_concat<int32NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
971 else if (result_type == "int64") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
972 retval = do_single_type_concat<int64NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
973 else if (result_type == "uint8") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
974 retval = do_single_type_concat<uint8NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
975 else if (result_type == "uint16") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
976 retval = do_single_type_concat<uint16NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
977 else if (result_type == "uint32") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
978 retval = do_single_type_concat<uint32NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
979 else if (result_type == "uint64") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
980 retval = do_single_type_concat<uint64NDArray> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
981 else if (result_type == "cell") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
982 retval = do_single_type_concat<Cell> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
983 else if (result_type == "struct") |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
984 retval = do_single_type_concat<octave_map> (dv, tmp); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
985 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
986 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
987 // The line below might seem crazy, since we take a copy of |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
988 // the first argument, resize it to be empty and then resize |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
989 // it to be full. This is done since it means that there is |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
990 // no recopying of data, as would happen if we used a single |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
991 // resize. It should be noted that resize operation is also |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
992 // significantly slower than the do_cat_op function, so it |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
993 // makes sense to have an empty matrix and copy all data. |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
994 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
995 // We might also start with a empty octave_value using |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
996 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
997 // ctmp = octave_value_typeinfo::lookup_type |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
998 // (tmp.begin() -> begin() -> type_name()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
999 // |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1000 // and then directly resize. However, for some types there |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1001 // might be some additional setup needed, and so this should |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1002 // be avoided. |
5502 | 1003 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1004 octave_value ctmp; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1005 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1006 // Find the first non-empty object |
5502 | 1007 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1008 if (any_sparse_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1009 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1010 // Start with sparse matrix to avoid issues memory issues |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1011 // with things like [ones(1,4),sprandn(1e8,4,1e-4)] |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1012 if (all_real_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1013 ctmp = octave_sparse_matrix ().resize (dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1014 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1015 ctmp = octave_sparse_complex_matrix ().resize (dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1016 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1017 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1018 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1019 for (tm_row_const& row : tmp) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1020 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1021 octave_quit (); |
5502 | 1022 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1023 for (auto& elt : row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1024 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1025 octave_quit (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1026 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1027 ctmp = elt; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1028 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1029 if (! ctmp.all_zero_dims ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1030 goto found_non_empty; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1031 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1032 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1033 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1034 ctmp = (*(tmp.begin () -> begin ())); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1035 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1036 found_non_empty: |
5502 | 1037 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1038 if (! all_empty_p) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1039 ctmp = ctmp.resize (dim_vector (0,0)).resize (dv); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1040 } |
5630 | 1041 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1042 // Now, extract the values from the individual elements and |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1043 // insert them in the result matrix. |
5164 | 1044 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1045 int dv_len = dv.ndims (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1046 octave_idx_type ntmp = dv_len > 1 ? dv_len : 2; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1047 Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0); |
5164 | 1048 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1049 for (tm_row_const& row : tmp) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1050 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1051 octave_quit (); |
5502 | 1052 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1053 for (auto& elt : row) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1054 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1055 octave_quit (); |
4915 | 1056 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1057 if (elt.is_empty ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1058 continue; |
20558
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1059 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1060 ctmp = do_cat_op (ctmp, elt, ra_idx); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1061 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1062 ra_idx (1) += elt.columns (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1063 } |
5502 | 1064 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1065 ra_idx (0) += row.rows (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1066 ra_idx (1) = 0; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1067 } |
5502 | 1068 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1069 retval = ctmp; |
5502 | 1070 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1071 if (frc_str_conv && ! retval.is_string ()) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1072 retval = retval.convert_to_str (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1073 } |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1074 } |
5502 | 1075 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1076 return retval; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1077 } |
5502 | 1078 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1079 tree_expression * |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1080 tree_matrix::dup (symbol_table::scope_id scope, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1081 symbol_table::context_id context) const |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1082 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1083 tree_matrix *new_matrix = new tree_matrix (0, line (), column ()); |
5502 | 1084 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1085 new_matrix->copy_base (*this, scope, context); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1086 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1087 return new_matrix; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1088 } |
20558
1a0a433c8263
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20428
diff
changeset
|
1089 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1090 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1091 tree_matrix::accept (tree_walker& tw) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1092 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1093 tw.visit_matrix (*this); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23012
diff
changeset
|
1094 } |
1741 | 1095 } |
1096 | |
1097 | |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
12864
diff
changeset
|
1098 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1099 ## test concatenation with all zero matrices |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
1100 %!assert ([ "" 65*ones(1,10) ], "AAAAAAAAAA") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
1101 %!assert ([ 65*ones(1,10) "" ], "AAAAAAAAAA") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1102 |
13144
c99f24c10ca3
fix vertical concatenation involving cell arrays
John W. Eaton <jwe@octave.org>
parents:
13142
diff
changeset
|
1103 %!test |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1104 %! c = {"foo"; "bar"; "bazoloa"}; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1105 %! assert ([c; "a"; "bc"; "def"], {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"}); |
13144
c99f24c10ca3
fix vertical concatenation involving cell arrays
John W. Eaton <jwe@octave.org>
parents:
13142
diff
changeset
|
1106 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1107 %!assert (class ([int64(1), int64(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1108 %!assert (class ([int64(1), int32(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1109 %!assert (class ([int64(1), int16(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1110 %!assert (class ([int64(1), int8(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1111 %!assert (class ([int64(1), uint64(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1112 %!assert (class ([int64(1), uint32(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1113 %!assert (class ([int64(1), uint16(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1114 %!assert (class ([int64(1), uint8(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1115 %!assert (class ([int64(1), single(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1116 %!assert (class ([int64(1), double(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1117 %!assert (class ([int64(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1118 %!assert (class ([int64(1), true]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1119 %!assert (class ([int64(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1120 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1121 %!assert (class ([int32(1), int64(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1122 %!assert (class ([int32(1), int32(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1123 %!assert (class ([int32(1), int16(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1124 %!assert (class ([int32(1), int8(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1125 %!assert (class ([int32(1), uint64(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1126 %!assert (class ([int32(1), uint32(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1127 %!assert (class ([int32(1), uint16(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1128 %!assert (class ([int32(1), uint8(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1129 %!assert (class ([int32(1), single(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1130 %!assert (class ([int32(1), double(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1131 %!assert (class ([int32(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1132 %!assert (class ([int32(1), true]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1133 %!assert (class ([int32(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1134 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1135 %!assert (class ([int16(1), int64(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1136 %!assert (class ([int16(1), int32(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1137 %!assert (class ([int16(1), int16(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1138 %!assert (class ([int16(1), int8(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1139 %!assert (class ([int16(1), uint64(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1140 %!assert (class ([int16(1), uint32(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1141 %!assert (class ([int16(1), uint16(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1142 %!assert (class ([int16(1), uint8(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1143 %!assert (class ([int16(1), single(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1144 %!assert (class ([int16(1), double(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1145 %!assert (class ([int16(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1146 %!assert (class ([int16(1), true]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1147 %!assert (class ([int16(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1148 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1149 %!assert (class ([int8(1), int64(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1150 %!assert (class ([int8(1), int32(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1151 %!assert (class ([int8(1), int16(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1152 %!assert (class ([int8(1), int8(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1153 %!assert (class ([int8(1), uint64(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1154 %!assert (class ([int8(1), uint32(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1155 %!assert (class ([int8(1), uint16(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1156 %!assert (class ([int8(1), uint8(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1157 %!assert (class ([int8(1), single(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1158 %!assert (class ([int8(1), double(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1159 %!assert (class ([int8(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1160 %!assert (class ([int8(1), true]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1161 %!assert (class ([int8(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1162 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1163 %!assert (class ([uint64(1), int64(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1164 %!assert (class ([uint64(1), int32(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1165 %!assert (class ([uint64(1), int16(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1166 %!assert (class ([uint64(1), int8(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1167 %!assert (class ([uint64(1), uint64(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1168 %!assert (class ([uint64(1), uint32(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1169 %!assert (class ([uint64(1), uint16(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1170 %!assert (class ([uint64(1), uint8(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1171 %!assert (class ([uint64(1), single(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1172 %!assert (class ([uint64(1), double(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1173 %!assert (class ([uint64(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1174 %!assert (class ([uint64(1), true]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1175 %!assert (class ([uint64(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1176 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1177 %!assert (class ([uint32(1), int64(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1178 %!assert (class ([uint32(1), int32(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1179 %!assert (class ([uint32(1), int16(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1180 %!assert (class ([uint32(1), int8(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1181 %!assert (class ([uint32(1), uint64(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1182 %!assert (class ([uint32(1), uint32(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1183 %!assert (class ([uint32(1), uint16(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1184 %!assert (class ([uint32(1), uint8(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1185 %!assert (class ([uint32(1), single(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1186 %!assert (class ([uint32(1), double(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1187 %!assert (class ([uint32(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1188 %!assert (class ([uint32(1), true]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1189 %!assert (class ([uint32(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1190 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1191 %!assert (class ([uint16(1), int64(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1192 %!assert (class ([uint16(1), int32(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1193 %!assert (class ([uint16(1), int16(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1194 %!assert (class ([uint16(1), int8(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1195 %!assert (class ([uint16(1), uint64(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1196 %!assert (class ([uint16(1), uint32(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1197 %!assert (class ([uint16(1), uint16(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1198 %!assert (class ([uint16(1), uint8(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1199 %!assert (class ([uint16(1), single(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1200 %!assert (class ([uint16(1), double(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1201 %!assert (class ([uint16(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1202 %!assert (class ([uint16(1), true]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1203 %!assert (class ([uint16(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1204 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1205 %!assert (class ([uint8(1), int64(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1206 %!assert (class ([uint8(1), int32(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1207 %!assert (class ([uint8(1), int16(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1208 %!assert (class ([uint8(1), int8(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1209 %!assert (class ([uint8(1), uint64(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1210 %!assert (class ([uint8(1), uint32(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1211 %!assert (class ([uint8(1), uint16(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1212 %!assert (class ([uint8(1), uint8(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1213 %!assert (class ([uint8(1), single(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1214 %!assert (class ([uint8(1), double(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1215 %!assert (class ([uint8(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1216 %!assert (class ([uint8(1), true]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1217 %!assert (class ([uint8(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1218 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1219 %!assert (class ([single(1), int64(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1220 %!assert (class ([single(1), int32(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1221 %!assert (class ([single(1), int16(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1222 %!assert (class ([single(1), int8(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1223 %!assert (class ([single(1), uint64(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1224 %!assert (class ([single(1), uint32(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1225 %!assert (class ([single(1), uint16(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1226 %!assert (class ([single(1), uint8(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1227 %!assert (class ([single(1), single(1)]), "single") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1228 %!assert (class ([single(1), double(1)]), "single") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1229 %!assert (class ([single(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1230 %!assert (class ([single(1), true]), "single") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1231 %!assert (class ([single(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1232 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1233 %!assert (class ([double(1), int64(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1234 %!assert (class ([double(1), int32(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1235 %!assert (class ([double(1), int16(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1236 %!assert (class ([double(1), int8(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1237 %!assert (class ([double(1), uint64(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1238 %!assert (class ([double(1), uint32(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1239 %!assert (class ([double(1), uint16(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1240 %!assert (class ([double(1), uint8(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1241 %!assert (class ([double(1), single(1)]), "single") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1242 %!assert (class ([double(1), double(1)]), "double") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1243 %!assert (class ([double(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1244 %!assert (class ([double(1), true]), "double") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1245 %!assert (class ([double(1), "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1246 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1247 %!assert (class ([cell(1), int64(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1248 %!assert (class ([cell(1), int32(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1249 %!assert (class ([cell(1), int16(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1250 %!assert (class ([cell(1), int8(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1251 %!assert (class ([cell(1), uint64(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1252 %!assert (class ([cell(1), uint32(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1253 %!assert (class ([cell(1), uint16(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1254 %!assert (class ([cell(1), uint8(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1255 %!assert (class ([cell(1), single(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1256 %!assert (class ([cell(1), double(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1257 %!assert (class ([cell(1), cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1258 %!assert (class ([cell(1), true]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1259 %!assert (class ([cell(1), "a"]), "cell") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1260 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1261 %!assert (class ([true, int64(1)]), "int64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1262 %!assert (class ([true, int32(1)]), "int32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1263 %!assert (class ([true, int16(1)]), "int16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1264 %!assert (class ([true, int8(1)]), "int8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1265 %!assert (class ([true, uint64(1)]), "uint64") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1266 %!assert (class ([true, uint32(1)]), "uint32") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1267 %!assert (class ([true, uint16(1)]), "uint16") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1268 %!assert (class ([true, uint8(1)]), "uint8") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1269 %!assert (class ([true, single(1)]), "single") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1270 %!assert (class ([true, double(1)]), "double") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1271 %!assert (class ([true, cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1272 %!assert (class ([true, true]), "logical") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1273 %!assert (class ([true, "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1274 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1275 %!assert (class (["a", int64(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1276 %!assert (class (["a", int32(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1277 %!assert (class (["a", int16(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1278 %!assert (class (["a", int8(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1279 %!assert (class (["a", int64(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1280 %!assert (class (["a", int32(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1281 %!assert (class (["a", int16(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1282 %!assert (class (["a", int8(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1283 %!assert (class (["a", single(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1284 %!assert (class (["a", double(1)]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1285 %!assert (class (["a", cell(1)]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1286 %!assert (class (["a", true]), "char") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1287 %!assert (class (["a", "a"]), "char") |
13142
d803d2702a39
improve compatibility of concatenation (bug #33966)
John W. Eaton <jwe@octave.org>
parents:
13140
diff
changeset
|
1288 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1289 %!assert (class ([cell(1), struct("foo", "bar")]), "cell") |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1290 %!error [struct("foo", "bar"), cell(1)] |
16924
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1291 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1292 %!assert ([,1], 1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1293 %!assert ([1,], 1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1294 %!assert ([,1,], 1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1295 %!assert ([,1,;;], 1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1296 %!assert ([,1,;,;], 1) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1297 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1298 %!assert ([1,1], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1299 %!assert ([,1,1], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1300 %!assert ([1,1,], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1301 %!assert ([,1,1,], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1302 %!assert ([,1,1,;;], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1303 %!assert ([,1,1,;,;], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1304 %!assert ([,;,1,1], ones (1, 2)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1305 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1306 %!assert ([1;1], ones (2, 1)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1307 %!assert ([1,;1], ones (2, 1)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1308 %!assert ([1,;,;1], ones (2, 1)) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1309 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1310 %!error eval ("[,,]") |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1311 %!error eval ("[,,;,]") |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1312 %!error eval ("[,;,,;,]") |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1313 |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1314 %!assert (isnull ([,])) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1315 %!assert (isnull ([;])) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1316 %!assert (isnull ([;;])) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1317 %!assert (isnull ([;,;])) |
aebb54d99dba
improve compatibility of parsing of matrices and cell arrays
John W. Eaton <jwe@octave.org>
parents:
16237
diff
changeset
|
1318 %!assert (isnull ([,;,;,])) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
12864
diff
changeset
|
1319 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
12864
diff
changeset
|
1320 |
5794 | 1321 DEFUN (string_fill_char, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1322 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1323 @deftypefn {} {@var{val} =} string_fill_char () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1324 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1325 @deftypefnx {} {} string_fill_char (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1326 Query or set the internal variable used to pad all rows of a character |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1327 matrix to the same length. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1328 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1329 The value must be a single character and the default is @qcode{" "} (a |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1330 single space). For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1331 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1332 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1333 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1334 string_fill_char ("X"); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1335 [ "these"; "are"; "strings" ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1336 @result{} "theseXX" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1337 "areXXXX" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1338 "strings" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1339 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1340 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1341 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1342 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1343 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1344 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1345 @end deftypefn */) |
5794 | 1346 { |
1347 return SET_INTERNAL_VARIABLE (string_fill_char); | |
2172 | 1348 } |
12842
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1349 |
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1350 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1351 ## string_fill_char() function call must be outside of %!test block |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1352 ## due to the way a %!test block is wrapped inside a function |
12864
213c791292a6
test: Add 3 tests for string_fill_char()
Rik <octave@nomad.inbox5.com>
parents:
12842
diff
changeset
|
1353 %!shared orig_val, old_val |
12842
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1354 %! orig_val = string_fill_char (); |
12864
213c791292a6
test: Add 3 tests for string_fill_char()
Rik <octave@nomad.inbox5.com>
parents:
12842
diff
changeset
|
1355 %! old_val = string_fill_char ("X"); |
213c791292a6
test: Add 3 tests for string_fill_char()
Rik <octave@nomad.inbox5.com>
parents:
12842
diff
changeset
|
1356 %!test |
12842
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1357 %! assert (orig_val, old_val); |
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1358 %! assert (string_fill_char (), "X"); |
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1359 %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]); |
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1360 %! string_fill_char (orig_val); |
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1361 %! assert (string_fill_char (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1362 |
21261
f982cfe3df03
When concatenating cells, suppress empty matrices (bug #43511).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1363 %!assert ( [ [], {1} ], {1} ) |
f982cfe3df03
When concatenating cells, suppress empty matrices (bug #43511).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1364 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14402
diff
changeset
|
1365 %!error (string_fill_char (1, 2)) |
12842
a52b4e9f45e3
codesprint: new tests for pt-mat.cc
John W. Eaton <jwe@octave.org>
parents:
12483
diff
changeset
|
1366 */ |