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