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