Mercurial > octave
annotate libinterp/parse-tree/pt-tm-const.cc @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | 70cdf8de553d 0a5b15007766 |
children | aef11bb4e6d1 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
28579
diff
changeset
|
3 // Copyright (C) 1996-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include "oct-locbuf.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "quit.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "data.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "defun.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "error.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "errwarn.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "oct-map.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ovl.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "pt-arg-list.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "pt-bp.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "pt-eval.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "pt-exp.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "pt-mat.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "pt-tm-const.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "utils.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "ov.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "variables.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "ov-cx-mat.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "ov-flt-cx-mat.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 #include "ov-re-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 #include "ov-cx-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 OCTAVE_NORETURN static |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 eval_error (const char *msg, const dim_vector& x, const dim_vector& y) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 namespace octave |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
63 void tm_row_const::cellify (void) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
65 bool elt_changed = false; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
66 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
67 for (auto& elt : m_values) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
68 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
69 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
70 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
71 if (! elt.iscell ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
72 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
73 elt_changed = true; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
74 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
75 if (elt.isempty ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
76 elt = Cell (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
77 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
78 elt = Cell (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
79 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
80 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
81 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
82 if (! elt_changed) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
83 return; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
84 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
85 bool first_elem = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
87 for (const auto& val : m_values) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
88 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
89 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
90 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
91 dim_vector this_elt_dv = val.dims (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
92 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
93 if (! this_elt_dv.zero_by_zero ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
94 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
95 if (first_elem) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
96 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
97 first_elem = false; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
98 m_dv = this_elt_dv; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
99 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
100 else if (! m_dv.hvcat (this_elt_dv, 1)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
101 eval_error ("horizontal dimensions mismatch", m_dv, this_elt_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
102 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
103 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
104 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
105 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
106 void tm_row_const::init_element (const octave_value& val, bool& first_elem) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
107 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
108 std::string this_elt_class_name |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
109 = val.isobject () ? "class" : val.class_name (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
110 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
111 m_class_name = get_concat_class (m_class_name, this_elt_class_name); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 dim_vector this_elt_dv = val.dims (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 if (! this_elt_dv.zero_by_zero ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
117 m_all_empty = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 if (first_elem) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 { |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23583
diff
changeset
|
121 if (val.isstruct ()) |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 m_first_elem_is_struct = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 first_elem = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 } |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23515
diff
changeset
|
127 else if (val.iscell ()) |
23515
4d7928872999
Fix concatenation of a struct with an empty cell array (bug #39041)
Mike Miller <mtmiller@octave.org>
parents:
23435
diff
changeset
|
128 first_elem = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
130 m_values.push_back (val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
132 if (m_all_strings && ! val.is_string ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
133 m_all_strings = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
135 if (m_all_sq_strings && ! val.is_sq_string ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
136 m_all_sq_strings = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
138 if (m_all_dq_strings && ! val.is_dq_string ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
139 m_all_dq_strings = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
141 if (! m_some_strings && val.is_string ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
142 m_some_strings = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 if (m_all_real && ! val.isreal ()) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 m_all_real = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
147 if (m_all_complex && ! (val.iscomplex () || val.isreal ())) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
148 m_all_complex = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 if (! m_any_cell && val.iscell ()) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 m_any_cell = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 if (! m_any_sparse && val.issparse ()) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 m_any_sparse = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 if (! m_any_class && val.isobject ()) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 m_any_class = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 // Special treatment of sparse matrices to avoid out-of-memory error |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 m_all_1x1 = m_all_1x1 && ! val.issparse () && val.numel () == 1; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
163 void tm_row_const::init (const tree_argument_list& row, tree_evaluator& tw) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 bool first_elem = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
167 for (auto *elt : row) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
171 octave_value tmp = elt->evaluate (tw); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 if (tmp.is_undefined ()) |
28547
66397e171801
error on undefined elements in matrix lists (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
28542
diff
changeset
|
174 error ("undefined element in matrix list"); |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
175 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
176 if (tmp.is_cs_list ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
178 octave_value_list tlst = tmp.list_value (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
179 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
180 for (octave_idx_type i = 0; i < tlst.length (); i++) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
181 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
182 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
183 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
184 init_element (tlst(i), first_elem); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
185 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 else |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
188 init_element (tmp, first_elem); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 if (m_any_cell && ! m_any_class && ! m_first_elem_is_struct) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 cellify (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 first_elem = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
196 for (const auto& val : m_values) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 dim_vector this_elt_dv = val.dims (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 if (! this_elt_dv.zero_by_zero ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
204 m_all_empty = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 if (first_elem) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 first_elem = false; |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
209 m_dv = this_elt_dv; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 } |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
211 else if ((! m_any_class) && (! m_dv.hvcat (this_elt_dv, 1))) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
212 eval_error ("horizontal dimensions mismatch", m_dv, this_elt_dv); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
217 octave_value tm_const::concat (char string_fill_char) const |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
219 if (m_tm_rows.empty ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
220 return Matrix (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
222 // Try to speed up the common cases. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
223 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
224 std::string result_type = m_class_name; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
226 if (m_any_class) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
227 return class_concat (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
228 else if (result_type == "double") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
229 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
230 if (m_any_sparse) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
232 if (m_all_real) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
233 return sparse_array_concat<SparseMatrix> (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 else |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
235 return sparse_array_concat<SparseComplexMatrix> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
236 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
237 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
238 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
239 if (m_all_real) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
240 return array_concat<NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
241 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
242 return array_concat<ComplexNDArray> (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 } |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
245 else if (result_type == "single") |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
247 if (m_all_real) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
248 return array_concat<FloatNDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
249 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
250 return array_concat<FloatComplexNDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
251 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
252 else if (result_type == "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
253 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
254 if (! m_all_strings) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
255 warn_implicit_conversion ("Octave:num-to-str", |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
256 "numeric", result_type); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
257 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
258 maybe_warn_string_concat (m_all_dq_strings, m_all_sq_strings); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
260 return char_array_concat (string_fill_char); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
261 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
262 else if (result_type == "logical") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
263 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
264 if (m_any_sparse) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
265 return sparse_array_concat<SparseBoolMatrix> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
266 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
267 return array_concat<boolNDArray> (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 } |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
269 else if (result_type == "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
270 return array_concat<int8NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
271 else if (result_type == "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
272 return array_concat<int16NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
273 else if (result_type == "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
274 return array_concat<int32NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
275 else if (result_type == "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
276 return array_concat<int64NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
277 else if (result_type == "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
278 return array_concat<uint8NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
279 else if (result_type == "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
280 return array_concat<uint16NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
281 else if (result_type == "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
282 return array_concat<uint32NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
283 else if (result_type == "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
284 return array_concat<uint64NDArray> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
285 else if (result_type == "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
286 return array_concat<Cell> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
287 else if (result_type == "struct") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
288 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
289 if (m_all_1x1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
290 return map_concat<octave_scalar_map> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
291 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
292 return map_concat<octave_map> (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
293 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
294 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
295 return generic_concat (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
298 void tm_const::init (const tree_matrix& tm) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 bool first_elem = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 bool first_elem_is_struct = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 // Just eval and figure out if what we have is complex or all strings. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 // We can't check columns until we know that this is a numeric matrix -- |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 // collections of strings can have elements of different lengths. |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
306 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
307 for (const auto *elt : tm) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
311 tm_row_const row (*elt, m_evaluator); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 if (first_elem) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
315 first_elem_is_struct = row.first_elem_struct_p (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 first_elem = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
320 if (row.empty ()) |
28542
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
321 continue; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
323 if (m_all_strings && ! row.all_strings_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
324 m_all_strings = false; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
325 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
326 if (m_all_sq_strings && ! row.all_sq_strings_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
327 m_all_sq_strings = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
329 if (m_all_dq_strings && ! row.all_dq_strings_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
330 m_all_dq_strings = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
332 if (! m_some_strings && row.some_strings_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
333 m_some_strings = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
334 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
335 if (m_all_real && ! row.all_real_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
336 m_all_real = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
338 if (m_all_complex && ! row.all_complex_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
339 m_all_complex = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
341 if (m_all_empty && ! row.all_empty_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
342 m_all_empty = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
344 if (! m_any_cell && row.any_cell_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
345 m_any_cell = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
347 if (! m_any_sparse && row.any_sparse_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
348 m_any_sparse = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
350 if (! m_any_class && row.any_class_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
351 m_any_class = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
353 m_all_1x1 = m_all_1x1 && row.all_1x1_p (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
354 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
355 m_tm_rows.push_back (row); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
356 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
357 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
358 if (m_any_cell && ! m_any_class && ! first_elem_is_struct) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
360 for (auto& elt : m_tm_rows) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
361 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
363 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 elt.cellify (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 first_elem = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
370 for (const auto& elt : m_tm_rows) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 octave_idx_type this_elt_nr = elt.rows (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 octave_idx_type this_elt_nc = elt.cols (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
377 std::string this_elt_class_name = elt.class_name (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
378 m_class_name = get_concat_class (m_class_name, this_elt_class_name); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 dim_vector this_elt_dv = elt.dims (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
382 m_all_empty = false; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 if (first_elem) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 first_elem = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
388 m_dv = this_elt_dv; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 } |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
390 else if (m_all_strings && m_dv.ndims () == 2 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 && this_elt_dv.ndims () == 2) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 { |
24339 | 393 // This is Octave's specialty. |
394 // Character matrices support rows of unequal length. | |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
395 if (m_dv.any_zero ()) |
24339 | 396 { |
397 // Empty existing element (bug #52542). | |
398 // Replace empty element with non-empty one. | |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
399 m_dv = this_elt_dv; |
24339 | 400 } |
401 else | |
402 { | |
403 if (this_elt_nc > cols ()) | |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
404 m_dv(1) = this_elt_nc; |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
405 m_dv(0) += this_elt_nr; |
24339 | 406 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 } |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
408 else if ((! m_any_class) && (! m_dv.hvcat (this_elt_dv, 0))) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
409 eval_error ("vertical dimensions mismatch", m_dv, this_elt_dv); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
413 octave_value tm_const::char_array_concat (char string_fill_char) const |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
414 { |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
415 char type = (m_all_dq_strings ? '"' : '\''); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
417 charNDArray result (m_dv, string_fill_char); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
419 array_concat_internal<charNDArray> (result); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
420 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
421 return octave_value (result, type); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
424 octave_value tm_const::class_concat (void) const |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 octave_value retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
428 octave_value_list rows (m_tm_rows.size (), octave_value ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 octave_idx_type j = 0; |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
431 for (const auto& tmrc : m_tm_rows) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 octave_quit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 if (tmrc.length () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 rows(j++) = *(tmrc.begin ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
437 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 octave_value_list row (tmrc.length (), octave_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 octave_idx_type i = 0; |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
442 for (const auto& elt : tmrc) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 row(i++) = elt; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
445 rows(j++) = ::do_class_concat (row, "horzcat", 1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 if (rows.length () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 retval = rows(0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 else |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
452 retval = ::do_class_concat (rows, "vertcat", 0); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
453 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
454 return retval; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
455 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
456 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
457 octave_value tm_const::generic_concat (void) const |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
458 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
459 // The line below might seem crazy, since we take a copy of the |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
460 // first argument, resize it to be empty and then resize it to be |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
461 // full. This is done since it means that there is no recopying of |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
462 // data, as would happen if we used a single resize. It should be |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
463 // noted that resize operation is also significantly slower than the |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28579
diff
changeset
|
464 // cat_op function, so it makes sense to have an empty matrix and |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
465 // copy all data. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
466 // |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
467 // We might also start with a empty octave_value using |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
468 // |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
469 // ctmp = type_info::lookup_type (tmp.begin() -> begin() -> type_name()); |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
470 // |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
471 // and then directly resize. However, for some types there might be |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
472 // some additional setup needed, and so this should be avoided. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
473 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
474 octave_value ctmp; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
475 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
476 // Find the first non-empty object |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
477 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
478 if (m_any_sparse) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
479 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
480 // Start with sparse matrix to avoid issues memory issues with |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
481 // things like [ones(1,4),sprandn(1e8,4,1e-4)] |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
482 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
483 if (m_all_real) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
484 ctmp = octave_sparse_matrix ().resize (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
485 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
486 ctmp = octave_sparse_complex_matrix ().resize (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
487 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
488 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
489 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
490 for (const auto& row : m_tm_rows) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
491 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
492 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
493 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
494 for (const auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
495 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
496 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
497 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
498 ctmp = elt; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
499 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
500 if (! ctmp.all_zero_dims ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
501 goto found_non_empty; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
502 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
503 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
504 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
505 ctmp = (*(m_tm_rows.begin () -> begin ())); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
506 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
507 found_non_empty: |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
508 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
509 if (! m_all_empty) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
510 ctmp = ctmp.resize (dim_vector (0,0)).resize (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
511 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
512 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
513 // Now, extract the values from the individual elements and insert |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
514 // them in the result matrix. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
515 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
516 interpreter& interp = m_evaluator.get_interpreter (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
517 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
518 type_info& ti = interp.get_type_info (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
519 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
520 int dv_len = m_dv.ndims (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
521 octave_idx_type ntmp = (dv_len > 1 ? dv_len : 2); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
522 Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
523 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
524 for (const auto& row : m_tm_rows) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
525 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
526 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
527 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
528 for (const auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
529 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
530 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
531 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
532 if (elt.isempty ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
533 continue; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
534 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28579
diff
changeset
|
535 ctmp = cat_op (ti, ctmp, elt, ra_idx); |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
536 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
537 ra_idx (1) += elt.columns (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
538 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
539 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
540 ra_idx (0) += row.rows (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
541 ra_idx (1) = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
542 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
543 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
544 octave_value retval = ctmp; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
545 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
546 // If some elements are strings, force the result to be a string. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
547 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
548 if (m_some_strings && ! retval.is_string ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
549 retval = retval.convert_to_str (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 } |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
553 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
554 // The result is passed as a parameter to this function so that the |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
555 // char_array_concat function can create the array externally. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
556 // Otherwise, we would need a specialization of this function for |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
557 // character arrays just to handle string_fill_char. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
558 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
559 template <typename TYPE> |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
560 void tm_const::array_concat_internal (TYPE& result) const |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
561 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
562 octave_idx_type r = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
563 octave_idx_type c = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
564 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
565 for (const auto& row : m_tm_rows) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
566 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
567 // Skip empty arrays to allow looser rules. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
568 if (row.dims ().any_zero ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
569 continue; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
570 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
571 for (const auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
572 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
573 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
574 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
575 TYPE ra = octave_value_extract<TYPE> (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
576 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
577 // Skip empty arrays to allow looser rules. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
578 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
579 if (! ra.isempty ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
580 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
581 result.insert (ra, r, c); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
582 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
583 c += ra.columns (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
584 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
585 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
586 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
587 r += row.rows (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
588 c = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
589 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
590 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
591 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
592 template <typename TYPE> |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
593 TYPE tm_const::array_concat (void) const |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
594 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
595 typedef typename TYPE::element_type ELT_T; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
596 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
597 if (m_dv.any_zero ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
598 return TYPE (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
599 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
600 if (m_tm_rows.size () == 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
601 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
602 // If possible, forward the operation to liboctave. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
603 // Single row. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
604 const tm_row_const& row = m_tm_rows.front (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
605 if (! (equal_types<ELT_T, char>::value |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
606 || equal_types<ELT_T, octave_value>::value) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
607 && row.all_1x1_p ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
608 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
609 // Optimize all scalars case. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
610 TYPE result (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
611 assert (static_cast<size_t> (result.numel ()) == row.length ()); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
612 octave_idx_type i = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
613 for (const auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
614 result(i++) = octave_value_extract<ELT_T> (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
615 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
616 return result; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
617 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
618 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
619 octave_idx_type ncols = row.length (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
620 octave_idx_type i = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
621 OCTAVE_LOCAL_BUFFER (TYPE, array_list, ncols); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
622 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
623 for (const auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
624 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
625 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
626 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
627 array_list[i++] = octave_value_extract<TYPE> (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
628 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
629 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
630 return TYPE::cat (-2, ncols, array_list); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
631 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
632 else |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
633 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
634 TYPE result (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
635 array_concat_internal<TYPE> (result); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
636 return result; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
637 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
638 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
639 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
640 template <typename TYPE> |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
641 TYPE tm_const::sparse_array_concat (void) const |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
642 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
643 if (m_dv.any_zero ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
644 return TYPE (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
645 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
646 // Sparse matrices require preallocation for efficient indexing; besides, |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
647 // only horizontal concatenation can be efficiently handled by indexing. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
648 // So we just cat all rows through liboctave, then cat the final column. |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
649 octave_idx_type nrows = m_tm_rows.size (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
650 octave_idx_type j = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
651 OCTAVE_LOCAL_BUFFER (TYPE, sparse_row_list, nrows); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
652 for (const auto& row : m_tm_rows) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
653 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
654 octave_idx_type ncols = row.length (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
655 octave_idx_type i = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
656 OCTAVE_LOCAL_BUFFER (TYPE, sparse_list, ncols); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
657 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
658 for (auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
659 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
660 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
661 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
662 sparse_list[i] = octave_value_extract<TYPE> (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
663 i++; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
664 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
665 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
666 TYPE stmp = TYPE::cat (-2, ncols, sparse_list); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
667 sparse_row_list[j] = stmp; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
668 j++; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
669 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
670 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
671 return TYPE::cat (-1, nrows, sparse_row_list); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
672 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
673 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
674 template <typename MAP> |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
675 octave_map tm_const::map_concat (void) const |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
676 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
677 if (m_dv.any_zero ()) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
678 return octave_map (m_dv); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
679 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
680 octave_idx_type nrows = m_tm_rows.size (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
681 octave_idx_type j = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
682 OCTAVE_LOCAL_BUFFER (octave_map, map_row_list, nrows); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
683 for (const auto& row : m_tm_rows) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
684 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
685 octave_idx_type ncols = row.length (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
686 octave_idx_type i = 0; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
687 OCTAVE_LOCAL_BUFFER (MAP, map_list, ncols); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
688 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
689 for (auto& elt : row) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
690 { |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
691 octave_quit (); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
692 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
693 map_list[i] = octave_value_extract<MAP> (elt); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
694 i++; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
695 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
696 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
697 octave_map mtmp = octave_map::cat (-2, ncols, map_list); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
698 map_row_list[j] = mtmp; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
699 j++; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
700 } |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
701 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
702 return octave_map::cat (-1, nrows, map_row_list); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
703 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 } |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
705 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
706 /* |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
707 ## test concatenation with all zero matrices |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
708 %!assert ([ "" 65*ones(1,10) ], "AAAAAAAAAA") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
709 %!assert ([ 65*ones(1,10) "" ], "AAAAAAAAAA") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
710 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
711 %!test |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
712 %! c = {"foo"; "bar"; "bazoloa"}; |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
713 %! assert ([c; "a"; "bc"; "def"], {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"}); |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
714 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
715 %!assert (class ([int64(1), int64(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
716 %!assert (class ([int64(1), int32(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
717 %!assert (class ([int64(1), int16(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
718 %!assert (class ([int64(1), int8(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
719 %!assert (class ([int64(1), uint64(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
720 %!assert (class ([int64(1), uint32(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
721 %!assert (class ([int64(1), uint16(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
722 %!assert (class ([int64(1), uint8(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
723 %!assert (class ([int64(1), single(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
724 %!assert (class ([int64(1), double(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
725 %!assert (class ([int64(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
726 %!assert (class ([int64(1), true]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
727 %!assert (class ([int64(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
728 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
729 %!assert (class ([int32(1), int64(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
730 %!assert (class ([int32(1), int32(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
731 %!assert (class ([int32(1), int16(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
732 %!assert (class ([int32(1), int8(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
733 %!assert (class ([int32(1), uint64(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
734 %!assert (class ([int32(1), uint32(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
735 %!assert (class ([int32(1), uint16(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
736 %!assert (class ([int32(1), uint8(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
737 %!assert (class ([int32(1), single(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
738 %!assert (class ([int32(1), double(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
739 %!assert (class ([int32(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
740 %!assert (class ([int32(1), true]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
741 %!assert (class ([int32(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
742 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
743 %!assert (class ([int16(1), int64(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
744 %!assert (class ([int16(1), int32(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
745 %!assert (class ([int16(1), int16(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
746 %!assert (class ([int16(1), int8(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
747 %!assert (class ([int16(1), uint64(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
748 %!assert (class ([int16(1), uint32(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
749 %!assert (class ([int16(1), uint16(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
750 %!assert (class ([int16(1), uint8(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
751 %!assert (class ([int16(1), single(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
752 %!assert (class ([int16(1), double(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
753 %!assert (class ([int16(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
754 %!assert (class ([int16(1), true]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
755 %!assert (class ([int16(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
756 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
757 %!assert (class ([int8(1), int64(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
758 %!assert (class ([int8(1), int32(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
759 %!assert (class ([int8(1), int16(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
760 %!assert (class ([int8(1), int8(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
761 %!assert (class ([int8(1), uint64(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
762 %!assert (class ([int8(1), uint32(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
763 %!assert (class ([int8(1), uint16(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
764 %!assert (class ([int8(1), uint8(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
765 %!assert (class ([int8(1), single(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
766 %!assert (class ([int8(1), double(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
767 %!assert (class ([int8(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
768 %!assert (class ([int8(1), true]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
769 %!assert (class ([int8(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
770 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
771 %!assert (class ([uint64(1), int64(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
772 %!assert (class ([uint64(1), int32(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
773 %!assert (class ([uint64(1), int16(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
774 %!assert (class ([uint64(1), int8(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
775 %!assert (class ([uint64(1), uint64(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
776 %!assert (class ([uint64(1), uint32(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
777 %!assert (class ([uint64(1), uint16(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
778 %!assert (class ([uint64(1), uint8(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
779 %!assert (class ([uint64(1), single(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
780 %!assert (class ([uint64(1), double(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
781 %!assert (class ([uint64(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
782 %!assert (class ([uint64(1), true]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
783 %!assert (class ([uint64(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
784 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
785 %!assert (class ([uint32(1), int64(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
786 %!assert (class ([uint32(1), int32(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
787 %!assert (class ([uint32(1), int16(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
788 %!assert (class ([uint32(1), int8(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
789 %!assert (class ([uint32(1), uint64(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
790 %!assert (class ([uint32(1), uint32(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
791 %!assert (class ([uint32(1), uint16(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
792 %!assert (class ([uint32(1), uint8(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
793 %!assert (class ([uint32(1), single(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
794 %!assert (class ([uint32(1), double(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
795 %!assert (class ([uint32(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
796 %!assert (class ([uint32(1), true]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
797 %!assert (class ([uint32(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
798 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
799 %!assert (class ([uint16(1), int64(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
800 %!assert (class ([uint16(1), int32(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
801 %!assert (class ([uint16(1), int16(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
802 %!assert (class ([uint16(1), int8(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
803 %!assert (class ([uint16(1), uint64(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
804 %!assert (class ([uint16(1), uint32(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
805 %!assert (class ([uint16(1), uint16(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
806 %!assert (class ([uint16(1), uint8(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
807 %!assert (class ([uint16(1), single(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
808 %!assert (class ([uint16(1), double(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
809 %!assert (class ([uint16(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
810 %!assert (class ([uint16(1), true]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
811 %!assert (class ([uint16(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
812 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
813 %!assert (class ([uint8(1), int64(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
814 %!assert (class ([uint8(1), int32(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
815 %!assert (class ([uint8(1), int16(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
816 %!assert (class ([uint8(1), int8(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
817 %!assert (class ([uint8(1), uint64(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
818 %!assert (class ([uint8(1), uint32(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
819 %!assert (class ([uint8(1), uint16(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
820 %!assert (class ([uint8(1), uint8(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
821 %!assert (class ([uint8(1), single(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
822 %!assert (class ([uint8(1), double(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
823 %!assert (class ([uint8(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
824 %!assert (class ([uint8(1), true]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
825 %!assert (class ([uint8(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
826 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
827 %!assert (class ([single(1), int64(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
828 %!assert (class ([single(1), int32(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
829 %!assert (class ([single(1), int16(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
830 %!assert (class ([single(1), int8(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
831 %!assert (class ([single(1), uint64(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
832 %!assert (class ([single(1), uint32(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
833 %!assert (class ([single(1), uint16(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
834 %!assert (class ([single(1), uint8(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
835 %!assert (class ([single(1), single(1)]), "single") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
836 %!assert (class ([single(1), double(1)]), "single") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
837 %!assert (class ([single(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
838 %!assert (class ([single(1), true]), "single") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
839 %!assert (class ([single(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
840 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
841 %!assert (class ([double(1), int64(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
842 %!assert (class ([double(1), int32(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
843 %!assert (class ([double(1), int16(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
844 %!assert (class ([double(1), int8(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
845 %!assert (class ([double(1), uint64(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
846 %!assert (class ([double(1), uint32(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
847 %!assert (class ([double(1), uint16(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
848 %!assert (class ([double(1), uint8(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
849 %!assert (class ([double(1), single(1)]), "single") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
850 %!assert (class ([double(1), double(1)]), "double") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
851 %!assert (class ([double(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
852 %!assert (class ([double(1), true]), "double") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
853 %!assert (class ([double(1), "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
854 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
855 %!assert (class ([cell(1), int64(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
856 %!assert (class ([cell(1), int32(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
857 %!assert (class ([cell(1), int16(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
858 %!assert (class ([cell(1), int8(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
859 %!assert (class ([cell(1), uint64(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
860 %!assert (class ([cell(1), uint32(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
861 %!assert (class ([cell(1), uint16(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
862 %!assert (class ([cell(1), uint8(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
863 %!assert (class ([cell(1), single(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
864 %!assert (class ([cell(1), double(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
865 %!assert (class ([cell(1), cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
866 %!assert (class ([cell(1), true]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
867 %!assert (class ([cell(1), "a"]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
868 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
869 %!assert (class ([true, int64(1)]), "int64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
870 %!assert (class ([true, int32(1)]), "int32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
871 %!assert (class ([true, int16(1)]), "int16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
872 %!assert (class ([true, int8(1)]), "int8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
873 %!assert (class ([true, uint64(1)]), "uint64") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
874 %!assert (class ([true, uint32(1)]), "uint32") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
875 %!assert (class ([true, uint16(1)]), "uint16") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
876 %!assert (class ([true, uint8(1)]), "uint8") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
877 %!assert (class ([true, single(1)]), "single") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
878 %!assert (class ([true, double(1)]), "double") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
879 %!assert (class ([true, cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
880 %!assert (class ([true, true]), "logical") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
881 %!assert (class ([true, "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
882 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
883 %!assert (class (["a", int64(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
884 %!assert (class (["a", int32(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
885 %!assert (class (["a", int16(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
886 %!assert (class (["a", int8(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
887 %!assert (class (["a", int64(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
888 %!assert (class (["a", int32(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
889 %!assert (class (["a", int16(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
890 %!assert (class (["a", int8(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
891 %!assert (class (["a", single(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
892 %!assert (class (["a", double(1)]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
893 %!assert (class (["a", cell(1)]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
894 %!assert (class (["a", true]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
895 %!assert (class (["a", "a"]), "char") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
896 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
897 %!assert (class ([cell(1), struct("foo", "bar")]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
898 %!error [struct("foo", "bar"), cell(1)] |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
899 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
900 %!test <*39041> assert (class ([cell(0), struct()]), "cell") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
901 %!test <51086> assert (class ([struct(), cell(0)]), "struct") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
902 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
903 %!assert ([,1], 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
904 %!assert ([1,], 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
905 %!assert ([,1,], 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
906 %!assert ([,1,;;], 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
907 %!assert ([,1,;,;], 1) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
908 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
909 %!assert ([1,1], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
910 %!assert ([,1,1], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
911 %!assert ([1,1,], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
912 %!assert ([,1,1,], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
913 %!assert ([,1,1,;;], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
914 %!assert ([,1,1,;,;], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
915 %!assert ([,;,1,1], ones (1, 2)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
916 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
917 %!assert ([1;1], ones (2, 1)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
918 %!assert ([1,;1], ones (2, 1)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
919 %!assert ([1,;,;1], ones (2, 1)) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
920 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
921 %!error eval ("[,,]") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
922 %!error eval ("[,,;,]") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
923 %!error eval ("[,;,,;,]") |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
924 |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
925 %!assert (isnull ([,])) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
926 %!assert (isnull ([;])) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
927 %!assert (isnull ([;;])) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
928 %!assert (isnull ([;,;])) |
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
929 %!assert (isnull ([,;,;,])) |
28542
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
930 |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
931 ## Undefined elements. |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
932 %!function my_undef () |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
933 %!endfunction |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
934 %! |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
935 %!shared es |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
936 %! es = struct ("a", {}); |
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
937 %! |
28579
713398d4a3c3
update bug status of tests marked with bug numbers
John W. Eaton <jwe@octave.org>
parents:
28547
diff
changeset
|
938 %!assert <*58695> ([1; es.a; 3], [1; 3]) |
713398d4a3c3
update bug status of tests marked with bug numbers
John W. Eaton <jwe@octave.org>
parents:
28547
diff
changeset
|
939 %!test <*58695> |
28547
66397e171801
error on undefined elements in matrix lists (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
28542
diff
changeset
|
940 %! fail ("undefined element in matrix list", "[1; my_undef(), 3]"); |
28542
c318254c9f01
accept and ignore undefined elements in matrix concatentation (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
941 %! |
28579
713398d4a3c3
update bug status of tests marked with bug numbers
John W. Eaton <jwe@octave.org>
parents:
28547
diff
changeset
|
942 %!assert <*58695> ([es.a; es.a; 3], 3) |
713398d4a3c3
update bug status of tests marked with bug numbers
John W. Eaton <jwe@octave.org>
parents:
28547
diff
changeset
|
943 %!test <*58695> |
28547
66397e171801
error on undefined elements in matrix lists (bug #58695)
John W. Eaton <jwe@octave.org>
parents:
28542
diff
changeset
|
944 %! fail ("undefined element in matrix list", "[my_undef(); my_undef(); 3]") |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
945 */ |