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