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