Mercurial > octave-antonio
annotate src/ov-cell.cc @ 10840:89f4d7e294cc
Grammarcheck .cc files
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 31 Jul 2010 11:18:11 -0700 |
parents | 687586b99f9d |
children | 333bf09e3b6e |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
5 Copyright (C) 2009, 2010 VZLU Prague |
3353 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
3353 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
3353 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include <config.h> | |
27 #endif | |
28 | |
5850 | 29 #include <iomanip> |
3503 | 30 #include <iostream> |
5765 | 31 #include <sstream> |
5164 | 32 #include <vector> |
9370
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
33 #include <queue> |
3353 | 34 |
5360 | 35 #include "Array-util.h" |
36 #include "byte-swap.h" | |
3353 | 37 #include "lo-utils.h" |
4153 | 38 #include "quit.h" |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
39 #include "oct-locbuf.h" |
3353 | 40 |
41 #include "defun.h" | |
42 #include "error.h" | |
43 #include "ov-cell.h" | |
3354 | 44 #include "oct-obj.h" |
3353 | 45 #include "unwind-prot.h" |
3354 | 46 #include "utils.h" |
3928 | 47 #include "ov-base-mat.h" |
48 #include "ov-base-mat.cc" | |
49 #include "ov-re-mat.h" | |
50 #include "ov-scalar.h" | |
5360 | 51 #include "pr-output.h" |
52 #include "ov-scalar.h" | |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8551
diff
changeset
|
53 #include "gripes.h" |
3928 | 54 |
4687 | 55 #include "ls-oct-ascii.h" |
56 #include "ls-oct-binary.h" | |
57 #include "ls-hdf5.h" | |
58 #include "ls-utils.h" | |
59 | |
8679
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
60 // Cell is able to handle octave_value indexing by itself, so just forward |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
61 // everything. |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
62 |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
63 template <> |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
64 octave_value |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
65 octave_base_matrix<Cell>::do_index_op (const octave_value_list& idx, |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
66 bool resize_ok) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
67 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
68 return matrix.index (idx, resize_ok); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
69 } |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
70 |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
71 template <> |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
72 void |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
73 octave_base_matrix<Cell>::assign (const octave_value_list& idx, const Cell& rhs) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
74 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
75 matrix.assign (idx, rhs); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
76 } |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
77 |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
78 template <> |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
79 void |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
80 octave_base_matrix<Cell>::assign (const octave_value_list& idx, octave_value rhs) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
81 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
82 // FIXME: Really? |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
83 if (rhs.is_cell ()) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
84 matrix.assign (idx, rhs.cell_value ()); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
85 else |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
86 matrix.assign (idx, Cell (rhs)); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
87 } |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
88 |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
89 template <> |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
90 void |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
91 octave_base_matrix<Cell>::delete_elements (const octave_value_list& idx) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
92 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
93 matrix.delete_elements (idx); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
94 } |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8626
diff
changeset
|
95 |
10670
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
96 // FIXME: this list of specializations is becoming so long that we should really ask |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
97 // whether octave_cell should inherit from octave_base_matrix at all. |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
98 |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
99 template <> |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
100 octave_value |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
101 octave_base_matrix<Cell>::fast_elem_extract (octave_idx_type n) const |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
102 { |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
103 if (n < matrix.numel ()) |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
104 return Cell (matrix(n)); |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
105 else |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
106 return octave_value (); |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
107 } |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
108 |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
109 template <> |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
110 bool |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
111 octave_base_matrix<Cell>::fast_elem_insert (octave_idx_type n, |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
112 const octave_value& x) |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
113 { |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
114 const octave_cell *xrep = |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
115 dynamic_cast<const octave_cell *> (&x.get_rep ()); |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
116 |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
117 bool retval = xrep && xrep->matrix.numel () == 1 && n < matrix.numel (); |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
118 if (retval) |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
119 matrix(n) = xrep->matrix(0); |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
120 |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
121 return retval; |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
122 } |
654fbde5dceb
make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents:
10600
diff
changeset
|
123 |
3928 | 124 template class octave_base_matrix<Cell>; |
3353 | 125 |
126 DEFINE_OCTAVE_ALLOCATOR (octave_cell); | |
127 | |
4612 | 128 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell"); |
3353 | 129 |
6833 | 130 static void |
131 gripe_failed_assignment (void) | |
132 { | |
133 error ("assignment to cell array failed"); | |
134 } | |
135 | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
136 octave_value_list |
4247 | 137 octave_cell::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
138 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
139 int nargout) |
3933 | 140 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
141 octave_value_list retval; |
3933 | 142 |
143 switch (type[0]) | |
144 { | |
145 case '(': | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
146 retval(0) = do_index_op (idx.front ()); |
3933 | 147 break; |
148 | |
149 case '{': | |
150 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
151 octave_value tmp = do_index_op (idx.front ()); |
3933 | 152 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
153 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
154 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
155 Cell tcell = tmp.cell_value (); |
4582 | 156 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
157 if (tcell.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
158 retval(0) = tcell(0,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
159 else |
8546
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
160 retval = octave_value (octave_value_list (tcell), true); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
161 } |
3933 | 162 } |
163 break; | |
164 | |
165 case '.': | |
166 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
167 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
168 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 169 } |
170 break; | |
171 | |
172 default: | |
173 panic_impossible (); | |
174 } | |
175 | |
5775 | 176 // FIXME -- perhaps there should be an |
4994 | 177 // octave_value_list::next_subsref member function? See also |
178 // octave_user_function::subsref. | |
179 | |
180 if (idx.size () > 1) | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7622
diff
changeset
|
181 retval = retval(0).next_subsref (nargout, type, idx); |
4994 | 182 |
183 return retval; | |
3933 | 184 } |
185 | |
186 octave_value | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
187 octave_cell::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
188 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
189 bool auto_add) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
190 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
191 octave_value retval; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
192 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
193 switch (type[0]) |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
194 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
195 case '(': |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
196 retval = do_index_op (idx.front (), auto_add); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
197 break; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
198 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
199 case '{': |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
200 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
201 octave_value tmp = do_index_op (idx.front (), auto_add); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
202 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
203 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
204 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
205 const Cell tcell = tmp.cell_value (); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
206 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
207 if (tcell.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
208 retval = tcell(0,0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
209 else |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8551
diff
changeset
|
210 retval = octave_value (octave_value_list (tcell), true); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
211 } |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
212 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
213 break; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
214 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
215 case '.': |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
216 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
217 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
218 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
219 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
220 break; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
221 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
222 default: |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
223 panic_impossible (); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
224 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
225 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
226 // FIXME -- perhaps there should be an |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
227 // octave_value_list::next_subsref member function? See also |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
228 // octave_user_function::subsref. |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
229 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
230 if (idx.size () > 1) |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
231 retval = retval.next_subsref (auto_add, type, idx); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
232 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
233 return retval; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
234 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
235 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8546
diff
changeset
|
236 octave_value |
4247 | 237 octave_cell::subsasgn (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
238 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
239 const octave_value& rhs) |
3933 | 240 { |
241 octave_value retval; | |
242 | |
243 int n = type.length (); | |
244 | |
245 octave_value t_rhs = rhs; | |
246 | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
247 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
248 |
9286
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
249 if (idx.front ().empty ()) |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
250 { |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
251 error ("missing index in indexed assignment"); |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
252 return retval; |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
253 } |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9109
diff
changeset
|
254 |
3933 | 255 if (n > 1) |
256 { | |
257 switch (type[0]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
258 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
259 case '(': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
260 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
261 if (is_empty () && type[1] == '.') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
262 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
263 // Allow conversion of empty cell array to some other |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
264 // type in cases like |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
265 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
266 // x = []; x(i).f = rhs |
3933 | 267 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
268 octave_value tmp = octave_value::empty_conv (type, rhs); |
3933 | 269 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
270 return tmp.subsasgn (type, idx, rhs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
271 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
272 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
273 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
274 octave_value tmp = do_index_op (idx.front (), true); |
3933 | 275 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
276 if (! tmp.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
277 tmp = octave_value::empty_conv (type.substr (1), rhs); |
3933 | 278 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
279 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
280 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
281 std::list<octave_value_list> next_idx (idx); |
4362 | 282 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
283 next_idx.erase (next_idx.begin ()); |
6767 | 284 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
285 tmp.make_unique (); |
6767 | 286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
287 t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
288 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
289 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
290 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
291 break; |
3933 | 292 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
293 case '{': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
294 { |
9106
1eb5b24186b6
fix nested cell assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
295 matrix.make_unique (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
296 Cell tmpc = matrix.index (idx.front (), true); |
3933 | 297 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
298 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
299 { |
8546
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
300 std::list<octave_value_list> next_idx (idx); |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
301 |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
302 next_idx.erase (next_idx.begin ()); |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
303 |
3d8a914c580e
improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents:
8523
diff
changeset
|
304 std::string next_type = type.substr (1); |
3933 | 305 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8551
diff
changeset
|
306 if (tmpc.numel () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
307 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
308 octave_value tmp = tmpc(0); |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
309 tmpc = Cell (); |
3933 | 310 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
311 if (! tmp.is_defined () || tmp.is_zero_by_zero ()) |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
312 { |
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
313 tmp = octave_value::empty_conv (type.substr (1), rhs); |
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
314 tmp.make_unique (); // probably a no-op. |
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
315 } |
8452
d6a349c7bd39
fix {} assigment if error occurs on subsequent assignment component
Jaroslav Hajek <highegg@gmail.com>
parents:
8446
diff
changeset
|
316 else |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
317 // optimization: ignore the copy still stored inside our array. |
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
318 tmp.make_unique (1); |
4519 | 319 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
320 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
321 t_rhs = tmp.subsasgn (next_type, next_idx, rhs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
322 } |
8446
7b25349b32e6
avoid redundant copying in {} assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
323 else |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8551
diff
changeset
|
324 gripe_indexed_cs_list (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
325 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
326 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
327 break; |
3933 | 328 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
329 case '.': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
331 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
332 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
333 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
334 break; |
3933 | 335 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
336 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
337 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
338 } |
3933 | 339 } |
340 | |
3940 | 341 if (! error_state) |
3933 | 342 { |
3940 | 343 switch (type[0]) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
344 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
345 case '(': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
346 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
347 octave_value_list i = idx.front (); |
3933 | 348 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
349 if (t_rhs.is_cell ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
350 octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
351 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
352 if (t_rhs.is_null_value ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
353 octave_base_matrix<Cell>::delete_elements (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
354 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
355 octave_base_matrix<Cell>::assign (i, Cell (t_rhs)); |
3933 | 356 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
357 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
358 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
359 count++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
360 retval = octave_value (this); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
361 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
362 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
363 gripe_failed_assignment (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
364 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
365 break; |
3933 | 366 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
367 case '{': |
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 idxf = idx.front (); |
3933 | 370 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
371 if (t_rhs.is_cs_list ()) |
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 Cell tmp_cell = Cell (t_rhs.list_value ()); |
5846 | 374 |
8587
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
375 // Inquire the proper shape of the RHS. |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
376 |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
377 dim_vector didx = dims ().redim (idxf.length ()); |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
378 for (octave_idx_type k = 0; k < idxf.length (); k++) |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
379 if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel (); |
7040 | 380 |
8587
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
381 if (didx.numel () == tmp_cell.numel ()) |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
382 tmp_cell = tmp_cell.reshape (didx); |
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
383 |
5846 | 384 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
385 octave_base_matrix<Cell>::assign (idxf, tmp_cell); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
386 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
387 else if (idxf.all_scalars () || do_index_op (idxf, true).numel () == 1) |
8455
fd11a08a9b31
disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents:
8452
diff
changeset
|
388 // Regularize a null matrix if stored into a cell. |
8587
35656d6ad061
properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8580
diff
changeset
|
389 octave_base_matrix<Cell>::assign (idxf, Cell (t_rhs.storable_value ())); |
8455
fd11a08a9b31
disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents:
8452
diff
changeset
|
390 else if (! error_state) |
10030
83bb2a78c07d
improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
391 gripe_nonbraced_cs_list_assignment (); |
3933 | 392 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
393 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
394 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
395 count++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
396 retval = octave_value (this); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
397 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
398 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
399 gripe_failed_assignment (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
400 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
401 break; |
3933 | 402 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
403 case '.': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
404 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
405 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
406 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
407 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
408 break; |
3933 | 409 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
410 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
411 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
412 } |
3933 | 413 } |
414 | |
415 return retval; | |
416 } | |
417 | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
418 bool |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
419 octave_cell::is_cellstr (void) const |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
420 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
421 bool retval; |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
422 if (cellstr_cache.get ()) |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
423 retval = true; |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
424 else |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
425 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
426 retval = matrix.is_cellstr (); |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
427 // Allocate empty cache to mark that this is indeed a cellstr. |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
428 if (retval) |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
429 cellstr_cache.reset (new Array<std::string> ()); |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
430 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
431 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
432 return retval; |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
433 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
434 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
435 void |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
436 octave_cell::assign (const octave_value_list& idx, const Cell& rhs) |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
437 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
438 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
439 octave_base_matrix<Cell>::assign (idx, rhs); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
440 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
441 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
442 void |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
443 octave_cell::assign (const octave_value_list& idx, const octave_value& rhs) |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
444 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
445 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
446 octave_base_matrix<Cell>::assign (idx, rhs); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
447 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
448 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
449 |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
450 void |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
451 octave_cell::delete_elements (const octave_value_list& idx) |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
452 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
453 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
454 octave_base_matrix<Cell>::delete_elements (idx); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
455 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
456 |
4791 | 457 size_t |
458 octave_cell::byte_size (void) const | |
459 { | |
460 size_t retval = 0; | |
461 | |
5275 | 462 for (octave_idx_type i = 0; i < numel (); i++) |
4791 | 463 retval += matrix(i).byte_size (); |
464 | |
465 return retval; | |
466 } | |
467 | |
8732 | 468 octave_value |
469 octave_cell::sort (octave_idx_type dim, sortmode mode) const | |
470 { | |
471 octave_value retval; | |
472 | |
473 if (is_cellstr ()) | |
474 { | |
475 Array<std::string> tmp = cellstr_value (); | |
476 | |
8824
76ddf0ab985d
auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
477 tmp = tmp.sort (dim, mode); |
76ddf0ab985d
auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
478 |
8825
c3445f1c8cb4
reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents:
8824
diff
changeset
|
479 // We already have the cache. |
c3445f1c8cb4
reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents:
8824
diff
changeset
|
480 retval = new octave_cell (tmp); |
8732 | 481 } |
482 else | |
483 error ("sort: only cell arrays of character strings may be sorted"); | |
484 | |
485 return retval; | |
486 } | |
487 | |
488 octave_value | |
489 octave_cell::sort (Array<octave_idx_type> &sidx, octave_idx_type dim, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
490 sortmode mode) const |
8732 | 491 { |
492 octave_value retval; | |
493 | |
494 if (is_cellstr ()) | |
495 { | |
496 Array<std::string> tmp = cellstr_value (); | |
497 | |
8824
76ddf0ab985d
auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
498 tmp = tmp.sort (sidx, dim, mode); |
76ddf0ab985d
auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8823
diff
changeset
|
499 |
9338
650c7efa7234
simplify octave_cell::sort
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
500 // We already have the cache. |
650c7efa7234
simplify octave_cell::sort
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
501 retval = new octave_cell (tmp); |
8732 | 502 } |
503 else | |
504 error ("sort: only cell arrays of character strings may be sorted"); | |
505 | |
506 return retval; | |
507 } | |
508 | |
8823
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
509 sortmode |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
510 octave_cell::is_sorted (sortmode mode) const |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
511 { |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
512 sortmode retval = UNSORTED; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
513 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
514 if (is_cellstr ()) |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
515 { |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
516 Array<std::string> tmp = cellstr_value (); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
517 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
518 retval = tmp.is_sorted (mode); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
519 } |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
520 else |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
521 error ("issorted: not a cell array of strings"); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
522 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
523 return retval; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
524 } |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
525 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
526 |
8732 | 527 Array<octave_idx_type> |
8733
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
528 octave_cell::sort_rows_idx (sortmode mode) const |
8732 | 529 { |
530 Array<octave_idx_type> retval; | |
531 | |
532 if (is_cellstr ()) | |
533 { | |
534 Array<std::string> tmp = cellstr_value (); | |
535 | |
536 retval = tmp.sort_rows_idx (mode); | |
537 } | |
538 else | |
539 error ("sortrows: only cell arrays of character strings may be sorted"); | |
540 | |
541 return retval; | |
542 } | |
543 | |
8823
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
544 sortmode |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
545 octave_cell::is_sorted_rows (sortmode mode) const |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
546 { |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
547 sortmode retval = UNSORTED; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
548 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
549 if (is_cellstr ()) |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
550 { |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
551 Array<std::string> tmp = cellstr_value (); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
552 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
553 retval = tmp.is_sorted_rows (mode); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
554 } |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
555 else |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
556 error ("issorted: not a cell array of strings"); |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
557 |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
558 return retval; |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
559 } |
3efa512a0957
make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents:
8815
diff
changeset
|
560 |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
561 bool |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
562 octave_cell::is_true (void) const |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
563 { |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
564 error ("invalid conversion from cell array to logical value"); |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
565 return false; |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
566 } |
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8587
diff
changeset
|
567 |
3933 | 568 octave_value_list |
569 octave_cell::list_value (void) const | |
570 { | |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8579
diff
changeset
|
571 return octave_value_list (matrix); |
3933 | 572 } |
573 | |
4243 | 574 string_vector |
5715 | 575 octave_cell::all_strings (bool pad) const |
4243 | 576 { |
4358 | 577 string_vector retval; |
578 | |
7285 | 579 octave_idx_type nel = numel (); |
4243 | 580 |
4358 | 581 int n_elts = 0; |
582 | |
5275 | 583 octave_idx_type max_len = 0; |
4358 | 584 |
9370
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
585 std::queue<string_vector> strvec_queue; |
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
586 |
7285 | 587 for (octave_idx_type i = 0; i < nel; i++) |
4358 | 588 { |
7285 | 589 string_vector s = matrix(i).all_strings (); |
590 | |
591 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
592 return retval; |
4358 | 593 |
7285 | 594 octave_idx_type s_len = s.length (); |
4358 | 595 |
7285 | 596 n_elts += s_len ? s_len : 1; |
4358 | 597 |
7285 | 598 octave_idx_type s_max_len = s.max_length (); |
4358 | 599 |
7285 | 600 if (s_max_len > max_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
601 max_len = s_max_len; |
9370
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
602 |
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
603 strvec_queue.push (s); |
4358 | 604 } |
605 | |
9370
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
606 retval = string_vector (n_elts); |
4243 | 607 |
5275 | 608 octave_idx_type k = 0; |
4243 | 609 |
7285 | 610 for (octave_idx_type i = 0; i < nel; i++) |
4243 | 611 { |
9370
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
612 const string_vector s = strvec_queue.front (); |
4ff6f8efdda2
fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
9338
diff
changeset
|
613 strvec_queue.pop (); |
7285 | 614 |
615 octave_idx_type s_len = s.length (); | |
4358 | 616 |
7285 | 617 if (s_len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
618 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
619 for (octave_idx_type j = 0; j < s_len; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
620 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
621 std::string t = s[j]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
622 int t_len = t.length (); |
5715 | 623 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
624 if (pad && max_len > t_len) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
625 t += std::string (max_len - t_len, ' '); |
5715 | 626 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
627 retval[k++] = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
628 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
629 } |
7285 | 630 else if (pad) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
631 retval[k++] = std::string (max_len, ' '); |
7285 | 632 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
633 retval[k++] = std::string (); |
4243 | 634 } |
635 | |
636 return retval; | |
637 } | |
638 | |
8732 | 639 Array<std::string> |
640 octave_cell::cellstr_value (void) const | |
641 { | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
642 Array<std::string> retval; |
8732 | 643 |
644 if (is_cellstr ()) | |
645 { | |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
646 if (cellstr_cache->is_empty ()) |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
647 *cellstr_cache = matrix.cellstr_value (); |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
648 |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10030
diff
changeset
|
649 return *cellstr_cache; |
8732 | 650 } |
651 else | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
652 error ("invalid conversion from cell array to array of strings"); |
8732 | 653 |
654 return retval; | |
655 } | |
656 | |
4604 | 657 bool |
658 octave_cell::print_as_scalar (void) const | |
659 { | |
660 return (ndims () > 2 || numel () == 0); | |
661 } | |
662 | |
3933 | 663 void |
664 octave_cell::print (std::ostream& os, bool) const | |
665 { | |
666 print_raw (os); | |
667 } | |
668 | |
669 void | |
670 octave_cell::print_raw (std::ostream& os, bool) const | |
671 { | |
4587 | 672 int nd = matrix.ndims (); |
4513 | 673 |
4587 | 674 if (nd == 2) |
4513 | 675 { |
5275 | 676 octave_idx_type nr = rows (); |
677 octave_idx_type nc = columns (); | |
4513 | 678 |
679 if (nr > 0 && nc > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
680 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
681 indent (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
682 os << "{"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
683 newline (os); |
4513 | 684 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
685 increment_indent_level (); |
4513 | 686 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
687 for (octave_idx_type j = 0; j < nc; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
688 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
689 for (octave_idx_type i = 0; i < nr; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
690 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
691 octave_quit (); |
4513 | 692 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
693 std::ostringstream buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
694 buf << "[" << i+1 << "," << j+1 << "]"; |
3933 | 695 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
696 octave_value val = matrix(i,j); |
4513 | 697 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
698 val.print_with_name (os, buf.str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
699 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
700 } |
4513 | 701 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
702 decrement_indent_level (); |
4513 | 703 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
704 indent (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
705 os << "}"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
706 newline (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
707 } |
4513 | 708 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
709 { |
9781
ea88eece12f5
fix printing of empty cells
Jaroslav Hajek <highegg@gmail.com>
parents:
9370
diff
changeset
|
710 indent (os); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
711 os << "{}"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
712 if (Vprint_empty_dimensions) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
713 os << "(" << nr << "x" << nc << ")"; |
9781
ea88eece12f5
fix printing of empty cells
Jaroslav Hajek <highegg@gmail.com>
parents:
9370
diff
changeset
|
714 newline (os); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
715 } |
4513 | 716 } |
717 else | |
3933 | 718 { |
719 indent (os); | |
4513 | 720 dim_vector dv = matrix.dims (); |
4587 | 721 os << "{" << dv.str () << " Cell Array}"; |
3933 | 722 newline (os); |
723 } | |
724 } | |
725 | |
4687 | 726 #define CELL_ELT_TAG "<cell-element>" |
727 | |
728 bool | |
6974 | 729 octave_cell::save_ascii (std::ostream& os) |
4687 | 730 { |
731 dim_vector d = dims (); | |
732 if (d.length () > 2) | |
733 { | |
734 os << "# ndims: " << d.length () << "\n"; | |
735 | |
5275 | 736 for (int i = 0; i < d.length (); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
737 os << " " << d (i); |
4687 | 738 os << "\n"; |
739 | |
740 Cell tmp = cell_value (); | |
741 | |
5275 | 742 for (octave_idx_type i = 0; i < d.numel (); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
743 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
744 octave_value o_val = tmp.elem (i); |
4687 | 745 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
746 // Recurse to print sub-value. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
747 bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
748 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
749 if (! b) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
750 return os; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
751 } |
4687 | 752 } |
753 else | |
754 { | |
755 // Keep this case, rather than use generic code above for backward | |
756 // compatiability. Makes load_ascii much more complex!! | |
757 os << "# rows: " << rows () << "\n" | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
758 << "# columns: " << columns () << "\n"; |
4687 | 759 |
760 Cell tmp = cell_value (); | |
761 | |
5275 | 762 for (octave_idx_type j = 0; j < tmp.cols (); j++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
763 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
764 for (octave_idx_type i = 0; i < tmp.rows (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
765 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
766 octave_value o_val = tmp.elem (i, j); |
4687 | 767 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
768 // Recurse to print sub-value. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
769 bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
770 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
771 if (! b) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
772 return os; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
773 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
774 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
775 os << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
776 } |
4687 | 777 } |
778 | |
779 return true; | |
780 } | |
781 | |
782 bool | |
783 octave_cell::load_ascii (std::istream& is) | |
784 { | |
785 bool success = true; | |
5099 | 786 |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
787 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
788 |
5099 | 789 string_vector keywords(2); |
4687 | 790 |
5099 | 791 keywords[0] = "ndims"; |
792 keywords[1] = "rows"; | |
793 | |
794 std::string kw; | |
5275 | 795 octave_idx_type val = 0; |
5099 | 796 |
797 if (extract_keyword (is, keywords, kw, val, true)) | |
4687 | 798 { |
5099 | 799 if (kw == "ndims") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
800 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
801 int mdims = static_cast<int> (val); |
4687 | 802 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
803 if (mdims >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
804 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
805 dim_vector dv; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
806 dv.resize (mdims); |
5099 | 807 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
808 for (int i = 0; i < mdims; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
809 is >> dv(i); |
4687 | 810 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
811 Cell tmp(dv); |
4687 | 812 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
813 for (octave_idx_type i = 0; i < dv.numel (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
814 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
815 octave_value t2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
816 bool dummy; |
5099 | 817 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
818 // recurse to read cell elements |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
819 std::string nm = read_ascii_data (is, std::string (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
820 dummy, t2, i); |
4687 | 821 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
822 if (nm == CELL_ELT_TAG) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
823 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
824 if (is) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
825 tmp.elem (i) = t2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
826 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
827 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
828 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
829 error ("load: cell array element had unexpected name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
830 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
831 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
832 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
833 } |
4687 | 834 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
835 if (is) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
836 matrix = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
837 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
838 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
839 error ("load: failed to load matrix constant"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
840 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
841 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
842 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
843 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
844 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
845 error ("load: failed to extract number of rows and columns"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
846 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
847 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
848 } |
5099 | 849 else if (kw == "rows") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
850 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
851 octave_idx_type nr = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
852 octave_idx_type nc = 0; |
5099 | 853 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
854 if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
855 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
856 if (nr > 0 && nc > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
857 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
858 Cell tmp (nr, nc); |
5099 | 859 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
860 for (octave_idx_type j = 0; j < nc; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
861 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
862 for (octave_idx_type i = 0; i < nr; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
863 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
864 octave_value t2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
865 bool dummy; |
5099 | 866 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
867 // recurse to read cell elements |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
868 std::string nm = read_ascii_data (is, std::string (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
869 dummy, t2, i); |
5099 | 870 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
871 if (nm == CELL_ELT_TAG) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
872 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
873 if (is) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
874 tmp.elem (i, j) = t2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
875 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
876 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
877 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
878 error ("load: cell array element had unexpected name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
879 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
880 goto cell_read_error; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
881 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
882 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
883 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
884 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
885 cell_read_error: |
5099 | 886 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
887 if (is) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
888 matrix = tmp; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
889 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
890 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
891 error ("load: failed to load cell element"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
892 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
893 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
894 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
895 else if (nr == 0 || nc == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
896 matrix = Cell (nr, nc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
897 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
898 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
899 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
900 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
901 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
902 error ("load: failed to extract number of rows and columns for cell array"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
903 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
904 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
905 } |
4687 | 906 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
907 panic_impossible (); |
4687 | 908 } |
909 else | |
910 { | |
5099 | 911 error ("load: failed to extract number of rows and columns"); |
912 success = false; | |
4687 | 913 } |
914 | |
915 return success; | |
916 } | |
917 | |
918 bool | |
919 octave_cell::save_binary (std::ostream& os, bool& save_as_floats) | |
920 { | |
921 dim_vector d = dims (); | |
922 if (d.length () < 1) | |
923 return false; | |
924 | |
925 // Use negative value for ndims | |
5828 | 926 int32_t di = - d.length(); |
5760 | 927 os.write (reinterpret_cast<char *> (&di), 4); |
5275 | 928 for (int i = 0; i < d.length (); i++) |
4687 | 929 { |
930 di = d(i); | |
5760 | 931 os.write (reinterpret_cast<char *> (&di), 4); |
4687 | 932 } |
933 | |
934 Cell tmp = cell_value (); | |
935 | |
5275 | 936 for (octave_idx_type i = 0; i < d.numel (); i++) |
4687 | 937 { |
938 octave_value o_val = tmp.elem (i); | |
939 | |
940 // Recurse to print sub-value. | |
941 bool b = save_binary_data (os, o_val, CELL_ELT_TAG, "", 0, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
942 save_as_floats); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
943 |
4687 | 944 if (! b) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
945 return false; |
4687 | 946 } |
947 | |
948 return true; | |
949 } | |
950 | |
951 bool | |
952 octave_cell::load_binary (std::istream& is, bool swap, | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
953 oct_mach_info::float_format fmt) |
4687 | 954 { |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
955 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
956 |
4687 | 957 bool success = true; |
5828 | 958 int32_t mdims; |
5760 | 959 if (! is.read (reinterpret_cast<char *> (&mdims), 4)) |
4687 | 960 return false; |
961 if (swap) | |
4944 | 962 swap_bytes<4> (&mdims); |
4687 | 963 if (mdims >= 0) |
964 return false; | |
965 | |
966 mdims = -mdims; | |
5828 | 967 int32_t di; |
4687 | 968 dim_vector dv; |
969 dv.resize (mdims); | |
970 | |
971 for (int i = 0; i < mdims; i++) | |
972 { | |
5760 | 973 if (! is.read (reinterpret_cast<char *> (&di), 4)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
974 return false; |
4687 | 975 if (swap) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
976 swap_bytes<4> (&di); |
4687 | 977 dv(i) = di; |
978 } | |
979 | |
5157 | 980 // Convert an array with a single dimension to be a row vector. |
981 // Octave should never write files like this, other software | |
982 // might. | |
983 | |
984 if (mdims == 1) | |
985 { | |
986 mdims = 2; | |
987 dv.resize (mdims); | |
988 dv(1) = dv(0); | |
989 dv(0) = 1; | |
990 } | |
991 | |
5275 | 992 octave_idx_type nel = dv.numel (); |
4687 | 993 Cell tmp(dv); |
994 | |
5275 | 995 for (octave_idx_type i = 0; i < nel; i++) |
4687 | 996 { |
997 octave_value t2; | |
998 bool dummy; | |
999 std::string doc; | |
1000 | |
1001 // recurse to read cell elements | |
1002 std::string nm = read_binary_data (is, swap, fmt, std::string (), | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1003 dummy, t2, doc); |
4687 | 1004 |
1005 if (nm == CELL_ELT_TAG) | |
10315
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 if (is) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1008 tmp.elem (i) = t2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1009 } |
4687 | 1010 else |
10315
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 error ("load: cell array element had unexpected name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1013 success = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1014 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1015 } |
4687 | 1016 } |
1017 | |
1018 if (is) | |
1019 matrix = tmp; | |
1020 else | |
1021 { | |
1022 error ("load: failed to load matrix constant"); | |
1023 success = false; | |
1024 } | |
1025 | |
1026 return success; | |
1027 } | |
1028 | |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1029 void * |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1030 octave_cell::mex_get_data (void) const |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1031 { |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1032 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1033 return matrix.mex_get_data (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1034 } |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1035 |
4687 | 1036 #if defined (HAVE_HDF5) |
4815 | 1037 |
4687 | 1038 bool |
1039 octave_cell::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) | |
1040 { | |
4814 | 1041 dim_vector dv = dims (); |
4837 | 1042 int empty = save_hdf5_empty (loc_id, name, dv); |
1043 if (empty) | |
1044 return (empty > 0); | |
1045 | |
4815 | 1046 hsize_t rank = dv.length (); |
4687 | 1047 hid_t space_hid = -1, data_hid = -1, size_hid = -1; |
1048 | |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1049 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1050 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1051 #else |
4687 | 1052 data_hid = H5Gcreate (loc_id, name, 0); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1053 #endif |
4815 | 1054 |
1055 if (data_hid < 0) | |
1056 return false; | |
4687 | 1057 |
4814 | 1058 // Have to save cell array shape, since can't have a |
1059 // dataset of groups.... | |
4815 | 1060 |
1061 space_hid = H5Screate_simple (1, &rank, 0); | |
1062 | |
4687 | 1063 if (space_hid < 0) |
1064 { | |
1065 H5Gclose (data_hid); | |
1066 return false; | |
1067 } | |
1068 | |
5351 | 1069 OCTAVE_LOCAL_BUFFER (octave_idx_type, hdims, rank); |
4814 | 1070 |
1071 // Octave uses column-major, while HDF5 uses row-major ordering | |
4933 | 1072 for (hsize_t i = 0; i < rank; i++) |
4815 | 1073 hdims[i] = dv(rank-i-1); |
4814 | 1074 |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1075 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1076 size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1077 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1078 #else |
5351 | 1079 size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1080 H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1081 #endif |
4687 | 1082 if (size_hid < 0) |
1083 { | |
1084 H5Sclose (space_hid); | |
1085 H5Gclose (data_hid); | |
1086 return false; | |
1087 } | |
1088 | |
6276 | 1089 if (H5Dwrite (size_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1090 H5P_DEFAULT, hdims) < 0) |
4687 | 1091 { |
1092 H5Dclose (size_hid); | |
1093 H5Sclose (space_hid); | |
1094 H5Gclose (data_hid); | |
1095 return false; | |
1096 } | |
4815 | 1097 |
4687 | 1098 H5Dclose (size_hid); |
1099 H5Sclose (space_hid); | |
1100 | |
4815 | 1101 // Recursively add each element of the cell to this group. |
1102 | |
4687 | 1103 Cell tmp = cell_value (); |
5850 | 1104 |
1105 octave_idx_type nel = dv.numel (); | |
1106 | |
1107 for (octave_idx_type i = 0; i < nel; i++) | |
4687 | 1108 { |
5765 | 1109 std::ostringstream buf; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7285
diff
changeset
|
1110 int digits = static_cast<int> (::floor (::log10 (static_cast<double> (nel)) + 1.0)); |
5850 | 1111 buf << "_" << std::setw (digits) << std::setfill ('0') << i; |
5765 | 1112 std::string s = buf.str (); |
4687 | 1113 |
5850 | 1114 if (! add_hdf5_data (data_hid, tmp.elem (i), s.c_str (), "", false, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1115 save_as_floats)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1116 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1117 H5Gclose (data_hid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1118 return false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1119 } |
4687 | 1120 } |
1121 | |
1122 H5Gclose (data_hid); | |
4815 | 1123 |
4687 | 1124 return true; |
1125 } | |
1126 | |
1127 bool | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9813
diff
changeset
|
1128 octave_cell::load_hdf5 (hid_t loc_id, const char *name) |
4687 | 1129 { |
8815
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1130 clear_cellstr_cache (); |
af907aeedbf4
cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents:
8733
diff
changeset
|
1131 |
4687 | 1132 bool retval = false; |
4837 | 1133 |
1134 dim_vector dv; | |
1135 int empty = load_hdf5_empty (loc_id, name, dv); | |
1136 if (empty > 0) | |
1137 matrix.resize(dv); | |
1138 if (empty) | |
1139 return (empty > 0); | |
1140 | |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1141 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1142 hid_t group_id = H5Gopen (loc_id, name, H5P_DEFAULT); |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1143 #else |
4687 | 1144 hid_t group_id = H5Gopen (loc_id, name); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1145 #endif |
4687 | 1146 |
1147 if (group_id < 0) | |
1148 return false; | |
1149 | |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1150 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1151 hid_t data_hid = H5Dopen (group_id, "dims", H5P_DEFAULT); |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1152 #else |
4814 | 1153 hid_t data_hid = H5Dopen (group_id, "dims"); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1154 #endif |
4687 | 1155 hid_t space_hid = H5Dget_space (data_hid); |
1156 hsize_t rank = H5Sget_simple_extent_ndims (space_hid); | |
4814 | 1157 if (rank != 1) |
4687 | 1158 { |
4837 | 1159 H5Dclose (data_hid); |
1160 H5Gclose (group_id); | |
4687 | 1161 return false; |
1162 } | |
1163 | |
4814 | 1164 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); |
1165 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank); | |
4815 | 1166 |
4814 | 1167 H5Sget_simple_extent_dims (space_hid, hdims, maxdims); |
4687 | 1168 |
4815 | 1169 // Octave uses column-major, while HDF5 uses row-major ordering. |
1170 | |
4814 | 1171 dv.resize (hdims[0]); |
4815 | 1172 |
5351 | 1173 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, hdims[0]); |
4814 | 1174 |
5351 | 1175 if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1176 H5P_DEFAULT, tmp) < 0) |
4687 | 1177 { |
4837 | 1178 H5Dclose (data_hid); |
1179 H5Gclose (group_id); | |
4687 | 1180 return false; |
1181 } | |
4815 | 1182 |
4687 | 1183 H5Dclose (data_hid); |
1184 H5Gclose (group_id); | |
1185 | |
4815 | 1186 for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--) |
4814 | 1187 dv(j) = tmp[i]; |
1188 | |
4687 | 1189 hdf5_callback_data dsub; |
1190 | |
1191 herr_t retval2 = -1; | |
4815 | 1192 |
4814 | 1193 Cell m (dv); |
4815 | 1194 |
4687 | 1195 int current_item = 0; |
4815 | 1196 |
4696 | 1197 hsize_t num_obj = 0; |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1198 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1199 group_id = H5Gopen (loc_id, name, H5P_DEFAULT); |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1200 #else |
5060 | 1201 group_id = H5Gopen (loc_id, name); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
1202 #endif |
5060 | 1203 H5Gget_num_objs (group_id, &num_obj); |
1204 H5Gclose (group_id); | |
4696 | 1205 |
5275 | 1206 for (octave_idx_type i = 0; i < dv.numel (); i++) |
4687 | 1207 { |
4696 | 1208 |
4814 | 1209 if (current_item >= static_cast<int> (num_obj)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1210 retval2 = -1; |
4814 | 1211 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1212 retval2 = H5Giterate (loc_id, name, ¤t_item, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1213 hdf5_read_next_data, &dsub); |
4814 | 1214 |
4687 | 1215 if (retval2 <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1216 break; |
4814 | 1217 |
1218 octave_value ov = dsub.tc; | |
1219 m.elem (i) = ov; | |
1220 | |
4687 | 1221 } |
1222 | |
1223 if (retval2 >= 0) | |
1224 { | |
1225 matrix = m; | |
1226 retval = true; | |
1227 } | |
1228 | |
1229 return retval; | |
1230 } | |
4815 | 1231 |
4687 | 1232 #endif |
1233 | |
3354 | 1234 DEFUN (iscell, args, , |
3448 | 1235 "-*- texinfo -*-\n\ |
1236 @deftypefn {Built-in Function} {} iscell (@var{x})\n\ | |
1237 Return true if @var{x} is a cell array object. Otherwise, return\n\ | |
1238 false.\n\ | |
1239 @end deftypefn") | |
3354 | 1240 { |
1241 octave_value retval; | |
1242 | |
1243 if (args.length () == 1) | |
1244 retval = args(0).is_cell (); | |
1245 else | |
5823 | 1246 print_usage (); |
3354 | 1247 |
1248 return retval; | |
1249 } | |
1250 | |
1251 DEFUN (cell, args, , | |
3448 | 1252 "-*- texinfo -*-\n\ |
10840 | 1253 @deftypefn {Built-in Function} {} cell (@var{x})\n\ |
3448 | 1254 @deftypefnx {Built-in Function} {} cell (@var{n}, @var{m})\n\ |
1255 Create a new cell array object. If invoked with a single scalar\n\ | |
1256 argument, @code{cell} returns a square cell array with the dimension\n\ | |
1257 specified. If you supply two scalar arguments, @code{cell} takes\n\ | |
1258 them to be the number of rows and columns. If given a vector with two\n\ | |
1259 elements, @code{cell} uses the values of the elements as the number of\n\ | |
1260 rows and columns, respectively.\n\ | |
1261 @end deftypefn") | |
3354 | 1262 { |
1263 octave_value retval; | |
1264 | |
1265 int nargin = args.length (); | |
1266 | |
4563 | 1267 dim_vector dims; |
1268 | |
3354 | 1269 switch (nargin) |
1270 { | |
4563 | 1271 case 0: |
1272 dims = dim_vector (0, 0); | |
3354 | 1273 break; |
1274 | |
4563 | 1275 case 1: |
1276 get_dimensions (args(0), "cell", dims); | |
3354 | 1277 break; |
1278 | |
1279 default: | |
4563 | 1280 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1281 dims.resize (nargin); |
4563 | 1282 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1283 for (int i = 0; i < nargin; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1284 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1285 dims(i) = args(i).is_empty () ? 0 : args(i).nint_value (); |
4563 | 1286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1287 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1288 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1289 error ("cell: expecting scalar arguments"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1290 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1291 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1292 } |
4563 | 1293 } |
3354 | 1294 break; |
1295 } | |
1296 | |
4563 | 1297 if (! error_state) |
1298 { | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1299 dims.chop_trailing_singletons (); |
4563 | 1300 |
1301 check_dimensions (dims, "cell"); | |
1302 | |
1303 if (! error_state) | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1304 retval = Cell (dims, Matrix ()); |
4563 | 1305 } |
1306 | |
3354 | 1307 return retval; |
1308 } | |
1309 | |
4610 | 1310 DEFUN (iscellstr, args, , |
1311 "-*- texinfo -*-\n\ | |
1312 @deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\ | |
1313 Return true if every element of the cell array @var{cell} is a\n\ | |
1314 character string\n\ | |
1315 @end deftypefn") | |
1316 { | |
4699 | 1317 octave_value retval; |
4610 | 1318 |
1319 if (args.length () == 1) | |
6116 | 1320 retval = args(0).is_cellstr (); |
4610 | 1321 else |
5823 | 1322 print_usage (); |
4610 | 1323 |
1324 return retval; | |
1325 } | |
1326 | |
4817 | 1327 // Note that since Fcellstr calls Fiscellstr, we need to have |
1328 // Fiscellstr defined first (to provide a declaration) and also we | |
1329 // should keep it in the same file (so we don't have to provide a | |
1330 // declaration) and so we don't have to use feval to call it. | |
1331 | |
1332 DEFUN (cellstr, args, , | |
1333 "-*- texinfo -*-\n\ | |
1334 @deftypefn {Built-in Function} {} cellstr (@var{string})\n\ | |
1335 Create a new cell array object from the elements of the string\n\ | |
1336 array @var{string}.\n\ | |
1337 @end deftypefn") | |
1338 { | |
1339 octave_value retval; | |
1340 | |
1341 if (args.length () == 1) | |
1342 { | |
1343 octave_value_list tmp = Fiscellstr (args, 1); | |
1344 | |
1345 if (tmp(0).is_true ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1346 retval = args(0); |
4817 | 1347 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1348 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1349 string_vector s = args(0).all_strings (); |
4817 | 1350 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1351 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1352 retval = (s.is_empty () |
7813 | 1353 ? Cell (octave_value (std::string ())) |
1354 : Cell (s, true)); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1355 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1356 error ("cellstr: expecting argument to be a 2-d character array"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1357 } |
4817 | 1358 } |
1359 else | |
5823 | 1360 print_usage (); |
4817 | 1361 |
1362 return retval; | |
1363 } | |
1364 | |
4762 | 1365 DEFUN (struct2cell, args, , |
1366 "-*- texinfo -*-\n\ | |
1367 @deftypefn {Built-in Function} {} struct2cell (@var{S})\n\ | |
1368 Create a new cell array from the objects stored in the struct object.\n\ | |
4764 | 1369 If @var{f} is the number of fields in the structure, the resulting\n\ |
1370 cell array will have a dimension vector corresponding to\n\ | |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10670
diff
changeset
|
1371 @code{[@var{F} size(@var{S})]}. For example:\n\ |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1372 \n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1373 @example\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1374 @group\n\ |
10600
036bdc2d0af0
Wrap documentation line to prevent overfull hbox LaTex warning
Rik <octave@nomad.inbox5.com>
parents:
10521
diff
changeset
|
1375 s = struct('name', @{'Peter', 'Hannah', 'Robert'@},\n\ |
036bdc2d0af0
Wrap documentation line to prevent overfull hbox LaTex warning
Rik <octave@nomad.inbox5.com>
parents:
10521
diff
changeset
|
1376 'age', @{23, 16, 3@});\n\ |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1377 c = struct2cell(s)\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1378 @result{} c = @{1x1x3 Cell Array@}\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1379 c(1,1,:)(:)\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1380 @result{} ans =\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1381 @{\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1382 [1,1] = Peter\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1383 [2,1] = Hannah\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1384 [3,1] = Robert\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1385 @}\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1386 c(2,1,:)(:)\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1387 @result{} ans =\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1388 @{\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1389 [1,1] = 23\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1390 [2,1] = 16\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1391 [3,1] = 3\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1392 @}\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1393 @end group\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1394 @end example\n\ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1395 \n\ |
5642 | 1396 @seealso{cell2struct, fieldnames}\n\ |
1397 @end deftypefn") | |
4762 | 1398 { |
1399 octave_value retval; | |
4764 | 1400 |
4762 | 1401 int nargin = args.length (); |
4764 | 1402 |
4762 | 1403 if (nargin == 1) |
1404 { | |
10772 | 1405 const octave_map m = args(0).map_value (); |
4764 | 1406 |
4762 | 1407 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1408 { |
10772 | 1409 const dim_vector m_dv = m.dims (); |
4764 | 1410 |
10772 | 1411 octave_idx_type num_fields = m.nfields (); |
4764 | 1412 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1413 // The resulting dim_vector should have dimensions: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1414 // [numel(fields) size(struct)] |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1415 // except if the struct is a column vector. |
4764 | 1416 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1417 dim_vector result_dv; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1418 if (m_dv (m_dv.length () - 1) == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1419 result_dv.resize (m_dv.length ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1420 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1421 result_dv.resize (m_dv.length () + 1); // Add 1 for the fields. |
4764 | 1422 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1423 result_dv(0) = num_fields; |
4762 | 1424 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1425 for (int i = 1; i < result_dv.length (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1426 result_dv(i) = m_dv(i-1); |
4764 | 1427 |
10772 | 1428 NoAlias<Cell> c (result_dv); |
4764 | 1429 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1430 octave_idx_type n_elts = m.numel (); |
4764 | 1431 |
10772 | 1432 // Fill c in one sweep. Note that thanks to octave_map structure, |
1433 // we don't need a key lookup at all. | |
1434 for (octave_idx_type j = 0; j < n_elts; j++) | |
1435 for (octave_idx_type i = 0; i < num_fields; i++) | |
1436 c(i,j) = m.contents(i)(j); | |
4762 | 1437 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1438 retval = c; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1439 } |
4762 | 1440 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1441 error ("struct2cell: expecting argument to be a cell array"); |
4762 | 1442 } |
1443 else | |
5823 | 1444 print_usage (); |
4764 | 1445 |
4762 | 1446 return retval; |
1447 } | |
1448 | |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1449 /* |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1450 %!test |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1451 %! keys = cellstr (char (floor (rand (11,10)*24+65)))'; |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1452 %! vals = cellfun(@(x) mat2cell(rand (19,1), ones (19,1), 1), ... |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1453 %! mat2cell([1:11]', ones(11,1), 1), "uniformoutput", false)'; |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1454 %! s = struct ([keys; vals]{:}); |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1455 %! t = cell2struct ([vals{:}], keys, 2); |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1456 %! assert (s, t); |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1457 %! assert (struct2cell (s), [vals{:}]'); |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1458 %! assert (fieldnames (s), keys'); |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1459 */ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10065
diff
changeset
|
1460 |
5900 | 1461 mxArray * |
1462 octave_cell::as_mxArray (void) const | |
1463 { | |
1464 mxArray *retval = new mxArray (dims ()); | |
1465 | |
1466 mxArray **elts = static_cast<mxArray **> (retval->get_data ()); | |
1467 | |
6686 | 1468 mwSize nel = numel (); |
5900 | 1469 |
1470 const octave_value *p = matrix.data (); | |
1471 | |
6686 | 1472 for (mwIndex i = 0; i < nel; i++) |
5900 | 1473 elts[i] = new mxArray (p[i]); |
1474 | |
1475 return retval; | |
1476 } | |
1477 | |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1478 octave_value |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1479 octave_cell::map (unary_mapper_t umap) const |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1480 { |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1481 switch (umap) |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1482 { |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1483 #define FORWARD_MAPPER(UMAP) \ |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1484 case umap_ ## UMAP: \ |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1485 return matrix.UMAP () |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1486 FORWARD_MAPPER (xisalnum); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1487 FORWARD_MAPPER (xisalpha); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1488 FORWARD_MAPPER (xisascii); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1489 FORWARD_MAPPER (xiscntrl); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1490 FORWARD_MAPPER (xisdigit); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1491 FORWARD_MAPPER (xisgraph); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1492 FORWARD_MAPPER (xislower); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1493 FORWARD_MAPPER (xisprint); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1494 FORWARD_MAPPER (xispunct); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1495 FORWARD_MAPPER (xisspace); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1496 FORWARD_MAPPER (xisupper); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1497 FORWARD_MAPPER (xisxdigit); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1498 FORWARD_MAPPER (xtoascii); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1499 FORWARD_MAPPER (xtolower); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1500 FORWARD_MAPPER (xtoupper); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1501 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1502 default: |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1503 return octave_base_value::map (umap); |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1504 } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9781
diff
changeset
|
1505 } |