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