annotate src/pt-mat.cc @ 13144:c99f24c10ca3

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