Mercurial > octave-antonio
annotate src/ov.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | d08901c05c1b |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
4 Copyright (C) 2009-2010 VZLU Prague | |
2376 | 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. | |
2376 | 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/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
4970 | 28 #include "data-conv.h" |
29 #include "quit.h" | |
2942 | 30 #include "str-vec.h" |
2376 | 31 |
2974 | 32 #include "oct-obj.h" |
4944 | 33 #include "oct-stream.h" |
2376 | 34 #include "ov.h" |
35 #include "ov-base.h" | |
2825 | 36 #include "ov-bool.h" |
37 #include "ov-bool-mat.h" | |
3351 | 38 #include "ov-cell.h" |
2376 | 39 #include "ov-scalar.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
40 #include "ov-float.h" |
2376 | 41 #include "ov-re-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
42 #include "ov-flt-re-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
43 #include "ov-re-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
44 #include "ov-flt-re-diag.h" |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
45 #include "ov-perm.h" |
5164 | 46 #include "ov-bool-sparse.h" |
47 #include "ov-cx-sparse.h" | |
48 #include "ov-re-sparse.h" | |
4901 | 49 #include "ov-int8.h" |
50 #include "ov-int16.h" | |
51 #include "ov-int32.h" | |
52 #include "ov-int64.h" | |
53 #include "ov-uint8.h" | |
54 #include "ov-uint16.h" | |
55 #include "ov-uint32.h" | |
56 #include "ov-uint64.h" | |
2376 | 57 #include "ov-complex.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
58 #include "ov-flt-complex.h" |
2376 | 59 #include "ov-cx-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
60 #include "ov-flt-cx-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
61 #include "ov-cx-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
62 #include "ov-flt-cx-diag.h" |
2376 | 63 #include "ov-ch-mat.h" |
64 #include "ov-str-mat.h" | |
65 #include "ov-range.h" | |
66 #include "ov-struct.h" | |
7336 | 67 #include "ov-class.h" |
3977 | 68 #include "ov-cs-list.h" |
2376 | 69 #include "ov-colon.h" |
2974 | 70 #include "ov-builtin.h" |
4649 | 71 #include "ov-dld-fcn.h" |
2974 | 72 #include "ov-usr-fcn.h" |
4342 | 73 #include "ov-fcn-handle.h" |
4966 | 74 #include "ov-fcn-inline.h" |
2376 | 75 #include "ov-typeinfo.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
76 #include "ov-null-mat.h" |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
77 #include "ov-lazy-idx.h" |
2376 | 78 |
79 #include "defun.h" | |
2880 | 80 #include "error.h" |
2376 | 81 #include "gripes.h" |
82 #include "pager.h" | |
4005 | 83 #include "parse.h" |
2376 | 84 #include "pr-output.h" |
7336 | 85 #include "symtab.h" |
2376 | 86 #include "utils.h" |
87 #include "variables.h" | |
88 | |
2477 | 89 // We are likely to have a lot of octave_value objects to allocate, so |
90 // make the grow_size large. | |
3219 | 91 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); |
2477 | 92 |
5775 | 93 // FIXME |
2880 | 94 |
2376 | 95 // Octave's value type. |
96 | |
3536 | 97 std::string |
3203 | 98 octave_value::unary_op_as_string (unary_op op) |
99 { | |
3523 | 100 std::string retval; |
3203 | 101 |
102 switch (op) | |
103 { | |
3533 | 104 case op_not: |
3203 | 105 retval = "!"; |
106 break; | |
107 | |
4965 | 108 case op_uplus: |
109 retval = "+"; | |
110 break; | |
111 | |
3533 | 112 case op_uminus: |
3203 | 113 retval = "-"; |
114 break; | |
115 | |
3533 | 116 case op_transpose: |
3203 | 117 retval = ".'"; |
118 break; | |
119 | |
3533 | 120 case op_hermitian: |
3203 | 121 retval = "'"; |
122 break; | |
123 | |
3533 | 124 case op_incr: |
3203 | 125 retval = "++"; |
126 break; | |
127 | |
3533 | 128 case op_decr: |
3203 | 129 retval = "--"; |
130 break; | |
131 | |
132 default: | |
133 retval = "<unknown>"; | |
134 } | |
135 | |
136 return retval; | |
137 } | |
138 | |
3536 | 139 std::string |
7336 | 140 octave_value::unary_op_fcn_name (unary_op op) |
141 { | |
142 std::string retval; | |
143 | |
144 switch (op) | |
145 { | |
146 case op_not: | |
147 retval = "not"; | |
148 break; | |
149 | |
150 case op_uplus: | |
151 retval = "uplus"; | |
152 break; | |
153 | |
154 case op_uminus: | |
155 retval = "uminus"; | |
156 break; | |
157 | |
158 case op_transpose: | |
159 retval = "transpose"; | |
160 break; | |
161 | |
162 case op_hermitian: | |
163 retval = "ctranspose"; | |
164 break; | |
165 | |
166 default: | |
167 break; | |
168 } | |
169 | |
170 return retval; | |
171 } | |
172 | |
173 std::string | |
2376 | 174 octave_value::binary_op_as_string (binary_op op) |
175 { | |
3523 | 176 std::string retval; |
2376 | 177 |
178 switch (op) | |
179 { | |
3533 | 180 case op_add: |
2376 | 181 retval = "+"; |
182 break; | |
183 | |
3533 | 184 case op_sub: |
2376 | 185 retval = "-"; |
186 break; | |
187 | |
3533 | 188 case op_mul: |
2376 | 189 retval = "*"; |
190 break; | |
191 | |
3533 | 192 case op_div: |
2376 | 193 retval = "/"; |
194 break; | |
195 | |
3533 | 196 case op_pow: |
2376 | 197 retval = "^"; |
198 break; | |
199 | |
3533 | 200 case op_ldiv: |
2376 | 201 retval = "\\"; |
202 break; | |
203 | |
3533 | 204 case op_lshift: |
2903 | 205 retval = "<<"; |
206 break; | |
207 | |
3533 | 208 case op_rshift: |
2903 | 209 retval = ">>"; |
210 break; | |
211 | |
3533 | 212 case op_lt: |
2376 | 213 retval = "<"; |
214 break; | |
215 | |
3533 | 216 case op_le: |
2376 | 217 retval = "<="; |
218 break; | |
219 | |
3533 | 220 case op_eq: |
2376 | 221 retval = "=="; |
222 break; | |
223 | |
3533 | 224 case op_ge: |
2376 | 225 retval = ">="; |
226 break; | |
227 | |
3533 | 228 case op_gt: |
2376 | 229 retval = ">"; |
230 break; | |
231 | |
3533 | 232 case op_ne: |
2376 | 233 retval = "!="; |
234 break; | |
235 | |
3533 | 236 case op_el_mul: |
2376 | 237 retval = ".*"; |
238 break; | |
239 | |
3533 | 240 case op_el_div: |
2376 | 241 retval = "./"; |
242 break; | |
243 | |
3533 | 244 case op_el_pow: |
2376 | 245 retval = ".^"; |
246 break; | |
247 | |
3533 | 248 case op_el_ldiv: |
2376 | 249 retval = ".\\"; |
250 break; | |
251 | |
3533 | 252 case op_el_and: |
2376 | 253 retval = "&"; |
254 break; | |
255 | |
3533 | 256 case op_el_or: |
2376 | 257 retval = "|"; |
258 break; | |
259 | |
3533 | 260 case op_struct_ref: |
2376 | 261 retval = "."; |
262 break; | |
263 | |
264 default: | |
265 retval = "<unknown>"; | |
266 } | |
267 | |
268 return retval; | |
269 } | |
270 | |
3536 | 271 std::string |
7336 | 272 octave_value::binary_op_fcn_name (binary_op op) |
273 { | |
274 std::string retval; | |
275 | |
276 switch (op) | |
277 { | |
278 case op_add: | |
279 retval = "plus"; | |
280 break; | |
281 | |
282 case op_sub: | |
283 retval = "minus"; | |
284 break; | |
285 | |
286 case op_mul: | |
287 retval = "mtimes"; | |
288 break; | |
289 | |
290 case op_div: | |
291 retval = "mrdivide"; | |
292 break; | |
293 | |
294 case op_pow: | |
295 retval = "mpower"; | |
296 break; | |
297 | |
298 case op_ldiv: | |
299 retval = "mldivide"; | |
300 break; | |
301 | |
302 case op_lt: | |
303 retval = "lt"; | |
304 break; | |
305 | |
306 case op_le: | |
307 retval = "le"; | |
308 break; | |
309 | |
310 case op_eq: | |
311 retval = "eq"; | |
312 break; | |
313 | |
314 case op_ge: | |
315 retval = "ge"; | |
316 break; | |
317 | |
318 case op_gt: | |
319 retval = "gt"; | |
320 break; | |
321 | |
322 case op_ne: | |
323 retval = "ne"; | |
324 break; | |
325 | |
326 case op_el_mul: | |
327 retval = "times"; | |
328 break; | |
329 | |
330 case op_el_div: | |
331 retval = "rdivide"; | |
332 break; | |
333 | |
334 case op_el_pow: | |
335 retval = "power"; | |
336 break; | |
337 | |
338 case op_el_ldiv: | |
339 retval = "ldivide"; | |
340 break; | |
341 | |
342 case op_el_and: | |
343 retval = "and"; | |
344 break; | |
345 | |
346 case op_el_or: | |
347 retval = "or"; | |
348 break; | |
349 | |
350 default: | |
351 break; | |
352 } | |
353 | |
354 return retval; | |
355 } | |
356 | |
357 std::string | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
358 octave_value::binary_op_fcn_name (compound_binary_op op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
359 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
360 std::string retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
361 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
362 switch (op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
363 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
364 case op_trans_mul: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
365 retval = "transtimes"; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
366 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
367 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
368 case op_mul_trans: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
369 retval = "timestrans"; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
370 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
371 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
372 case op_herm_mul: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
373 retval = "hermtimes"; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
374 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
375 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
376 case op_mul_herm: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
377 retval = "timesherm"; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
378 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
379 |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
380 case op_trans_ldiv: |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
381 retval = "transldiv"; |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
382 break; |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
383 |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
384 case op_herm_ldiv: |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
385 retval = "hermldiv"; |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
386 break; |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
387 |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
388 case op_el_and_not: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
389 retval = "andnot"; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
390 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
391 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
392 case op_el_or_not: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
393 retval = "ornot"; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
394 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
395 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
396 case op_el_not_and: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
397 retval = "notand"; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
398 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
399 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
400 case op_el_not_or: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
401 retval = "notor"; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
402 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
403 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
404 default: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
405 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
406 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
407 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
408 return retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
409 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
410 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
411 std::string |
2880 | 412 octave_value::assign_op_as_string (assign_op op) |
413 { | |
3523 | 414 std::string retval; |
2880 | 415 |
416 switch (op) | |
417 { | |
3533 | 418 case op_asn_eq: |
2880 | 419 retval = "="; |
420 break; | |
421 | |
3533 | 422 case op_add_eq: |
2880 | 423 retval = "+="; |
424 break; | |
425 | |
3533 | 426 case op_sub_eq: |
2880 | 427 retval = "-="; |
428 break; | |
429 | |
3533 | 430 case op_mul_eq: |
2880 | 431 retval = "*="; |
432 break; | |
433 | |
3533 | 434 case op_div_eq: |
2880 | 435 retval = "/="; |
436 break; | |
437 | |
3533 | 438 case op_ldiv_eq: |
3204 | 439 retval = "\\="; |
440 break; | |
441 | |
4018 | 442 case op_pow_eq: |
443 retval = "^="; | |
444 break; | |
445 | |
3533 | 446 case op_lshift_eq: |
2903 | 447 retval = "<<="; |
448 break; | |
449 | |
3533 | 450 case op_rshift_eq: |
2903 | 451 retval = ">>="; |
452 break; | |
453 | |
3533 | 454 case op_el_mul_eq: |
2880 | 455 retval = ".*="; |
456 break; | |
457 | |
3533 | 458 case op_el_div_eq: |
2880 | 459 retval = "./="; |
460 break; | |
461 | |
3533 | 462 case op_el_ldiv_eq: |
3204 | 463 retval = ".\\="; |
464 break; | |
465 | |
4018 | 466 case op_el_pow_eq: |
467 retval = ".^="; | |
468 break; | |
469 | |
3533 | 470 case op_el_and_eq: |
2880 | 471 retval = "&="; |
472 break; | |
473 | |
3533 | 474 case op_el_or_eq: |
2880 | 475 retval = "|="; |
476 break; | |
477 | |
478 default: | |
479 retval = "<unknown>"; | |
480 } | |
481 | |
482 return retval; | |
483 } | |
484 | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
485 octave_value::assign_op |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
486 octave_value::binary_op_to_assign_op (binary_op op) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
487 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
488 assign_op retval; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
489 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
490 switch (op) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
491 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
492 case op_add: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
493 retval = op_add_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
494 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
495 case op_sub: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
496 retval = op_sub_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
497 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
498 case op_mul: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
499 retval = op_mul_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
500 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
501 case op_div: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
502 retval = op_div_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
503 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
504 case op_el_mul: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
505 retval = op_el_mul_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
506 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
507 case op_el_div: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
508 retval = op_el_div_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
509 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
510 case op_el_and: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
511 retval = op_el_and_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
512 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
513 case op_el_or: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
514 retval = op_el_or_eq; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
515 break; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
516 default: |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
517 retval = unknown_assign_op; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
518 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
519 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
520 return retval; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
521 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
522 |
4254 | 523 octave_value::octave_value (short int i) |
524 : rep (new octave_scalar (i)) | |
525 { | |
526 } | |
527 | |
528 octave_value::octave_value (unsigned short int i) | |
529 : rep (new octave_scalar (i)) | |
530 { | |
531 } | |
532 | |
4233 | 533 octave_value::octave_value (int i) |
534 : rep (new octave_scalar (i)) | |
535 { | |
536 } | |
537 | |
4254 | 538 octave_value::octave_value (unsigned int i) |
539 : rep (new octave_scalar (i)) | |
540 { | |
541 } | |
542 | |
543 octave_value::octave_value (long int i) | |
544 : rep (new octave_scalar (i)) | |
545 { | |
546 } | |
547 | |
548 octave_value::octave_value (unsigned long int i) | |
549 : rep (new octave_scalar (i)) | |
550 { | |
551 } | |
552 | |
4353 | 553 #if defined (HAVE_LONG_LONG_INT) |
554 octave_value::octave_value (long long int i) | |
555 : rep (new octave_scalar (i)) | |
556 { | |
557 } | |
558 #endif | |
559 | |
4355 | 560 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 561 octave_value::octave_value (unsigned long long int i) |
562 : rep (new octave_scalar (i)) | |
563 { | |
564 } | |
565 #endif | |
566 | |
4254 | 567 octave_value::octave_value (octave_time t) |
7065 | 568 : rep (new octave_scalar (t.double_value ())) |
4254 | 569 { |
570 } | |
571 | |
2376 | 572 octave_value::octave_value (double d) |
2825 | 573 : rep (new octave_scalar (d)) |
574 { | |
575 } | |
2376 | 576 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
577 octave_value::octave_value (float d) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
578 : rep (new octave_float_scalar (d)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
579 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
580 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
581 |
4587 | 582 octave_value::octave_value (const Cell& c, bool is_csl) |
5477 | 583 : rep (is_csl |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
584 ? dynamic_cast<octave_base_value *> (new octave_cs_list (c)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
585 : dynamic_cast<octave_base_value *> (new octave_cell (c))) |
3351 | 586 { |
587 } | |
588 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
589 octave_value::octave_value (const Array<octave_value>& a, bool is_csl) |
5477 | 590 : rep (is_csl |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
591 ? dynamic_cast<octave_base_value *> (new octave_cs_list (Cell (a))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
592 : dynamic_cast<octave_base_value *> (new octave_cell (Cell (a)))) |
5147 | 593 { |
594 } | |
595 | |
5785 | 596 octave_value::octave_value (const Matrix& m, const MatrixType& t) |
597 : rep (new octave_matrix (m, t)) | |
2423 | 598 { |
599 maybe_mutate (); | |
600 } | |
2376 | 601 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
602 octave_value::octave_value (const FloatMatrix& m, const MatrixType& t) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
603 : rep (new octave_float_matrix (m, t)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
604 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
605 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
606 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
607 |
4507 | 608 octave_value::octave_value (const NDArray& a) |
4513 | 609 : rep (new octave_matrix (a)) |
4478 | 610 { |
611 maybe_mutate (); | |
612 } | |
613 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
614 octave_value::octave_value (const FloatNDArray& a) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
615 : rep (new octave_float_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
616 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
617 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
618 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
619 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
620 octave_value::octave_value (const Array<double>& a) |
4911 | 621 : rep (new octave_matrix (a)) |
622 { | |
623 maybe_mutate (); | |
624 } | |
625 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
626 octave_value::octave_value (const Array<float>& a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
627 : rep (new octave_float_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
628 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
629 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
630 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
631 |
2376 | 632 octave_value::octave_value (const DiagMatrix& d) |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
633 : rep (new octave_diag_matrix (d)) |
2423 | 634 { |
635 maybe_mutate (); | |
636 } | |
2376 | 637 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
638 octave_value::octave_value (const FloatDiagMatrix& d) |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
639 : rep (new octave_float_diag_matrix (d)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
640 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
641 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
642 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
643 |
3418 | 644 octave_value::octave_value (const RowVector& v) |
645 : rep (new octave_matrix (v)) | |
2423 | 646 { |
647 maybe_mutate (); | |
648 } | |
2376 | 649 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
650 octave_value::octave_value (const FloatRowVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
651 : rep (new octave_float_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
652 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
653 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
654 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
655 |
3418 | 656 octave_value::octave_value (const ColumnVector& v) |
657 : rep (new octave_matrix (v)) | |
2423 | 658 { |
659 maybe_mutate (); | |
660 } | |
2376 | 661 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
662 octave_value::octave_value (const FloatColumnVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
663 : rep (new octave_float_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
664 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
665 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
666 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
667 |
2376 | 668 octave_value::octave_value (const Complex& C) |
2423 | 669 : rep (new octave_complex (C)) |
670 { | |
671 maybe_mutate (); | |
672 } | |
2376 | 673 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
674 octave_value::octave_value (const FloatComplex& C) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
675 : rep (new octave_float_complex (C)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
676 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
677 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
678 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
679 |
5785 | 680 octave_value::octave_value (const ComplexMatrix& m, const MatrixType& t) |
681 : rep (new octave_complex_matrix (m, t)) | |
2423 | 682 { |
683 maybe_mutate (); | |
684 } | |
2376 | 685 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
686 octave_value::octave_value (const FloatComplexMatrix& m, const MatrixType& t) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
687 : rep (new octave_float_complex_matrix (m, t)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
688 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
689 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
690 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
691 |
4513 | 692 octave_value::octave_value (const ComplexNDArray& a) |
693 : rep (new octave_complex_matrix (a)) | |
4478 | 694 { |
695 maybe_mutate (); | |
696 } | |
697 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
698 octave_value::octave_value (const FloatComplexNDArray& a) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
699 : rep (new octave_float_complex_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
700 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
701 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
702 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
703 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
704 octave_value::octave_value (const Array<Complex>& a) |
4911 | 705 : rep (new octave_complex_matrix (a)) |
706 { | |
707 maybe_mutate (); | |
708 } | |
709 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
710 octave_value::octave_value (const Array<FloatComplex>& a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
711 : rep (new octave_float_complex_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
712 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
713 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
714 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
715 |
2376 | 716 octave_value::octave_value (const ComplexDiagMatrix& d) |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
717 : rep (new octave_complex_diag_matrix (d)) |
2423 | 718 { |
719 maybe_mutate (); | |
720 } | |
2376 | 721 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
722 octave_value::octave_value (const FloatComplexDiagMatrix& d) |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
723 : rep (new octave_float_complex_diag_matrix (d)) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
724 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
725 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
726 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
727 |
3418 | 728 octave_value::octave_value (const ComplexRowVector& v) |
729 : rep (new octave_complex_matrix (v)) | |
2423 | 730 { |
731 maybe_mutate (); | |
732 } | |
2376 | 733 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
734 octave_value::octave_value (const FloatComplexRowVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
735 : rep (new octave_float_complex_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
736 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
737 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
738 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
739 |
3418 | 740 octave_value::octave_value (const ComplexColumnVector& v) |
741 : rep (new octave_complex_matrix (v)) | |
2423 | 742 { |
743 maybe_mutate (); | |
744 } | |
2376 | 745 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
746 octave_value::octave_value (const FloatComplexColumnVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
747 : rep (new octave_float_complex_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
748 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
749 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
750 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
751 |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
752 octave_value::octave_value (const PermMatrix& p) |
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
753 : rep (new octave_perm_matrix (p)) |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
754 { |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
755 maybe_mutate (); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
756 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
757 |
2825 | 758 octave_value::octave_value (bool b) |
759 : rep (new octave_bool (b)) | |
760 { | |
761 } | |
762 | |
5785 | 763 octave_value::octave_value (const boolMatrix& bm, const MatrixType& t) |
764 : rep (new octave_bool_matrix (bm, t)) | |
2825 | 765 { |
766 maybe_mutate (); | |
767 } | |
768 | |
4513 | 769 octave_value::octave_value (const boolNDArray& bnda) |
770 : rep (new octave_bool_matrix (bnda)) | |
771 { | |
772 maybe_mutate (); | |
773 } | |
774 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
775 octave_value::octave_value (const Array<bool>& bnda) |
7433 | 776 : rep (new octave_bool_matrix (bnda)) |
777 { | |
778 maybe_mutate (); | |
779 } | |
780 | |
5279 | 781 octave_value::octave_value (char c, char type) |
782 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
783 ? new octave_char_matrix_dq_str (c) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
784 : new octave_char_matrix_sq_str (c)) |
3189 | 785 { |
786 maybe_mutate (); | |
787 } | |
788 | |
5279 | 789 octave_value::octave_value (const char *s, char type) |
790 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
791 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
792 : new octave_char_matrix_sq_str (s)) |
2423 | 793 { |
794 maybe_mutate (); | |
795 } | |
2376 | 796 |
5279 | 797 octave_value::octave_value (const std::string& s, char type) |
798 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
799 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
800 : new octave_char_matrix_sq_str (s)) |
2423 | 801 { |
802 maybe_mutate (); | |
803 } | |
2376 | 804 |
5279 | 805 octave_value::octave_value (const string_vector& s, char type) |
806 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
807 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
808 : new octave_char_matrix_sq_str (s)) |
2423 | 809 { |
810 maybe_mutate (); | |
811 } | |
2376 | 812 |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
813 octave_value::octave_value (const charMatrix& chm, char type) |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
814 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
815 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
816 : new octave_char_matrix_sq_str (chm)) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
817 { |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
818 maybe_mutate (); |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
819 } |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
820 |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
821 octave_value::octave_value (const charNDArray& chm, char type) |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
822 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
823 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
824 : new octave_char_matrix_sq_str (chm)) |
2409 | 825 { |
4513 | 826 maybe_mutate (); |
827 } | |
2376 | 828 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
829 octave_value::octave_value (const Array<char>& chm, char type) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
830 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
831 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
832 : new octave_char_matrix_sq_str (chm)) |
4513 | 833 { |
2423 | 834 maybe_mutate (); |
2409 | 835 } |
2376 | 836 |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
837 octave_value::octave_value (const charMatrix& chm, bool, char type) |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
838 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
839 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
840 : new octave_char_matrix_sq_str (chm)) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
841 { |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
842 maybe_mutate (); |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
843 } |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
844 |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
845 octave_value::octave_value (const charNDArray& chm, bool, char type) |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
846 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
847 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
848 : new octave_char_matrix_sq_str (chm)) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
849 { |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
850 maybe_mutate (); |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
851 } |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
852 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
853 octave_value::octave_value (const Array<char>& chm, bool, char type) |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
854 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
855 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
856 : new octave_char_matrix_sq_str (chm)) |
4997 | 857 { |
858 maybe_mutate (); | |
859 } | |
860 | |
5785 | 861 octave_value::octave_value (const SparseMatrix& m, const MatrixType &t) |
5164 | 862 : rep (new octave_sparse_matrix (m, t)) |
863 { | |
864 maybe_mutate (); | |
865 } | |
866 | |
6863 | 867 octave_value::octave_value (const Sparse<double>& m, const MatrixType &t) |
868 : rep (new octave_sparse_matrix (m, t)) | |
869 { | |
870 maybe_mutate (); | |
871 } | |
872 | |
5785 | 873 octave_value::octave_value (const SparseComplexMatrix& m, const MatrixType &t) |
5164 | 874 : rep (new octave_sparse_complex_matrix (m, t)) |
875 { | |
876 maybe_mutate (); | |
877 } | |
878 | |
6863 | 879 octave_value::octave_value (const Sparse<Complex>& m, const MatrixType &t) |
880 : rep (new octave_sparse_complex_matrix (m, t)) | |
881 { | |
882 maybe_mutate (); | |
883 } | |
884 | |
5785 | 885 octave_value::octave_value (const SparseBoolMatrix& bm, const MatrixType &t) |
5164 | 886 : rep (new octave_sparse_bool_matrix (bm, t)) |
887 { | |
888 maybe_mutate (); | |
889 } | |
890 | |
7433 | 891 octave_value::octave_value (const Sparse<bool>& bm, const MatrixType &t) |
892 : rep (new octave_sparse_bool_matrix (bm, t)) | |
893 { | |
894 maybe_mutate (); | |
895 } | |
896 | |
4901 | 897 octave_value::octave_value (const octave_int8& i) |
898 : rep (new octave_int8_scalar (i)) | |
899 { | |
900 maybe_mutate (); | |
901 } | |
902 | |
903 octave_value::octave_value (const octave_uint8& i) | |
904 : rep (new octave_uint8_scalar (i)) | |
905 { | |
906 maybe_mutate (); | |
907 } | |
908 | |
909 octave_value::octave_value (const octave_int16& i) | |
910 : rep (new octave_int16_scalar (i)) | |
911 { | |
912 maybe_mutate (); | |
913 } | |
914 | |
915 octave_value::octave_value (const octave_uint16& i) | |
916 : rep (new octave_uint16_scalar (i)) | |
917 { | |
918 maybe_mutate (); | |
919 } | |
920 | |
921 octave_value::octave_value (const octave_int32& i) | |
922 : rep (new octave_int32_scalar (i)) | |
923 { | |
924 maybe_mutate (); | |
925 } | |
926 | |
927 octave_value::octave_value (const octave_uint32& i) | |
928 : rep (new octave_uint32_scalar (i)) | |
929 { | |
930 maybe_mutate (); | |
931 } | |
932 | |
933 octave_value::octave_value (const octave_int64& i) | |
934 : rep (new octave_int64_scalar (i)) | |
935 { | |
936 maybe_mutate (); | |
937 } | |
938 | |
939 octave_value::octave_value (const octave_uint64& i) | |
940 : rep (new octave_uint64_scalar (i)) | |
941 { | |
942 maybe_mutate (); | |
943 } | |
944 | |
945 octave_value::octave_value (const int8NDArray& inda) | |
946 : rep (new octave_int8_matrix (inda)) | |
947 { | |
948 maybe_mutate (); | |
949 } | |
950 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
951 octave_value::octave_value (const Array<octave_int8>& inda) |
7064 | 952 : rep (new octave_int8_matrix (inda)) |
953 { | |
954 maybe_mutate (); | |
955 } | |
956 | |
4901 | 957 octave_value::octave_value (const uint8NDArray& inda) |
958 : rep (new octave_uint8_matrix (inda)) | |
959 { | |
960 maybe_mutate (); | |
961 } | |
962 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
963 octave_value::octave_value (const Array<octave_uint8>& inda) |
7064 | 964 : rep (new octave_uint8_matrix (inda)) |
965 { | |
966 maybe_mutate (); | |
967 } | |
968 | |
4901 | 969 octave_value::octave_value (const int16NDArray& inda) |
970 : rep (new octave_int16_matrix (inda)) | |
971 { | |
972 maybe_mutate (); | |
973 } | |
974 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
975 octave_value::octave_value (const Array<octave_int16>& inda) |
7064 | 976 : rep (new octave_int16_matrix (inda)) |
977 { | |
978 maybe_mutate (); | |
979 } | |
980 | |
4901 | 981 octave_value::octave_value (const uint16NDArray& inda) |
982 : rep (new octave_uint16_matrix (inda)) | |
983 { | |
984 maybe_mutate (); | |
985 } | |
986 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
987 octave_value::octave_value (const Array<octave_uint16>& inda) |
7064 | 988 : rep (new octave_uint16_matrix (inda)) |
989 { | |
990 maybe_mutate (); | |
991 } | |
992 | |
4901 | 993 octave_value::octave_value (const int32NDArray& inda) |
994 : rep (new octave_int32_matrix (inda)) | |
995 { | |
996 maybe_mutate (); | |
997 } | |
998 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
999 octave_value::octave_value (const Array<octave_int32>& inda) |
7064 | 1000 : rep (new octave_int32_matrix (inda)) |
1001 { | |
1002 maybe_mutate (); | |
1003 } | |
1004 | |
4901 | 1005 octave_value::octave_value (const uint32NDArray& inda) |
1006 : rep (new octave_uint32_matrix (inda)) | |
1007 { | |
1008 maybe_mutate (); | |
1009 } | |
1010 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
1011 octave_value::octave_value (const Array<octave_uint32>& inda) |
7064 | 1012 : rep (new octave_uint32_matrix (inda)) |
1013 { | |
1014 maybe_mutate (); | |
1015 } | |
1016 | |
4901 | 1017 octave_value::octave_value (const int64NDArray& inda) |
1018 : rep (new octave_int64_matrix (inda)) | |
1019 { | |
1020 maybe_mutate (); | |
1021 } | |
1022 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
1023 octave_value::octave_value (const Array<octave_int64>& inda) |
7064 | 1024 : rep (new octave_int64_matrix (inda)) |
1025 { | |
1026 maybe_mutate (); | |
1027 } | |
1028 | |
4901 | 1029 octave_value::octave_value (const uint64NDArray& inda) |
1030 : rep (new octave_uint64_matrix (inda)) | |
1031 { | |
1032 maybe_mutate (); | |
1033 } | |
1034 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
1035 octave_value::octave_value (const Array<octave_uint64>& inda) |
7064 | 1036 : rep (new octave_uint64_matrix (inda)) |
1037 { | |
1038 maybe_mutate (); | |
1039 } | |
1040 | |
9351
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1041 octave_value::octave_value (const Array<octave_idx_type>& inda, bool zero_based, |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1042 bool cache_index) |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1043 : rep (new octave_matrix (inda, zero_based, cache_index)) |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1044 { |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1045 maybe_mutate (); |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1046 } |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1047 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1048 octave_value::octave_value (const idx_vector& idx, bool lazy) |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1049 : rep () |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1050 { |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1051 double scalar; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1052 Range range; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1053 NDArray array; |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1054 boolNDArray mask; |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1055 idx_vector::idx_class_type idx_class; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1056 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1057 if (lazy) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1058 { |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1059 // Only make lazy indices out of ranges and index vectors. |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1060 switch (idx.idx_class ()) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1061 { |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1062 case idx_vector::class_range: |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1063 case idx_vector::class_vector: |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1064 rep = new octave_lazy_index (idx); |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1065 maybe_mutate (); |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1066 return; |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1067 default: |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1068 break; |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1069 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1070 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1071 |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1072 idx.unconvert (idx_class, scalar, range, array, mask); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1073 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1074 switch (idx_class) |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1075 { |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1076 case idx_vector::class_colon: |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1077 rep = new octave_magic_colon (); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1078 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1079 case idx_vector::class_range: |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1080 rep = new octave_range (range, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1081 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1082 case idx_vector::class_scalar: |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1083 rep = new octave_scalar (scalar); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1084 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1085 case idx_vector::class_vector: |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1086 rep = new octave_matrix (array, idx); |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1087 break; |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1088 case idx_vector::class_mask: |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1089 rep = new octave_bool_matrix (mask, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1090 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1091 default: |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1092 assert (false); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1093 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1094 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1095 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1096 // FIXME: needed? |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1097 maybe_mutate (); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1098 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1099 |
9725 | 1100 octave_value::octave_value (const Array<std::string>& cellstr) |
1101 : rep (new octave_cell (cellstr)) | |
1102 { | |
1103 maybe_mutate (); | |
1104 } | |
1105 | |
2376 | 1106 octave_value::octave_value (double base, double limit, double inc) |
2423 | 1107 : rep (new octave_range (base, limit, inc)) |
1108 { | |
1109 maybe_mutate (); | |
1110 } | |
2376 | 1111 |
1112 octave_value::octave_value (const Range& r) | |
2423 | 1113 : rep (new octave_range (r)) |
1114 { | |
1115 maybe_mutate (); | |
1116 } | |
2376 | 1117 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1118 octave_value::octave_value (const octave_map& m) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1119 : rep (new octave_struct (m)) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1120 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1121 maybe_mutate (); |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1122 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1123 |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1124 octave_value::octave_value (const octave_scalar_map& m) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1125 : rep (new octave_scalar_struct (m)) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1126 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1127 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1128 |
2376 | 1129 octave_value::octave_value (const Octave_map& m) |
2825 | 1130 : rep (new octave_struct (m)) |
1131 { | |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1132 maybe_mutate (); |
2880 | 1133 } |
1134 | |
7336 | 1135 octave_value::octave_value (const Octave_map& m, const std::string& id) |
1136 : rep (new octave_class (m, id)) | |
1137 { | |
1138 } | |
1139 | |
10232
0efd486813fe
remove deprecated list datatype
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1140 octave_value::octave_value (const octave_value_list& l, bool) |
0efd486813fe
remove deprecated list datatype
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
1141 : rep (new octave_cs_list (l)) |
2880 | 1142 { |
1143 } | |
2376 | 1144 |
1145 octave_value::octave_value (octave_value::magic_colon) | |
2825 | 1146 : rep (new octave_magic_colon ()) |
1147 { | |
1148 } | |
2376 | 1149 |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1150 octave_value::octave_value (octave_base_value *new_rep, bool borrow) |
2825 | 1151 : rep (new_rep) |
1152 { | |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1153 if (borrow) |
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1154 rep->count++; |
2825 | 1155 } |
2376 | 1156 |
7336 | 1157 octave_value::octave_value (octave_base_value *new_rep, int xcount) |
1158 : rep (new_rep) | |
1159 { | |
1160 rep->count = xcount; | |
1161 } | |
1162 | |
5759 | 1163 octave_base_value * |
3933 | 1164 octave_value::clone (void) const |
2880 | 1165 { |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1166 return rep->clone (); |
2880 | 1167 } |
1168 | |
2409 | 1169 void |
1170 octave_value::maybe_mutate (void) | |
1171 { | |
5759 | 1172 octave_base_value *tmp = rep->try_narrowing_conversion (); |
2409 | 1173 |
1174 if (tmp && tmp != rep) | |
1175 { | |
1176 if (--rep->count == 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1177 delete rep; |
2409 | 1178 |
1179 rep = tmp; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1180 } |
2409 | 1181 } |
1182 | |
4247 | 1183 octave_value |
4271 | 1184 octave_value::single_subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1185 const octave_value_list& idx) |
4247 | 1186 { |
1187 std::list<octave_value_list> i; | |
1188 | |
1189 i.push_back (idx); | |
1190 | |
1191 return rep->subsref (type, i); | |
1192 } | |
1193 | |
2974 | 1194 octave_value_list |
4247 | 1195 octave_value::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1196 const std::list<octave_value_list>& idx, int nargout) |
3933 | 1197 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1198 if (nargout == 1) |
3933 | 1199 return rep->subsref (type, idx); |
1200 else | |
1201 return rep->subsref (type, idx, nargout); | |
1202 } | |
1203 | |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1204 octave_value_list |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1205 octave_value::subsref (const std::string& type, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1206 const std::list<octave_value_list>& idx, int nargout, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1207 const std::list<octave_lvalue> *lvalue_list) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1208 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1209 if (lvalue_list) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1210 return rep->subsref (type, idx, nargout, lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1211 else |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1212 return subsref (type, idx, nargout); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1213 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1214 |
3933 | 1215 octave_value |
4247 | 1216 octave_value::next_subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1217 const std::list<octave_value_list>& idx, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1218 size_t skip) |
3933 | 1219 { |
4582 | 1220 if (! error_state && idx.size () > skip) |
3933 | 1221 { |
4219 | 1222 std::list<octave_value_list> new_idx (idx); |
4233 | 1223 for (size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1224 new_idx.erase (new_idx.begin ()); |
3933 | 1225 return subsref (type.substr (skip), new_idx); |
1226 } | |
1227 else | |
1228 return *this; | |
1229 } | |
1230 | |
1231 octave_value_list | |
4994 | 1232 octave_value::next_subsref (int nargout, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1233 const std::list<octave_value_list>& idx, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1234 size_t skip) |
4994 | 1235 { |
1236 if (! error_state && idx.size () > skip) | |
1237 { | |
1238 std::list<octave_value_list> new_idx (idx); | |
1239 for (size_t i = 0; i < skip; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1240 new_idx.erase (new_idx.begin ()); |
4994 | 1241 return subsref (type.substr (skip), new_idx, nargout); |
1242 } | |
1243 else | |
1244 return *this; | |
1245 } | |
1246 | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1247 octave_value |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1248 octave_value::next_subsref (bool auto_add, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1249 const std::list<octave_value_list>& idx, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1250 size_t skip) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1251 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1252 if (! error_state && idx.size () > skip) |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1253 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1254 std::list<octave_value_list> new_idx (idx); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1255 for (size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1256 new_idx.erase (new_idx.begin ()); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1257 return subsref (type.substr (skip), new_idx, auto_add); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1258 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1259 else |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1260 return *this; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1261 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1262 |
4994 | 1263 octave_value_list |
3544 | 1264 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx) |
2974 | 1265 { |
3544 | 1266 return rep->do_multi_index_op (nargout, idx); |
2974 | 1267 } |
1268 | |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1269 octave_value_list |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1270 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1271 const std::list<octave_lvalue> *lvalue_list) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1272 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1273 return rep->do_multi_index_op (nargout, idx, lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1274 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10768
diff
changeset
|
1275 |
3933 | 1276 #if 0 |
3204 | 1277 static void |
3933 | 1278 gripe_assign_failed (const std::string& on, const std::string& tn1, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1279 const std::string& tn2) |
3204 | 1280 { |
1281 error ("assignment failed for `%s %s %s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1282 tn1.c_str (), on.c_str (), tn2.c_str ()); |
3204 | 1283 } |
3933 | 1284 #endif |
3204 | 1285 |
1286 static void | |
3933 | 1287 gripe_assign_failed_or_no_method (const std::string& on, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1288 const std::string& tn1, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1289 const std::string& tn2) |
3204 | 1290 { |
1291 error ("assignment failed, or no method for `%s %s %s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1292 tn1.c_str (), on.c_str (), tn2.c_str ()); |
3204 | 1293 } |
1294 | |
3933 | 1295 octave_value |
4247 | 1296 octave_value::subsasgn (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1297 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1298 const octave_value& rhs) |
3933 | 1299 { |
1300 return rep->subsasgn (type, idx, rhs); | |
1301 } | |
1302 | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1303 octave_value& |
4247 | 1304 octave_value::assign (assign_op op, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1305 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1306 const octave_value& rhs) |
3933 | 1307 { |
1308 octave_value retval; | |
1309 | |
1310 make_unique (); | |
1311 | |
1312 octave_value t_rhs = rhs; | |
1313 | |
1314 if (op != op_asn_eq) | |
1315 { | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1316 if (is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1317 { |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1318 octave_value t = subsref (type, idx); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1319 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1320 if (! error_state) |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1321 { |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1322 binary_op binop = op_eq_to_binary_op (op); |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1323 |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1324 if (! error_state) |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1325 t_rhs = do_binary_op (binop, t, rhs); |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1326 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1327 } |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1328 else |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1329 error ("in computed assignment A(index) OP= X, A must be defined first"); |
3933 | 1330 } |
1331 | |
1332 if (! error_state) | |
1333 { | |
10871
333bf09e3b6e
only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
10832
diff
changeset
|
1334 octave_value tmp = subsasgn (type, idx, t_rhs); |
9693
1c19877799d3
improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
1335 |
1c19877799d3
improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
1336 if (error_state) |
1c19877799d3
improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
1337 gripe_assign_failed_or_no_method (assign_op_as_string (op_asn_eq), |
1c19877799d3
improve error reports for computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9690
diff
changeset
|
1338 type_name (), rhs.type_name ()); |
10871
333bf09e3b6e
only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
10832
diff
changeset
|
1339 else |
333bf09e3b6e
only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
10832
diff
changeset
|
1340 *this = tmp; |
3933 | 1341 } |
1342 | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1343 return *this; |
3933 | 1344 } |
1345 | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1346 octave_value& |
3203 | 1347 octave_value::assign (assign_op op, const octave_value& rhs) |
2880 | 1348 { |
3533 | 1349 if (op == op_asn_eq) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1350 // Regularize a null matrix if stored into a variable. |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1351 operator = (rhs.storable_value ()); |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1352 else if (is_defined ()) |
3203 | 1353 { |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1354 octave_value_typeinfo::assign_op_fcn f = 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1355 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1356 // Only attempt to operate in-place if this variable is unshared. |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1357 if (rep->count == 1) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1358 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1359 int tthis = this->type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1360 int trhs = rhs.type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1361 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1362 f = octave_value_typeinfo::lookup_assign_op (op, tthis, trhs); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1363 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1364 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1365 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1366 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1367 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1368 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1369 f (*rep, octave_value_list (), *rhs.rep); |
9608
1c76e806c2a7
possibly mutate after in-place computed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
9607
diff
changeset
|
1370 maybe_mutate (); // Usually unnecessary, but may be needed (complex arrays). |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1371 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1372 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1373 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1374 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1375 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1376 } |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1377 else |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1378 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1379 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1380 binary_op binop = op_eq_to_binary_op (op); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1381 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1382 if (! error_state) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1383 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1384 octave_value t = do_binary_op (binop, *this, rhs); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1385 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1386 if (! error_state) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1387 operator = (t); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1388 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1389 } |
3204 | 1390 } |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1391 else |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1392 error ("in computed assignment A OP= X, A must be defined first"); |
3204 | 1393 |
3933 | 1394 return *this; |
2376 | 1395 } |
1396 | |
5275 | 1397 octave_idx_type |
4563 | 1398 octave_value::length (void) const |
1399 { | |
10654
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1400 octave_idx_type retval = 0; |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1401 |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1402 const dim_vector dv = dims (); |
4584 | 1403 |
4563 | 1404 for (int i = 0; i < dv.length (); i++) |
1405 { | |
4584 | 1406 if (dv(i) == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1407 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1408 retval = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1409 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1410 } |
4584 | 1411 |
4563 | 1412 if (dv(i) > retval) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1413 retval = dv(i); |
4563 | 1414 } |
1415 | |
1416 return retval; | |
1417 } | |
1418 | |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1419 bool |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1420 octave_value::is_equal (const octave_value& test) const |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1421 { |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1422 bool retval = false; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1423 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1424 // If there is no op_eq for these types, we can't compare values. |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1425 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1426 if (rows () == test.rows () && columns () == test.columns ()) |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1427 { |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1428 octave_value tmp = do_binary_op (octave_value::op_eq, *this, test); |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1429 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1430 // Empty array also means a match. |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1431 if (! error_state && tmp.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1432 retval = tmp.is_true () || tmp.is_empty (); |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1433 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1434 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1435 return retval; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1436 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1437 |
3351 | 1438 Cell |
1439 octave_value::cell_value (void) const | |
1440 { | |
1441 return rep->cell_value (); | |
1442 } | |
1443 | |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1444 // Define the idx_type_value function here instead of in ov.h to avoid |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1445 // needing definitions for the SIZEOF_X macros in ov.h. |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1446 |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1447 octave_idx_type |
8024
dc36eb214129
ov.cc (octave_value::idx_type_value): don't include default argument value in definition
John W. Eaton <jwe@octave.org>
parents:
8017
diff
changeset
|
1448 octave_value::idx_type_value (bool req_int, bool frc_str_conv) const |
8017
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1449 { |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1450 #if SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_LONG |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1451 return long_value (req_int, frc_str_conv); |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1452 #elif SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_INT |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1453 return int_value (req_int, frc_str_conv); |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1454 #else |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1455 #error "no octave_value extractor for octave_idx_type" |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1456 #endif |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1457 } |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1458 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1459 octave_map |
2376 | 1460 octave_value::map_value (void) const |
1461 { | |
1462 return rep->map_value (); | |
1463 } | |
1464 | |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1465 octave_scalar_map |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1466 octave_value::scalar_map_value (void) const |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1467 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1468 return rep->scalar_map_value (); |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1469 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1470 |
2974 | 1471 octave_function * |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1472 octave_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1473 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1474 return rep->function_value (silent); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1475 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1476 |
4700 | 1477 octave_user_function * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1478 octave_value::user_function_value (bool silent) const |
4700 | 1479 { |
1480 return rep->user_function_value (silent); | |
1481 } | |
1482 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1483 octave_user_script * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1484 octave_value::user_script_value (bool silent) const |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1485 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1486 return rep->user_script_value (silent); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1487 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1488 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1489 octave_user_code * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1490 octave_value::user_code_value (bool silent) const |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1491 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1492 return rep->user_code_value (silent); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1493 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
1494 |
4346 | 1495 octave_fcn_handle * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1496 octave_value::fcn_handle_value (bool silent) const |
4343 | 1497 { |
1498 return rep->fcn_handle_value (silent); | |
1499 } | |
1500 | |
4933 | 1501 octave_fcn_inline * |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
1502 octave_value::fcn_inline_value (bool silent) const |
4933 | 1503 { |
1504 return rep->fcn_inline_value (silent); | |
1505 } | |
1506 | |
2880 | 1507 octave_value_list |
1508 octave_value::list_value (void) const | |
1509 { | |
1510 return rep->list_value (); | |
1511 } | |
1512 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1513 static dim_vector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1514 make_vector_dims (const dim_vector& dv, bool force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1515 const std::string& my_type, const std::string& wanted_type) |
3419 | 1516 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1517 dim_vector retval (dv); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1518 retval.chop_trailing_singletons (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1519 octave_idx_type nel = dv.numel (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1520 |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1521 if (retval.length () > 2 || (retval(0) != 1 && retval(1) != 1)) |
3419 | 1522 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1523 if (!force_vector_conversion) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1524 gripe_implicit_conversion ("Octave:array-as-vector", |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1525 my_type.c_str (), wanted_type.c_str ()); |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10325
diff
changeset
|
1526 retval = dim_vector (nel, 1); |
3419 | 1527 } |
1528 | |
1529 return retval; | |
1530 } | |
1531 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1532 ColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1533 octave_value::column_vector_value (bool force_string_conv, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1534 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1535 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1536 return ColumnVector (vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1537 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1538 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1539 |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1540 ComplexColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1541 octave_value::complex_column_vector_value (bool force_string_conv, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1542 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1543 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1544 return ComplexColumnVector (complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1545 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1546 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1547 |
3419 | 1548 RowVector |
1549 octave_value::row_vector_value (bool force_string_conv, | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1550 bool frc_vec_conv) const |
3419 | 1551 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1552 return RowVector (vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1553 frc_vec_conv)); |
3419 | 1554 } |
1555 | |
1556 ComplexRowVector | |
1557 octave_value::complex_row_vector_value (bool force_string_conv, | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1558 bool frc_vec_conv) const |
3419 | 1559 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1560 return ComplexRowVector (complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1561 frc_vec_conv)); |
3419 | 1562 } |
1563 | |
1564 Array<double> | |
2376 | 1565 octave_value::vector_value (bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1566 bool force_vector_conversion) const |
2376 | 1567 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1568 Array<double> retval = array_value (force_string_conv); |
2376 | 1569 |
1570 if (error_state) | |
1571 return retval; | |
1572 else | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1573 return retval.reshape (make_vector_dims (retval.dims (), |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1574 force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1575 type_name (), "real vector")); |
2376 | 1576 } |
1577 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1578 template <class T> |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1579 static Array<int> |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1580 convert_to_int_array (const Array<octave_int<T> >& A) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1581 { |
7999 | 1582 Array<int> retval (A.dims ()); |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1583 octave_idx_type n = A.numel (); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1584 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1585 for (octave_idx_type i = 0; i < n; i++) |
7999 | 1586 retval.xelem (i) = octave_int<int> (A.xelem (i)); |
8039
cd90e2842080
Add additional integer math and conversion warnings, set their default state to be off and add the intwarning function
David Bateman <dbateman@free.fr>
parents:
8024
diff
changeset
|
1587 |
7999 | 1588 return retval; |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1589 } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1590 |
4044 | 1591 Array<int> |
1592 octave_value::int_vector_value (bool force_string_conv, bool require_int, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1593 bool force_vector_conversion) const |
4044 | 1594 { |
1595 Array<int> retval; | |
1596 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1597 if (is_integer_type ()) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1598 { |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1599 if (is_int32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1600 retval = convert_to_int_array (int32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1601 else if (is_int64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1602 retval = convert_to_int_array (int64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1603 else if (is_int16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1604 retval = convert_to_int_array (int16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1605 else if (is_int8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1606 retval = convert_to_int_array (int8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1607 else if (is_uint32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1608 retval = convert_to_int_array (uint32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1609 else if (is_uint64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1610 retval = convert_to_int_array (uint64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1611 else if (is_uint16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1612 retval = convert_to_int_array (uint16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1613 else if (is_uint8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1614 retval = convert_to_int_array (uint8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1615 else |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1616 retval = array_value (force_string_conv); |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1617 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1618 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1619 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1620 const NDArray a = array_value (force_string_conv); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1621 if (! error_state) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1622 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1623 if (require_int) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1624 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1625 retval.resize (a.dims ()); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1626 for (octave_idx_type i = 0; i < a.numel (); i++) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1627 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1628 double ai = a.elem (i); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1629 int v = static_cast<int> (ai); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1630 if (ai == v) |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1631 retval.xelem (i) = v; |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1632 else |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1633 { |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
1634 error_with_cfn ("conversion to integer value failed"); |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1635 break; |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1636 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1637 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1638 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1639 else |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1640 retval = Array<int> (a); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1641 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1642 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1643 |
4044 | 1644 |
1645 if (error_state) | |
1646 return retval; | |
1647 else | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1648 return retval.reshape (make_vector_dims (retval.dims (), |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1649 force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1650 type_name (), "integer vector")); |
4044 | 1651 } |
1652 | |
8811 | 1653 template <class T> |
1654 static Array<octave_idx_type> | |
1655 convert_to_octave_idx_type_array (const Array<octave_int<T> >& A) | |
1656 { | |
1657 Array<octave_idx_type> retval (A.dims ()); | |
1658 octave_idx_type n = A.numel (); | |
1659 | |
1660 for (octave_idx_type i = 0; i < n; i++) | |
1661 retval.xelem (i) = octave_int<octave_idx_type> (A.xelem (i)); | |
1662 | |
1663 return retval; | |
1664 } | |
1665 | |
1666 Array<octave_idx_type> | |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1667 octave_value::octave_idx_type_vector_value (bool require_int, |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1668 bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1669 bool force_vector_conversion) const |
8811 | 1670 { |
1671 Array<octave_idx_type> retval; | |
1672 | |
1673 if (is_integer_type ()) | |
1674 { | |
1675 if (is_int32_type ()) | |
1676 retval = convert_to_octave_idx_type_array (int32_array_value ()); | |
1677 else if (is_int64_type ()) | |
1678 retval = convert_to_octave_idx_type_array (int64_array_value ()); | |
1679 else if (is_int16_type ()) | |
1680 retval = convert_to_octave_idx_type_array (int16_array_value ()); | |
1681 else if (is_int8_type ()) | |
1682 retval = convert_to_octave_idx_type_array (int8_array_value ()); | |
1683 else if (is_uint32_type ()) | |
1684 retval = convert_to_octave_idx_type_array (uint32_array_value ()); | |
1685 else if (is_uint64_type ()) | |
1686 retval = convert_to_octave_idx_type_array (uint64_array_value ()); | |
1687 else if (is_uint16_type ()) | |
1688 retval = convert_to_octave_idx_type_array (uint16_array_value ()); | |
1689 else if (is_uint8_type ()) | |
1690 retval = convert_to_octave_idx_type_array (uint8_array_value ()); | |
1691 else | |
1692 retval = array_value (force_string_conv); | |
1693 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1694 else |
8811 | 1695 { |
1696 const NDArray a = array_value (force_string_conv); | |
1697 if (! error_state) | |
1698 { | |
1699 if (require_int) | |
1700 { | |
1701 retval.resize (a.dims ()); | |
1702 for (octave_idx_type i = 0; i < a.numel (); i++) | |
1703 { | |
1704 double ai = a.elem (i); | |
1705 octave_idx_type v = static_cast<octave_idx_type> (ai); | |
1706 if (ai == v) | |
1707 retval.xelem (i) = v; | |
1708 else | |
1709 { | |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9732
diff
changeset
|
1710 error_with_cfn ("conversion to integer value failed"); |
8811 | 1711 break; |
1712 } | |
1713 } | |
1714 } | |
1715 else | |
1716 retval = Array<octave_idx_type> (a); | |
1717 } | |
1718 } | |
1719 | |
1720 | |
1721 if (error_state) | |
1722 return retval; | |
1723 else | |
1724 return retval.reshape (make_vector_dims (retval.dims (), | |
1725 force_vector_conversion, | |
1726 type_name (), "integer vector")); | |
1727 } | |
1728 | |
3419 | 1729 Array<Complex> |
2376 | 1730 octave_value::complex_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1731 bool force_vector_conversion) const |
2376 | 1732 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1733 Array<Complex> retval = complex_array_value (force_string_conv); |
2376 | 1734 |
1735 if (error_state) | |
1736 return retval; | |
1737 else | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1738 return retval.reshape (make_vector_dims (retval.dims (), |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1739 force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1740 type_name (), "complex vector")); |
2376 | 1741 } |
1742 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1743 FloatColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1744 octave_value::float_column_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1745 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1746 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1747 return FloatColumnVector (float_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1748 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1749 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1750 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1751 FloatComplexColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1752 octave_value::float_complex_column_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1753 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1754 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1755 return FloatComplexColumnVector (float_complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1756 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1757 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1758 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1759 FloatRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1760 octave_value::float_row_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1761 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1762 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1763 return FloatRowVector (float_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1764 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1765 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1766 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1767 FloatComplexRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1768 octave_value::float_complex_row_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1769 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1770 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1771 return FloatComplexRowVector (float_complex_vector_value (force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1772 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1773 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1774 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1775 Array<float> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1776 octave_value::float_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1777 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1778 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1779 Array<float> retval = float_array_value (force_string_conv); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1780 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1781 if (error_state) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1782 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1783 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1784 return retval.reshape (make_vector_dims (retval.dims (), |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1785 force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1786 type_name (), "real vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1787 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1788 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1789 Array<FloatComplex> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1790 octave_value::float_complex_vector_value (bool force_string_conv, |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1791 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1792 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1793 Array<FloatComplex> retval = float_complex_array_value (force_string_conv); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1794 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1795 if (error_state) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1796 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1797 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1798 return retval.reshape (make_vector_dims (retval.dims (), |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1799 force_vector_conversion, |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1800 type_name (), "complex vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1801 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
1802 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1803 octave_value |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1804 octave_value::storable_value (void) const |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1805 { |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1806 octave_value retval = *this; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1807 if (is_null_value ()) |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1808 retval = octave_value (rep->empty_clone ()); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1809 else |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1810 retval.maybe_economize (); |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1811 |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1812 return retval; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1813 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1814 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1815 void |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1816 octave_value::make_storable_value (void) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1817 { |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1818 if (is_null_value ()) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1819 { |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1820 octave_base_value *rc = rep->empty_clone (); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1821 if (--rep->count == 0) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1822 delete rep; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1823 rep = rc; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1824 } |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1825 else |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
1826 maybe_economize (); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1827 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1828 |
4944 | 1829 int |
1830 octave_value::write (octave_stream& os, int block_size, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1831 oct_data_conv::data_type output_type, int skip, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1832 oct_mach_info::float_format flt_fmt) const |
4944 | 1833 { |
1834 return rep->write (os, block_size, output_type, skip, flt_fmt); | |
1835 } | |
1836 | |
2413 | 1837 static void |
3933 | 1838 gripe_binary_op (const std::string& on, const std::string& tn1, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1839 const std::string& tn2) |
2376 | 1840 { |
2903 | 1841 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1842 on.c_str (), tn1.c_str (), tn2.c_str ()); |
2376 | 1843 } |
1844 | |
3203 | 1845 static void |
3523 | 1846 gripe_binary_op_conv (const std::string& on) |
3203 | 1847 { |
1848 error ("type conversion failed for binary operator `%s'", on.c_str ()); | |
1849 } | |
1850 | |
2376 | 1851 octave_value |
3933 | 1852 do_binary_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1853 const octave_value& v1, const octave_value& v2) |
2376 | 1854 { |
1855 octave_value retval; | |
1856 | |
1857 int t1 = v1.type_id (); | |
1858 int t2 = v2.type_id (); | |
1859 | |
7336 | 1860 if (t1 == octave_class::static_type_id () |
1861 || t2 == octave_class::static_type_id ()) | |
1862 { | |
1863 octave_value_typeinfo::binary_class_op_fcn f | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1864 = octave_value_typeinfo::lookup_binary_class_op (op); |
2376 | 1865 |
7336 | 1866 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1867 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1868 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1869 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1870 retval = f (v1, v2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1871 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1872 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1873 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1874 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1875 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1876 } |
7336 | 1877 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1878 gripe_binary_op (octave_value::binary_op_as_string (op), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1879 v1.class_name (), v2.class_name ()); |
7336 | 1880 } |
2376 | 1881 else |
1882 { | |
7336 | 1883 // FIXME -- we need to handle overloading operators for built-in |
1884 // classes (double, char, int8, etc.) | |
2376 | 1885 |
7336 | 1886 octave_value_typeinfo::binary_op_fcn f |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1887 = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
7336 | 1888 |
1889 if (f) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1890 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1891 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1892 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1893 retval = f (*v1.rep, *v2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1894 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1895 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1896 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1897 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1898 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1899 } |
7336 | 1900 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1901 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1902 octave_value tv1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1903 octave_base_value::type_conv_info cf1 = v1.numeric_conversion_function (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1904 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1905 octave_value tv2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1906 octave_base_value::type_conv_info cf2 = v2.numeric_conversion_function (); |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1907 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1908 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1909 if (cf2.type_id () >= 0 && |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1910 octave_value_typeinfo::lookup_binary_op (op, t1, cf2.type_id ())) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1911 cf1 = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1912 else if (cf1.type_id () >= 0 && |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1913 octave_value_typeinfo::lookup_binary_op (op, cf1.type_id (), t2)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1914 cf2 = 0; |
7336 | 1915 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1916 if (cf1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1917 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1918 octave_base_value *tmp = cf1 (*v1.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1919 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1920 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1921 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1922 tv1 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1923 t1 = tv1.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1924 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1925 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1926 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1927 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1928 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1929 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1930 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1931 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1932 tv1 = v1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1933 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1934 if (cf2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1935 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1936 octave_base_value *tmp = cf2 (*v2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1937 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1938 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1939 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1940 tv2 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1941 t2 = tv2.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1942 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1943 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1944 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1945 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1946 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1947 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1948 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1949 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1950 tv2 = v2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1951 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1952 if (cf1 || cf2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1953 { |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1954 retval = do_binary_op (op, tv1, tv2); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1955 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1956 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1957 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1958 //demote double -> single and try again |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1959 cf1 = tv1.numeric_demotion_function (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1960 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1961 cf2 = tv2.numeric_demotion_function (); |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1962 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1963 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1964 if (cf2.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1965 && octave_value_typeinfo::lookup_binary_op (op, t1, cf2.type_id ())) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1966 cf1 = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1967 else if (cf1.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1968 && octave_value_typeinfo::lookup_binary_op (op, cf1.type_id (), t2)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1969 cf2 = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
1970 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1971 if (cf1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1972 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1973 octave_base_value *tmp = cf1 (*tv1.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1974 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1975 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1976 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1977 tv1 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1978 t1 = tv1.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1979 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1980 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1981 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1982 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1983 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1984 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1985 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1986 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1987 if (cf2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1988 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1989 octave_base_value *tmp = cf2 (*tv2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1990 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1991 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1992 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1993 tv2 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1994 t2 = tv2.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1995 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1996 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1997 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1998 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1999 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2000 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2001 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2002 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2003 if (cf1 || cf2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2004 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2005 f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2006 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2007 if (f) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2008 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2009 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2010 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2011 retval = f (*tv1.rep, *tv2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2012 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2013 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2014 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2015 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2016 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2017 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2018 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2019 gripe_binary_op (octave_value::binary_op_as_string (op), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2020 v1.type_name (), v2.type_name ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2021 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2022 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2023 gripe_binary_op (octave_value::binary_op_as_string (op), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2024 v1.type_name (), v2.type_name ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2025 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2026 } |
2376 | 2027 } |
2028 | |
2029 return retval; | |
2030 } | |
2031 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2032 static octave_value |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2033 decompose_binary_op (octave_value::compound_binary_op op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2034 const octave_value& v1, const octave_value& v2) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2035 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2036 octave_value retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2037 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2038 switch (op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2039 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2040 case octave_value::op_trans_mul: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2041 retval = do_binary_op (octave_value::op_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2042 do_unary_op (octave_value::op_transpose, v1), |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2043 v2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2044 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2045 case octave_value::op_mul_trans: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2046 retval = do_binary_op (octave_value::op_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2047 v1, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2048 do_unary_op (octave_value::op_transpose, v2)); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2049 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2050 case octave_value::op_herm_mul: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2051 retval = do_binary_op (octave_value::op_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2052 do_unary_op (octave_value::op_hermitian, v1), |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2053 v2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2054 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2055 case octave_value::op_mul_herm: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2056 retval = do_binary_op (octave_value::op_mul, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2057 v1, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2058 do_unary_op (octave_value::op_hermitian, v2)); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2059 break; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2060 case octave_value::op_trans_ldiv: |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2061 retval = do_binary_op (octave_value::op_ldiv, |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2062 do_unary_op (octave_value::op_transpose, v1), |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2063 v2); |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2064 break; |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2065 case octave_value::op_herm_ldiv: |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2066 retval = do_binary_op (octave_value::op_ldiv, |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2067 do_unary_op (octave_value::op_hermitian, v1), |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2068 v2); |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
2069 break; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2070 case octave_value::op_el_not_and: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2071 retval = do_binary_op (octave_value::op_el_and, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2072 do_unary_op (octave_value::op_not, v1), |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2073 v2); |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2074 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2075 case octave_value::op_el_not_or: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2076 retval = do_binary_op (octave_value::op_el_or, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2077 do_unary_op (octave_value::op_not, v1), |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2078 v2); |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2079 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2080 case octave_value::op_el_and_not: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2081 retval = do_binary_op (octave_value::op_el_and, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2082 v1, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2083 do_unary_op (octave_value::op_not, v2)); |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2084 break; |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2085 case octave_value::op_el_or_not: |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2086 retval = do_binary_op (octave_value::op_el_or, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2087 v1, |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2088 do_unary_op (octave_value::op_not, v2)); |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
2089 break; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2090 default: |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2091 error ("invalid compound operator"); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2092 break; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2093 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2094 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2095 return retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2096 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2097 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2098 octave_value |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2099 do_binary_op (octave_value::compound_binary_op op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2100 const octave_value& v1, const octave_value& v2) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2101 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2102 octave_value retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2103 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2104 int t1 = v1.type_id (); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2105 int t2 = v2.type_id (); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2106 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2107 if (t1 == octave_class::static_type_id () |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2108 || t2 == octave_class::static_type_id ()) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2109 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2110 octave_value_typeinfo::binary_class_op_fcn f |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2111 = octave_value_typeinfo::lookup_binary_class_op (op); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2112 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2113 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2114 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2115 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2116 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2117 retval = f (v1, v2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2118 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2119 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2120 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2121 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2122 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2123 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2124 else |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2125 retval = decompose_binary_op (op, v1, v2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2126 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2127 else |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2128 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2129 octave_value_typeinfo::binary_op_fcn f |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2130 = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2131 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2132 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2133 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2134 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2135 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2136 retval = f (*v1.rep, *v2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2137 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2138 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2139 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2140 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2141 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2142 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2143 else |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2144 retval = decompose_binary_op (op, v1, v2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2145 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2146 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2147 return retval; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2148 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
2149 |
4915 | 2150 static void |
2151 gripe_cat_op (const std::string& tn1, const std::string& tn2) | |
2152 { | |
2153 error ("concatenation operator not implemented for `%s' by `%s' operations", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2154 tn1.c_str (), tn2.c_str ()); |
4915 | 2155 } |
2156 | |
2157 static void | |
2158 gripe_cat_op_conv (void) | |
2159 { | |
2160 error ("type conversion failed for concatenation operator"); | |
2161 } | |
2162 | |
2163 octave_value | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2164 do_cat_op (const octave_value& v1, const octave_value& v2, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2165 const Array<octave_idx_type>& ra_idx) |
4915 | 2166 { |
2167 octave_value retval; | |
2168 | |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7800
diff
changeset
|
2169 // Can't rapid return for concatenation with an empty object here as |
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7800
diff
changeset
|
2170 // something like cat(1,[],single([]) must return the correct type. |
5164 | 2171 |
4915 | 2172 int t1 = v1.type_id (); |
2173 int t2 = v2.type_id (); | |
2174 | |
5759 | 2175 octave_value_typeinfo::cat_op_fcn f |
2176 = octave_value_typeinfo::lookup_cat_op (t1, t2); | |
4915 | 2177 |
2178 if (f) | |
7487
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
2179 { |
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
2180 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2181 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2182 retval = f (*v1.rep, *v2.rep, ra_idx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2183 } |
7487
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
2184 catch (octave_execution_exception) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2185 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2186 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2187 } |
7487
1e01db14700b
catch octave_execution_exception for built-in and mex functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
2188 } |
4915 | 2189 else |
2190 { | |
2191 octave_value tv1; | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2192 octave_base_value::type_conv_info cf1 = v1.numeric_conversion_function (); |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2193 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2194 octave_value tv2; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2195 octave_base_value::type_conv_info cf2 = v2.numeric_conversion_function (); |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2196 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2197 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2198 if (cf2.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2199 && octave_value_typeinfo::lookup_cat_op (t1, cf2.type_id ())) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2200 cf1 = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2201 else if (cf1.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2202 && octave_value_typeinfo::lookup_cat_op (cf1.type_id (), t2)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2203 cf2 = 0; |
4915 | 2204 |
2205 if (cf1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2206 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2207 octave_base_value *tmp = cf1 (*v1.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2208 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2209 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2210 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2211 tv1 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2212 t1 = tv1.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2213 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2214 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2215 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2216 gripe_cat_op_conv (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2217 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2218 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2219 } |
4915 | 2220 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2221 tv1 = v1; |
4915 | 2222 |
2223 if (cf2) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2224 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2225 octave_base_value *tmp = cf2 (*v2.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2226 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2227 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2228 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2229 tv2 = octave_value (tmp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2230 t2 = tv2.type_id (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2231 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2232 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2233 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2234 gripe_cat_op_conv (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2235 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2236 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2237 } |
4915 | 2238 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2239 tv2 = v2; |
4915 | 2240 |
2241 if (cf1 || cf2) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2242 { |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2243 retval = do_cat_op (tv1, tv2, ra_idx); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2244 } |
4915 | 2245 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2246 gripe_cat_op (v1.type_name (), v2.type_name ()); |
4915 | 2247 } |
2248 | |
2249 return retval; | |
2250 } | |
2251 | |
3933 | 2252 void |
2253 octave_value::print_info (std::ostream& os, const std::string& prefix) const | |
2254 { | |
2255 os << prefix << "type_name: " << type_name () << "\n" | |
2256 << prefix << "count: " << get_count () << "\n" | |
2257 << prefix << "rep info: "; | |
2258 | |
2259 rep->print_info (os, prefix + " "); | |
2260 } | |
2261 | |
3203 | 2262 static void |
3523 | 2263 gripe_unary_op (const std::string& on, const std::string& tn) |
3203 | 2264 { |
2265 error ("unary operator `%s' not implemented for `%s' operands", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2266 on.c_str (), tn.c_str ()); |
3203 | 2267 } |
2268 | |
2269 static void | |
3523 | 2270 gripe_unary_op_conv (const std::string& on) |
3203 | 2271 { |
2272 error ("type conversion failed for unary operator `%s'", on.c_str ()); | |
2273 } | |
2274 | |
2275 octave_value | |
2276 do_unary_op (octave_value::unary_op op, const octave_value& v) | |
2277 { | |
2278 octave_value retval; | |
2279 | |
2280 int t = v.type_id (); | |
2281 | |
7336 | 2282 if (t == octave_class::static_type_id ()) |
2283 { | |
2284 octave_value_typeinfo::unary_class_op_fcn f | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2285 = octave_value_typeinfo::lookup_unary_class_op (op); |
3203 | 2286 |
7336 | 2287 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2288 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2289 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2290 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2291 retval = f (v); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2292 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2293 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2294 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2295 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2296 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2297 } |
7336 | 2298 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2299 gripe_unary_op (octave_value::unary_op_as_string (op), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2300 v.class_name ()); |
7336 | 2301 } |
3203 | 2302 else |
2303 { | |
7336 | 2304 // FIXME -- we need to handle overloading operators for built-in |
2305 // classes (double, char, int8, etc.) | |
2306 | |
2307 octave_value_typeinfo::unary_op_fcn f | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2308 = octave_value_typeinfo::lookup_unary_op (op, t); |
3203 | 2309 |
7336 | 2310 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2311 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2312 try |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2313 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2314 retval = f (*v.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2315 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2316 catch (octave_execution_exception) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2317 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2318 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2319 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2320 } |
7336 | 2321 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2322 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2323 octave_value tv; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2324 octave_base_value::type_conv_fcn cf |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2325 = v.numeric_conversion_function (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2326 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2327 if (cf) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2328 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2329 octave_base_value *tmp = cf (*v.rep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2330 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2331 if (tmp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2332 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2333 tv = octave_value (tmp); |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
2334 retval = do_unary_op (op, tv); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2335 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2336 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2337 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2338 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2339 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2340 gripe_unary_op (octave_value::unary_op_as_string (op), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2341 v.type_name ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2342 } |
3203 | 2343 } |
2344 | |
2345 return retval; | |
2346 } | |
2347 | |
2348 static void | |
3933 | 2349 gripe_unary_op_conversion_failed (const std::string& op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2350 const std::string& tn) |
3203 | 2351 { |
2352 error ("operator %s: type conversion for `%s' failed", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2353 op.c_str (), tn.c_str ()); |
3203 | 2354 } |
2355 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2356 octave_value& |
3933 | 2357 octave_value::do_non_const_unary_op (unary_op op) |
3203 | 2358 { |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2359 if (op == op_incr || op == op_decr) |
3203 | 2360 { |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2361 // We want the gripe just here, because in the other branch this should |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2362 // not happen, and if it did anyway (internal error), the message would |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2363 // be confusing. |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2364 if (is_undefined ()) |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2365 { |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2366 std::string op_str = unary_op_as_string (op); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2367 error ("in x%s or %sx, x must be defined first", |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2368 op_str.c_str (), op_str.c_str ()); |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2369 return *this; |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2370 } |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2371 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2372 // Genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2373 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2374 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2375 octave_value_typeinfo::non_const_unary_op_fcn f |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2376 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2377 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2378 if (f) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2379 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2380 make_unique (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2381 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2382 try |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2383 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2384 f (*rep); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2385 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2386 catch (octave_execution_exception) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2387 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2388 gripe_library_execution_error (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2389 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2390 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2391 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2392 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2393 octave_base_value::type_conv_fcn cf = numeric_conversion_function (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2394 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2395 if (cf) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2396 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2397 octave_base_value *tmp = cf (*rep); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2398 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2399 if (tmp) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2400 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2401 octave_base_value *old_rep = rep; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2402 rep = tmp; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2403 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2404 t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2405 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2406 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2407 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2408 if (f) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2409 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2410 try |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2411 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2412 f (*rep); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2413 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2414 catch (octave_execution_exception) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2415 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2416 gripe_library_execution_error (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2417 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2418 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2419 if (old_rep && --old_rep->count == 0) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2420 delete old_rep; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2421 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2422 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2423 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2424 if (old_rep) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2425 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2426 if (--rep->count == 0) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2427 delete rep; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2428 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2429 rep = old_rep; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2430 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2431 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2432 gripe_unary_op (octave_value::unary_op_as_string (op), |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2433 type_name ()); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2434 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2435 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2436 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2437 gripe_unary_op_conversion_failed |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2438 (octave_value::unary_op_as_string (op), type_name ()); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2439 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2440 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2441 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2442 } |
3203 | 2443 } |
2444 else | |
2445 { | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2446 // Non-genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2447 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2448 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2449 octave_value_typeinfo::non_const_unary_op_fcn f = 0; |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2450 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2451 // Only attempt to operate in-place if this variable is unshared. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2452 if (rep->count == 1) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2453 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2454 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2455 if (f) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2456 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2457 try |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2458 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2459 f (*rep); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2460 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2461 catch (octave_execution_exception) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2462 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2463 gripe_library_execution_error (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2464 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2465 } |
3203 | 2466 else |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2467 *this = do_unary_op (op, *this); |
3203 | 2468 } |
3933 | 2469 |
2470 return *this; | |
3203 | 2471 } |
2472 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2473 octave_value& |
4247 | 2474 octave_value::do_non_const_unary_op (unary_op op, const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2475 const std::list<octave_value_list>& idx) |
3933 | 2476 { |
2477 if (idx.empty ()) | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2478 do_non_const_unary_op (op); |
3933 | 2479 else |
2480 { | |
5775 | 2481 // FIXME -- only do the following stuff if we can't find a |
3933 | 2482 // specific function to call to handle the op= operation for the |
2483 // types we have. | |
3205 | 2484 |
3933 | 2485 assign_op assop = unary_op_to_assign_op (op); |
2486 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2487 assign (assop, type, idx, 1.0); |
3933 | 2488 } |
2489 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2490 return *this; |
3205 | 2491 } |
2492 | |
2493 octave_value::assign_op | |
2494 octave_value::unary_op_to_assign_op (unary_op op) | |
2495 { | |
2496 assign_op binop = unknown_assign_op; | |
2497 | |
2498 switch (op) | |
2499 { | |
3533 | 2500 case op_incr: |
2501 binop = op_add_eq; | |
3205 | 2502 break; |
2503 | |
3533 | 2504 case op_decr: |
2505 binop = op_sub_eq; | |
3205 | 2506 break; |
2507 | |
2508 default: | |
2509 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2510 std::string on = unary_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2511 error ("operator %s: no assign operator found", on.c_str ()); |
3205 | 2512 } |
2513 } | |
2514 | |
2515 return binop; | |
2516 } | |
2517 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2518 octave_value::binary_op |
3204 | 2519 octave_value::op_eq_to_binary_op (assign_op op) |
2520 { | |
2521 binary_op binop = unknown_binary_op; | |
2522 | |
2523 switch (op) | |
2524 { | |
3533 | 2525 case op_add_eq: |
2526 binop = op_add; | |
3204 | 2527 break; |
2528 | |
3533 | 2529 case op_sub_eq: |
2530 binop = op_sub; | |
3204 | 2531 break; |
2532 | |
3533 | 2533 case op_mul_eq: |
2534 binop = op_mul; | |
3204 | 2535 break; |
2536 | |
3533 | 2537 case op_div_eq: |
2538 binop = op_div; | |
3204 | 2539 break; |
2540 | |
3533 | 2541 case op_ldiv_eq: |
2542 binop = op_ldiv; | |
3204 | 2543 break; |
2544 | |
4018 | 2545 case op_pow_eq: |
2546 binop = op_pow; | |
2547 break; | |
2548 | |
3533 | 2549 case op_lshift_eq: |
2550 binop = op_lshift; | |
3204 | 2551 break; |
2552 | |
3533 | 2553 case op_rshift_eq: |
2554 binop = op_rshift; | |
3204 | 2555 break; |
2556 | |
3533 | 2557 case op_el_mul_eq: |
2558 binop = op_el_mul; | |
3204 | 2559 break; |
2560 | |
3533 | 2561 case op_el_div_eq: |
2562 binop = op_el_div; | |
3204 | 2563 break; |
2564 | |
3533 | 2565 case op_el_ldiv_eq: |
2566 binop = op_el_ldiv; | |
3204 | 2567 break; |
2568 | |
4018 | 2569 case op_el_pow_eq: |
2570 binop = op_el_pow; | |
2571 break; | |
2572 | |
3533 | 2573 case op_el_and_eq: |
2574 binop = op_el_and; | |
3204 | 2575 break; |
2576 | |
3533 | 2577 case op_el_or_eq: |
2578 binop = op_el_or; | |
3204 | 2579 break; |
2580 | |
2581 default: | |
2582 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2583 std::string on = assign_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2584 error ("operator %s: no binary operator found", on.c_str ()); |
3204 | 2585 } |
2586 } | |
2587 | |
2588 return binop; | |
2589 } | |
2590 | |
3933 | 2591 octave_value |
2592 octave_value::empty_conv (const std::string& type, const octave_value& rhs) | |
2593 { | |
2594 octave_value retval; | |
2595 | |
2596 if (type.length () > 0) | |
2597 { | |
2598 switch (type[0]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2599 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2600 case '(': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2601 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2602 if (type.length () > 1 && type[1] == '.') |
10754
92eb5fb58ebc
fix resize with structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10753
diff
changeset
|
2603 retval = octave_map (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2604 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2605 retval = octave_value (rhs.empty_clone ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2606 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2607 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2608 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2609 case '{': |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2610 retval = Cell (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2611 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2612 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2613 case '.': |
10754
92eb5fb58ebc
fix resize with structs
Jaroslav Hajek <highegg@gmail.com>
parents:
10753
diff
changeset
|
2614 retval = octave_scalar_map (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2615 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2616 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2617 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2618 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2619 } |
3933 | 2620 } |
2621 else | |
2622 retval = octave_value (rhs.empty_clone ()); | |
2623 | |
2624 return retval; | |
2625 } | |
2626 | |
2376 | 2627 void |
2628 install_types (void) | |
2629 { | |
2630 octave_base_value::register_type (); | |
3928 | 2631 octave_cell::register_type (); |
2376 | 2632 octave_scalar::register_type (); |
2633 octave_complex::register_type (); | |
2634 octave_matrix::register_type (); | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
2635 octave_diag_matrix::register_type (); |
2376 | 2636 octave_complex_matrix::register_type (); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
2637 octave_complex_diag_matrix::register_type (); |
2376 | 2638 octave_range::register_type (); |
2825 | 2639 octave_bool::register_type (); |
2640 octave_bool_matrix::register_type (); | |
2376 | 2641 octave_char_matrix_str::register_type (); |
5279 | 2642 octave_char_matrix_sq_str::register_type (); |
4901 | 2643 octave_int8_scalar::register_type (); |
2644 octave_int16_scalar::register_type (); | |
2645 octave_int32_scalar::register_type (); | |
2646 octave_int64_scalar::register_type (); | |
2647 octave_uint8_scalar::register_type (); | |
2648 octave_uint16_scalar::register_type (); | |
2649 octave_uint32_scalar::register_type (); | |
2650 octave_uint64_scalar::register_type (); | |
2651 octave_int8_matrix::register_type (); | |
2652 octave_int16_matrix::register_type (); | |
2653 octave_int32_matrix::register_type (); | |
2654 octave_int64_matrix::register_type (); | |
2655 octave_uint8_matrix::register_type (); | |
2656 octave_uint16_matrix::register_type (); | |
2657 octave_uint32_matrix::register_type (); | |
2658 octave_uint64_matrix::register_type (); | |
5164 | 2659 octave_sparse_bool_matrix::register_type (); |
2660 octave_sparse_matrix::register_type (); | |
2661 octave_sparse_complex_matrix::register_type (); | |
2376 | 2662 octave_struct::register_type (); |
10753
bee1b1a2e29a
yield compatible dims from cell2struct + more fixes. build & tests OK
Jaroslav Hajek <highegg@gmail.com>
parents:
10742
diff
changeset
|
2663 octave_scalar_struct::register_type (); |
7336 | 2664 octave_class::register_type (); |
3977 | 2665 octave_cs_list::register_type (); |
2376 | 2666 octave_magic_colon::register_type (); |
2974 | 2667 octave_builtin::register_type (); |
2668 octave_user_function::register_type (); | |
4649 | 2669 octave_dld_function::register_type (); |
4643 | 2670 octave_fcn_handle::register_type (); |
4966 | 2671 octave_fcn_inline::register_type (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2672 octave_float_scalar::register_type (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2673 octave_float_complex::register_type (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2674 octave_float_matrix::register_type (); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
2675 octave_float_diag_matrix::register_type (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2676 octave_float_complex_matrix::register_type (); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
2677 octave_float_complex_diag_matrix::register_type (); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
2678 octave_perm_matrix::register_type (); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2679 octave_null_matrix::register_type (); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2680 octave_null_str::register_type (); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2681 octave_null_sq_str::register_type (); |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
2682 octave_lazy_index::register_type (); |
2376 | 2683 } |
2684 | |
4970 | 2685 #if 0 |
2686 DEFUN (cast, args, , | |
2687 "-*- texinfo -*-\n\ | |
2688 @deftypefn {Built-in Function} {} cast (@var{val}, @var{type})\n\ | |
2689 Convert @var{val} to the new data type @var{type}.\n\ | |
5642 | 2690 @seealso{class, typeinfo}\n\ |
2691 @end deftypefn") | |
4970 | 2692 { |
2693 octave_value retval; | |
2694 | |
2695 if (args.length () == 2) | |
2696 error ("cast: not implemented"); | |
2697 else | |
5823 | 2698 print_usage (); |
4970 | 2699 |
2700 return retval; | |
2701 } | |
2702 #endif | |
2703 | |
4791 | 2704 DEFUN (sizeof, args, , |
2705 "-*- texinfo -*-\n\ | |
2706 @deftypefn {Built-in Function} {} sizeof (@var{val})\n\ | |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10654
diff
changeset
|
2707 Return the size of @var{val} in bytes.\n\ |
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10654
diff
changeset
|
2708 @seealso{whos}\n\ |
4791 | 2709 @end deftypefn") |
2710 { | |
2711 octave_value retval; | |
2712 | |
2713 if (args.length () == 1) | |
2714 retval = args(0).byte_size (); | |
2715 else | |
5823 | 2716 print_usage (); |
4791 | 2717 |
2718 return retval; | |
2719 } | |
2720 | |
6153 | 2721 DEFUN (subsref, args, nargout, |
2722 "-*- texinfo -*-\n\ | |
2723 @deftypefn {Built-in Function} {} subsref (@var{val}, @var{idx})\n\ | |
2724 Perform the subscripted element selection operation according to\n\ | |
2725 the subscript specified by @var{idx}.\n\ | |
2726 \n\ | |
2727 The subscript @var{idx} is expected to be a structure array with\n\ | |
2728 fields @samp{type} and @samp{subs}. Valid values for @samp{type}\n\ | |
6550 | 2729 are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\ |
6153 | 2730 The @samp{subs} field may be either @samp{\":\"} or a cell array\n\ |
2731 of index values.\n\ | |
6631 | 2732 \n\ |
2733 The following example shows how to extract the two first columns of\n\ | |
2734 a matrix\n\ | |
2735 \n\ | |
2736 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8992
diff
changeset
|
2737 @group\n\ |
6631 | 2738 val = magic(3)\n\ |
2739 @result{} val = [ 8 1 6\n\ | |
2740 3 5 7\n\ | |
2741 4 9 2 ]\n\ | |
2742 idx.type = \"()\";\n\ | |
2743 idx.subs = @{\":\", 1:2@};\n\ | |
2744 subsref(val, idx)\n\ | |
2745 @result{} [ 8 1 \n\ | |
2746 3 5 \n\ | |
2747 4 9 ]\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8992
diff
changeset
|
2748 @end group\n\ |
6631 | 2749 @end example\n\ |
2750 \n\ | |
2751 @noindent\n\ | |
2752 Note that this is the same as writing @code{val(:,1:2)}.\n\ | |
6157 | 2753 @seealso{subsasgn, substruct}\n\ |
6153 | 2754 @end deftypefn") |
2755 { | |
2756 octave_value_list retval; | |
2757 | |
2758 if (args.length () == 2) | |
2759 { | |
2760 std::string type; | |
2761 std::list<octave_value_list> idx; | |
2762 | |
2763 decode_subscripts ("subsref", args(1), type, idx); | |
2764 | |
2765 if (! error_state) | |
10075
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
2766 { |
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
2767 octave_value tmp = args(0); |
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
2768 retval = tmp.subsref (type, idx, nargout); |
84b0725f4b09
return class types by reference in const Array element access functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10033
diff
changeset
|
2769 } |
6153 | 2770 } |
2771 else | |
2772 print_usage (); | |
2773 | |
2774 return retval; | |
2775 } | |
2776 | |
2777 DEFUN (subsasgn, args, , | |
2778 "-*- texinfo -*-\n\ | |
2779 @deftypefn {Built-in Function} {} subsasgn (@var{val}, @var{idx}, @var{rhs})\n\ | |
2780 Perform the subscripted assignment operation according to\n\ | |
2781 the subscript specified by @var{idx}.\n\ | |
2782 \n\ | |
2783 The subscript @var{idx} is expected to be a structure array with\n\ | |
2784 fields @samp{type} and @samp{subs}. Valid values for @samp{type}\n\ | |
6248 | 2785 are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\ |
6153 | 2786 The @samp{subs} field may be either @samp{\":\"} or a cell array\n\ |
2787 of index values.\n\ | |
6631 | 2788 \n\ |
2789 The following example shows how to set the two first columns of a\n\ | |
2790 3-by-3 matrix to zero.\n\ | |
2791 \n\ | |
2792 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8992
diff
changeset
|
2793 @group\n\ |
6631 | 2794 val = magic(3);\n\ |
2795 idx.type = \"()\";\n\ | |
2796 idx.subs = @{\":\", 1:2@};\n\ | |
2797 subsasgn (val, idx, 0)\n\ | |
2798 @result{} [ 0 0 6\n\ | |
2799 0 0 7\n\ | |
2800 0 0 2 ]\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8992
diff
changeset
|
2801 @end group\n\ |
6631 | 2802 @end example\n\ |
2803 \n\ | |
2804 Note that this is the same as writing @code{val(:,1:2) = 0}.\n\ | |
6157 | 2805 @seealso{subsref, substruct}\n\ |
6153 | 2806 @end deftypefn") |
2807 { | |
2808 octave_value retval; | |
2809 | |
2810 if (args.length () == 3) | |
2811 { | |
2812 std::string type; | |
2813 std::list<octave_value_list> idx; | |
2814 | |
2815 decode_subscripts ("subsasgn", args(1), type, idx); | |
2816 | |
9368
ff612fdaee95
properly unshare variable in subsasgn
Jaroslav Hajek <highegg@gmail.com>
parents:
9351
diff
changeset
|
2817 octave_value arg0 = args(0); |
ff612fdaee95
properly unshare variable in subsasgn
Jaroslav Hajek <highegg@gmail.com>
parents:
9351
diff
changeset
|
2818 |
ff612fdaee95
properly unshare variable in subsasgn
Jaroslav Hajek <highegg@gmail.com>
parents:
9351
diff
changeset
|
2819 arg0.make_unique (); |
ff612fdaee95
properly unshare variable in subsasgn
Jaroslav Hajek <highegg@gmail.com>
parents:
9351
diff
changeset
|
2820 |
6153 | 2821 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2822 retval = arg0.subsasgn (type, idx, args(2)); |
6153 | 2823 } |
2824 else | |
2825 print_usage (); | |
2826 | |
2827 return retval; | |
2828 } |