annotate libinterp/parse-tree/pt-tm-const.cc @ 32633:4b601ca024d5

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