Mercurial > octave
comparison libinterp/octave-value/ov-lazy-idx.cc @ 25287:f692728de113 stable
enable lazy index to numeric conversion (bug #53681)
* ov-lazy-idx.h, ov-lazy-idx.h (octave_lazy_index::as_double,
octave_lazy_index::as_single, octave_lazy_index::as_int8,
octave_lazy_index::as_int16, octave_lazy_index::as_int32,
octave_lazy_index::as_int64, octave_lazy_index::as_uint8,
octave_lazy_index::as_uint16, octave_lazy_index::as_uint32,
octave_lazy_index::as_uint64): New functions.
New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Apr 2018 14:32:37 -0400 |
parents | 6652d3823428 |
children | 00f796120a6d |
comparison
equal
deleted
inserted
replaced
25286:44c0aca121cc | 25287:f692728de113 |
---|---|
155 octave_lazy_index::is_sorted_rows (sortmode mode) const | 155 octave_lazy_index::is_sorted_rows (sortmode mode) const |
156 { | 156 { |
157 return index.as_array ().is_sorted_rows (mode); | 157 return index.as_array ().is_sorted_rows (mode); |
158 } | 158 } |
159 | 159 |
160 octave_value | |
161 octave_lazy_index::as_double (void) const | |
162 { | |
163 return array_value (); | |
164 } | |
165 | |
166 octave_value | |
167 octave_lazy_index::as_single (void) const | |
168 { | |
169 return float_array_value (); | |
170 } | |
171 | |
172 octave_value | |
173 octave_lazy_index::as_int8 (void) const | |
174 { | |
175 return int8_array_value (); | |
176 } | |
177 | |
178 octave_value | |
179 octave_lazy_index::as_int16 (void) const | |
180 { | |
181 return int16_array_value (); | |
182 } | |
183 | |
184 octave_value | |
185 octave_lazy_index::as_int32 (void) const | |
186 { | |
187 return int32_array_value (); | |
188 } | |
189 | |
190 octave_value | |
191 octave_lazy_index::as_int64 (void) const | |
192 { | |
193 return int64_array_value (); | |
194 } | |
195 | |
196 octave_value | |
197 octave_lazy_index::as_uint8 (void) const | |
198 { | |
199 return uint8_array_value (); | |
200 } | |
201 | |
202 octave_value | |
203 octave_lazy_index::as_uint16 (void) const | |
204 { | |
205 return uint16_array_value (); | |
206 } | |
207 | |
208 octave_value | |
209 octave_lazy_index::as_uint32 (void) const | |
210 { | |
211 return uint32_array_value (); | |
212 } | |
213 | |
214 octave_value | |
215 octave_lazy_index::as_uint64 (void) const | |
216 { | |
217 return uint64_array_value (); | |
218 } | |
219 | |
160 static const std::string value_save_tag ("index_value"); | 220 static const std::string value_save_tag ("index_value"); |
161 | 221 |
162 bool octave_lazy_index::save_ascii (std::ostream& os) | 222 bool octave_lazy_index::save_ascii (std::ostream& os) |
163 { | 223 { |
164 return save_text_data (os, make_value (), value_save_tag, false, 0); | 224 return save_text_data (os, make_value (), value_save_tag, false, 0); |
195 | 255 |
196 index = value.index_vector (); | 256 index = value.index_vector (); |
197 | 257 |
198 return true; | 258 return true; |
199 } | 259 } |
260 | |
261 /* | |
262 %!shared x, y | |
263 %! x = find ([-1, 0, -2, 1, 3, -4] < 0); | |
264 %! y = [1, 3, 6]; | |
265 %!assert (typeinfo (x), "lazy_index") | |
266 %!assert (double (x), y) | |
267 %!assert (single (x), single (y)) | |
268 %!assert (int8 (x), int8 (y)) | |
269 %!assert (int16 (x), int16 (y)) | |
270 %!assert (int32 (x), int32 (y)) | |
271 %!assert (int64 (x), int64 (y)) | |
272 %!assert (uint8 (x), uint8 (y)) | |
273 %!assert (uint16 (x), uint16 (y)) | |
274 %!assert (uint32 (x), uint32 (y)) | |
275 %!assert (uint64 (x), uint64 (y)) | |
276 */ |