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