Mercurial > octave
annotate libinterp/octave-value/ov.cc @ 29982:605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Replace configuration options with inverted sense (true means functionality is
disabled) with ordinary sense options: optimize_range, optimize_diagonal_matrix,
optimize_permutation_matrix.
* NEWS: Announce deprecation and replacement functions.
* basics.txi, diagperm.txi, numbers.txi: Replace instances of functions
in Octave manual with their replacements.
* interpreter.cc (maximum_braindamage): Change options for --traditional
to disable Octave optimizations.
* ov-typeinfo.cc (Ftypeinfo): Replace old functions in BIST tests.
* ov.cc: Rename variables Vdisable_diagonal_matrix,
Vdisable_permutation_matrix, Vdisable_range. Update code for inverted
sense of new optimize_XXX variables.
* ov.cc (Foptimize_range, Foptimize_diagonal_matrix,
Foptimize_permutation_matrix): New replacement functions.
* diag-perm.tst, mk-conv-tst.sh: Replace instances of disable_range
with optimize_range in BIST tests.
* scripts/deprecated/module.mk: Add disable_diagonal_matrix.m, disable_permutation_matrix.m, disable_range.m to build system.
* scripts/deprecated/disable_diagonal_matrix.m,
scripts/deprecated/disable_permutation_matrix.m,
scripts/deprecated/disable_range.m: New m-functions to issue a warning before
calling replacement optimize_XXX function.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 17 Aug 2021 14:34:42 -0700 |
parents | 939bef0b66e0 |
children | 428cccc75cc9 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
28427
diff
changeset
|
3 // Copyright (C) 1996-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2376 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21295
diff
changeset
|
27 # include "config.h" |
2376 | 28 #endif |
29 | |
4970 | 30 #include "data-conv.h" |
31 #include "quit.h" | |
2942 | 32 #include "str-vec.h" |
2376 | 33 |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
34 #include "ovl.h" |
4944 | 35 #include "oct-stream.h" |
2376 | 36 #include "ov.h" |
37 #include "ov-base.h" | |
2825 | 38 #include "ov-bool.h" |
39 #include "ov-bool-mat.h" | |
3351 | 40 #include "ov-cell.h" |
2376 | 41 #include "ov-scalar.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
42 #include "ov-float.h" |
2376 | 43 #include "ov-re-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
44 #include "ov-flt-re-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
45 #include "ov-re-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
46 #include "ov-flt-re-diag.h" |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
47 #include "ov-perm.h" |
5164 | 48 #include "ov-bool-sparse.h" |
49 #include "ov-cx-sparse.h" | |
50 #include "ov-re-sparse.h" | |
4901 | 51 #include "ov-int8.h" |
52 #include "ov-int16.h" | |
53 #include "ov-int32.h" | |
54 #include "ov-int64.h" | |
55 #include "ov-uint8.h" | |
56 #include "ov-uint16.h" | |
57 #include "ov-uint32.h" | |
58 #include "ov-uint64.h" | |
2376 | 59 #include "ov-complex.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
60 #include "ov-flt-complex.h" |
2376 | 61 #include "ov-cx-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
62 #include "ov-flt-cx-mat.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
63 #include "ov-cx-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8346
diff
changeset
|
64 #include "ov-flt-cx-diag.h" |
2376 | 65 #include "ov-ch-mat.h" |
66 #include "ov-str-mat.h" | |
67 #include "ov-range.h" | |
68 #include "ov-struct.h" | |
7336 | 69 #include "ov-class.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14861
diff
changeset
|
70 #include "ov-classdef.h" |
14015 | 71 #include "ov-oncleanup.h" |
3977 | 72 #include "ov-cs-list.h" |
2376 | 73 #include "ov-colon.h" |
2974 | 74 #include "ov-builtin.h" |
4649 | 75 #include "ov-dld-fcn.h" |
2974 | 76 #include "ov-usr-fcn.h" |
4342 | 77 #include "ov-fcn-handle.h" |
2376 | 78 #include "ov-typeinfo.h" |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
79 #include "ov-magic-int.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
80 #include "ov-null-mat.h" |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
81 #include "ov-lazy-idx.h" |
15754
bf77f7f66bdf
register octave_java type at Octave startup
John W. Eaton <jwe@octave.org>
parents:
15467
diff
changeset
|
82 #include "ov-java.h" |
2376 | 83 |
84 #include "defun.h" | |
2880 | 85 #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
|
86 #include "errwarn.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23589
diff
changeset
|
87 #include "interpreter-private.h" |
2376 | 88 #include "pager.h" |
4005 | 89 #include "parse.h" |
24668
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
90 #include "pr-flt-fmt.h" |
2376 | 91 #include "pr-output.h" |
7336 | 92 #include "symtab.h" |
2376 | 93 #include "utils.h" |
94 #include "variables.h" | |
95 | |
2477 | 96 // We are likely to have a lot of octave_value objects to allocate, so |
97 // make the grow_size large. | |
98 | |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
99 // If TRUE, create special space-optimized diagonal matrix objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
100 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
101 static bool Voptimize_diagonal_matrix = true; |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
102 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
103 // If TRUE, create special space-optimized permutation matrix objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
104 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
105 static bool Voptimize_permutation_matrix = true; |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
106 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
107 // If TRUE, create special space-optimized range objects. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
108 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
109 static bool Voptimize_range = true; |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
110 |
5775 | 111 // FIXME |
2880 | 112 |
2376 | 113 // Octave's value type. |
114 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
115 octave_base_value * |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
116 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
|
117 { |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
118 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
|
119 return &nr; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
120 } |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20163
diff
changeset
|
121 |
3536 | 122 std::string |
3203 | 123 octave_value::unary_op_as_string (unary_op op) |
124 { | |
125 switch (op) | |
126 { | |
3533 | 127 case op_not: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
128 return "!"; |
3203 | 129 |
4965 | 130 case op_uplus: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
131 return "+"; |
4965 | 132 |
3533 | 133 case op_uminus: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
134 return "-"; |
3203 | 135 |
3533 | 136 case op_transpose: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
137 return ".'"; |
3203 | 138 |
3533 | 139 case op_hermitian: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
140 return "'"; |
3203 | 141 |
3533 | 142 case op_incr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
143 return "++"; |
3203 | 144 |
3533 | 145 case op_decr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
146 return "--"; |
3203 | 147 |
148 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
149 return "<unknown>"; |
3203 | 150 } |
151 } | |
152 | |
3536 | 153 std::string |
7336 | 154 octave_value::unary_op_fcn_name (unary_op op) |
155 { | |
156 switch (op) | |
157 { | |
158 case op_not: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
159 return "not"; |
7336 | 160 |
161 case op_uplus: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
162 return "uplus"; |
7336 | 163 |
164 case op_uminus: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
165 return "uminus"; |
7336 | 166 |
167 case op_transpose: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
168 return "transpose"; |
7336 | 169 |
170 case op_hermitian: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
171 return "ctranspose"; |
7336 | 172 |
173 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
174 return "<unknown>"; |
7336 | 175 } |
176 } | |
177 | |
178 std::string | |
2376 | 179 octave_value::binary_op_as_string (binary_op op) |
180 { | |
181 switch (op) | |
182 { | |
3533 | 183 case op_add: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
184 return "+"; |
2376 | 185 |
3533 | 186 case op_sub: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
187 return "-"; |
2376 | 188 |
3533 | 189 case op_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
190 return "*"; |
2376 | 191 |
3533 | 192 case op_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
193 return "/"; |
2376 | 194 |
3533 | 195 case op_pow: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
196 return "^"; |
2376 | 197 |
3533 | 198 case op_ldiv: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
199 return R"(\)"; |
2903 | 200 |
3533 | 201 case op_lt: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
202 return "<"; |
2376 | 203 |
3533 | 204 case op_le: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
205 return "<="; |
2376 | 206 |
3533 | 207 case op_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
208 return "=="; |
2376 | 209 |
3533 | 210 case op_ge: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
211 return ">="; |
2376 | 212 |
3533 | 213 case op_gt: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
214 return ">"; |
2376 | 215 |
3533 | 216 case op_ne: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
217 return "!="; |
2376 | 218 |
3533 | 219 case op_el_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
220 return ".*"; |
2376 | 221 |
3533 | 222 case op_el_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
223 return "./"; |
2376 | 224 |
3533 | 225 case op_el_pow: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
226 return ".^"; |
2376 | 227 |
3533 | 228 case op_el_ldiv: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
229 return R"(.\)"; |
2376 | 230 |
3533 | 231 case op_el_and: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
232 return "&"; |
2376 | 233 |
3533 | 234 case op_el_or: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
235 return "|"; |
2376 | 236 |
3533 | 237 case op_struct_ref: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
238 return "."; |
2376 | 239 |
240 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
241 return "<unknown>"; |
2376 | 242 } |
243 } | |
244 | |
3536 | 245 std::string |
7336 | 246 octave_value::binary_op_fcn_name (binary_op op) |
247 { | |
248 switch (op) | |
249 { | |
250 case op_add: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
251 return "plus"; |
7336 | 252 |
253 case op_sub: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
254 return "minus"; |
7336 | 255 |
256 case op_mul: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
257 return "mtimes"; |
7336 | 258 |
259 case op_div: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
260 return "mrdivide"; |
7336 | 261 |
262 case op_pow: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
263 return "mpower"; |
7336 | 264 |
265 case op_ldiv: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
266 return "mldivide"; |
7336 | 267 |
268 case op_lt: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
269 return "lt"; |
7336 | 270 |
271 case op_le: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
272 return "le"; |
7336 | 273 |
274 case op_eq: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
275 return "eq"; |
7336 | 276 |
277 case op_ge: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
278 return "ge"; |
7336 | 279 |
280 case op_gt: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
281 return "gt"; |
7336 | 282 |
283 case op_ne: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
284 return "ne"; |
7336 | 285 |
286 case op_el_mul: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
287 return "times"; |
7336 | 288 |
289 case op_el_div: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
290 return "rdivide"; |
7336 | 291 |
292 case op_el_pow: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
293 return "power"; |
7336 | 294 |
295 case op_el_ldiv: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
296 return "ldivide"; |
7336 | 297 |
298 case op_el_and: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
299 return "and"; |
7336 | 300 |
301 case op_el_or: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
302 return "or"; |
7336 | 303 |
304 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
305 return "<unknown>"; |
7336 | 306 } |
307 } | |
308 | |
309 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
|
310 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
|
311 { |
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 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
|
313 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
314 case op_trans_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
315 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
|
316 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
317 case op_mul_trans: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
318 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
|
319 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
320 case op_herm_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
321 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
|
322 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
323 case op_mul_herm: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
324 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
|
325 |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
326 case op_trans_ldiv: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
327 return "transldiv"; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
328 |
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
329 case op_herm_ldiv: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
330 return "hermldiv"; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
9608
diff
changeset
|
331 |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
332 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
|
333 return "andnot"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
334 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
335 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
|
336 return "ornot"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
337 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
338 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
|
339 return "notand"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
340 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
341 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
|
342 return "notor"; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8960
diff
changeset
|
343 |
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
|
344 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
345 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
|
346 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
347 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
348 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
349 std::string |
2880 | 350 octave_value::assign_op_as_string (assign_op op) |
351 { | |
352 switch (op) | |
353 { | |
3533 | 354 case op_asn_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
355 return "="; |
2880 | 356 |
3533 | 357 case op_add_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
358 return "+="; |
2880 | 359 |
3533 | 360 case op_sub_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
361 return "-="; |
2880 | 362 |
3533 | 363 case op_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
364 return "*="; |
2880 | 365 |
3533 | 366 case op_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
367 return "/="; |
2880 | 368 |
3533 | 369 case op_ldiv_eq: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
370 return R"(\=)"; |
3204 | 371 |
4018 | 372 case op_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
373 return "^="; |
2903 | 374 |
3533 | 375 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
|
376 return ".*="; |
2880 | 377 |
3533 | 378 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
|
379 return "./="; |
2880 | 380 |
3533 | 381 case op_el_ldiv_eq: |
23804
8057d3f0673d
Use C++11 raw string literals to avoid escaping backslashes in strings.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
382 return R"(.\=)"; |
3204 | 383 |
4018 | 384 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
|
385 return ".^="; |
4018 | 386 |
3533 | 387 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
|
388 return "&="; |
2880 | 389 |
3533 | 390 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
|
391 return "|="; |
2880 | 392 |
393 default: | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
394 return "<unknown>"; |
2880 | 395 } |
396 } | |
397 | |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
398 octave_value::binary_op |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
399 octave_value::assign_op_to_binary_op (assign_op op) |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
400 { |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
401 switch (op) |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
402 { |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
403 case op_add_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
404 return op_add; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
405 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
406 case op_sub_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
407 return op_sub; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
408 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
409 case op_mul_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
410 return op_mul; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
411 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
412 case op_div_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
413 return op_div; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
414 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
415 case op_ldiv_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
416 return op_ldiv; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
417 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
418 case op_pow_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
419 return op_pow; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
420 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
421 case op_el_mul_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
422 return op_el_mul; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
423 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
424 case op_el_div_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
425 return op_el_div; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
426 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
427 case op_el_ldiv_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
428 return op_el_ldiv; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
429 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
430 case op_el_pow_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
431 return op_el_pow; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
432 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
433 case op_el_and_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
434 return op_el_and; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
435 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
436 case op_el_or_eq: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
437 return op_el_or; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
438 |
15140
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
439 default: |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
440 return unknown_binary_op; |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
441 } |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
442 } |
6ea86e1d0f5f
Support +=, -=, *=, ect. in JIT
Max Brister <max@2bass.com>
parents:
15057
diff
changeset
|
443 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
444 octave_value::assign_op |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
445 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
|
446 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
447 switch (op) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
448 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
449 case op_add: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
450 return op_add_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
451 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
452 case op_sub: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
453 return op_sub_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
454 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
455 case op_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
456 return op_mul_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
457 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
458 case op_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
459 return op_div_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
460 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
461 case op_el_mul: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
462 return op_el_mul_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
463 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
464 case op_el_div: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
465 return op_el_div_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
466 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
467 case op_el_and: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
468 return op_el_and_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
469 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
470 case op_el_or: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
471 return op_el_or_eq; |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
472 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
473 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
474 return unknown_assign_op; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
475 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
476 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
477 |
4254 | 478 octave_value::octave_value (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 |
482 octave_value::octave_value (unsigned short 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 { } |
4254 | 485 |
4233 | 486 octave_value::octave_value (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 { } |
4233 | 489 |
4254 | 490 octave_value::octave_value (unsigned 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 (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 |
498 octave_value::octave_value (unsigned long int i) | |
499 : rep (new octave_scalar (i)) | |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
500 { } |
4254 | 501 |
21354
06d15e4e611a
move public data type macros to octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
502 #if defined (OCTAVE_HAVE_LONG_LONG_INT) |
4353 | 503 octave_value::octave_value (long long int i) |
504 : rep (new octave_scalar (i)) | |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
505 { } |
4353 | 506 #endif |
507 | |
21354
06d15e4e611a
move public data type macros to octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
508 #if defined (OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 509 octave_value::octave_value (unsigned long long int i) |
510 : rep (new octave_scalar (i)) | |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
511 { } |
4353 | 512 #endif |
513 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
514 octave_value::octave_value (octave::sys::time t) |
7065 | 515 : 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
|
516 { } |
4254 | 517 |
2376 | 518 octave_value::octave_value (double d) |
2825 | 519 : rep (new octave_scalar (d)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
520 { } |
2376 | 521 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
522 octave_value::octave_value (float d) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
523 : rep (new octave_float_scalar (d)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
524 { } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
525 |
4587 | 526 octave_value::octave_value (const Cell& c, bool is_csl) |
5477 | 527 : rep (is_csl |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
528 ? 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
|
529 : 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
|
530 { } |
3351 | 531 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
532 octave_value::octave_value (const Array<octave_value>& a, bool is_csl) |
5477 | 533 : rep (is_csl |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
534 ? 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
|
535 : 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
|
536 { } |
5147 | 537 |
5785 | 538 octave_value::octave_value (const Matrix& m, const MatrixType& t) |
539 : rep (new octave_matrix (m, t)) | |
2423 | 540 { |
541 maybe_mutate (); | |
542 } | |
2376 | 543 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
544 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
|
545 : rep (new octave_float_matrix (m, t)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
546 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
547 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
548 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
549 |
4507 | 550 octave_value::octave_value (const NDArray& a) |
4513 | 551 : rep (new octave_matrix (a)) |
4478 | 552 { |
553 maybe_mutate (); | |
554 } | |
555 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
556 octave_value::octave_value (const FloatNDArray& a) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
557 : rep (new octave_float_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
558 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
559 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
560 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
561 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
562 octave_value::octave_value (const Array<double>& a) |
4911 | 563 : rep (new octave_matrix (a)) |
564 { | |
565 maybe_mutate (); | |
566 } | |
567 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
568 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
|
569 : rep (new octave_float_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
570 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
571 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
572 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
573 |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
574 octave_value::octave_value (const DiagArray2<double>& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
575 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
576 ? dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
577 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
578 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
579 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
580 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
581 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
582 octave_value::octave_value (const DiagArray2<float>& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
583 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
584 ? dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
585 : dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
586 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
587 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
588 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
589 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
590 octave_value::octave_value (const DiagArray2<Complex>& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
591 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
592 ? dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
593 : dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
594 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
595 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
596 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
597 |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
598 octave_value::octave_value (const DiagArray2<FloatComplex>& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
599 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
600 ? dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
601 : dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))) |
15428
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
602 { |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
603 maybe_mutate (); |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
604 } |
fd5c0159b588
Fix diag handling of diagvectors (bug #37411)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14138
diff
changeset
|
605 |
2376 | 606 octave_value::octave_value (const DiagMatrix& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
607 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
608 ? dynamic_cast<octave_base_value *> (new octave_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
609 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (d)))) |
2423 | 610 { |
611 maybe_mutate (); | |
612 } | |
2376 | 613 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
614 octave_value::octave_value (const FloatDiagMatrix& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
615 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
616 ? dynamic_cast<octave_base_value *> (new octave_float_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
617 : dynamic_cast<octave_base_value *> (new octave_float_matrix (FloatMatrix (d)))) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
618 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
619 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
620 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
621 |
3418 | 622 octave_value::octave_value (const RowVector& v) |
623 : rep (new octave_matrix (v)) | |
2423 | 624 { |
625 maybe_mutate (); | |
626 } | |
2376 | 627 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
628 octave_value::octave_value (const FloatRowVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
629 : rep (new octave_float_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
630 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
631 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
632 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
633 |
3418 | 634 octave_value::octave_value (const ColumnVector& v) |
635 : rep (new octave_matrix (v)) | |
2423 | 636 { |
637 maybe_mutate (); | |
638 } | |
2376 | 639 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
640 octave_value::octave_value (const FloatColumnVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
641 : rep (new octave_float_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
642 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
643 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
644 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
645 |
2376 | 646 octave_value::octave_value (const Complex& C) |
2423 | 647 : rep (new octave_complex (C)) |
648 { | |
649 maybe_mutate (); | |
650 } | |
2376 | 651 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
652 octave_value::octave_value (const FloatComplex& C) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
653 : rep (new octave_float_complex (C)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
654 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
655 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
656 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
657 |
5785 | 658 octave_value::octave_value (const ComplexMatrix& m, const MatrixType& t) |
659 : rep (new octave_complex_matrix (m, t)) | |
2423 | 660 { |
661 maybe_mutate (); | |
662 } | |
2376 | 663 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
664 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
|
665 : rep (new octave_float_complex_matrix (m, t)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
666 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
667 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
668 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
669 |
4513 | 670 octave_value::octave_value (const ComplexNDArray& a) |
671 : rep (new octave_complex_matrix (a)) | |
4478 | 672 { |
673 maybe_mutate (); | |
674 } | |
675 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
676 octave_value::octave_value (const FloatComplexNDArray& a) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
677 : rep (new octave_float_complex_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
678 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
679 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
680 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
681 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
682 octave_value::octave_value (const Array<Complex>& a) |
4911 | 683 : rep (new octave_complex_matrix (a)) |
684 { | |
685 maybe_mutate (); | |
686 } | |
687 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
688 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
|
689 : rep (new octave_float_complex_matrix (a)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
690 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
691 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
692 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
693 |
2376 | 694 octave_value::octave_value (const ComplexDiagMatrix& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
695 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
696 ? dynamic_cast<octave_base_value *> (new octave_complex_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
697 : dynamic_cast<octave_base_value *> (new octave_complex_matrix (ComplexMatrix (d)))) |
2423 | 698 { |
699 maybe_mutate (); | |
700 } | |
2376 | 701 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
702 octave_value::octave_value (const FloatComplexDiagMatrix& d) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
703 : rep (Voptimize_diagonal_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
704 ? dynamic_cast<octave_base_value *> (new octave_float_complex_diag_matrix (d)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
705 : dynamic_cast<octave_base_value *> (new octave_float_complex_matrix (FloatComplexMatrix (d)))) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
706 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
707 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
708 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
709 |
3418 | 710 octave_value::octave_value (const ComplexRowVector& v) |
711 : rep (new octave_complex_matrix (v)) | |
2423 | 712 { |
713 maybe_mutate (); | |
714 } | |
2376 | 715 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
716 octave_value::octave_value (const FloatComplexRowVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
717 : rep (new octave_float_complex_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
718 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
719 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
720 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
721 |
3418 | 722 octave_value::octave_value (const ComplexColumnVector& v) |
723 : rep (new octave_complex_matrix (v)) | |
2423 | 724 { |
725 maybe_mutate (); | |
726 } | |
2376 | 727 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
728 octave_value::octave_value (const FloatComplexColumnVector& v) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
729 : rep (new octave_float_complex_matrix (v)) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
730 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
731 maybe_mutate (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
732 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
733 |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
734 octave_value::octave_value (const PermMatrix& p) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
735 : rep (Voptimize_permutation_matrix |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
736 ? dynamic_cast<octave_base_value *> (new octave_perm_matrix (p)) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
737 : dynamic_cast<octave_base_value *> (new octave_matrix (Matrix (p)))) |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
738 { |
8960
93f18f166aba
remove float perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
739 maybe_mutate (); |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
740 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
741 |
2825 | 742 octave_value::octave_value (bool b) |
743 : rep (new octave_bool (b)) | |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
744 { } |
2825 | 745 |
5785 | 746 octave_value::octave_value (const boolMatrix& bm, const MatrixType& t) |
747 : rep (new octave_bool_matrix (bm, t)) | |
2825 | 748 { |
749 maybe_mutate (); | |
750 } | |
751 | |
4513 | 752 octave_value::octave_value (const boolNDArray& bnda) |
753 : rep (new octave_bool_matrix (bnda)) | |
754 { | |
755 maybe_mutate (); | |
756 } | |
757 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
758 octave_value::octave_value (const Array<bool>& bnda) |
7433 | 759 : rep (new octave_bool_matrix (bnda)) |
760 { | |
761 maybe_mutate (); | |
762 } | |
763 | |
5279 | 764 octave_value::octave_value (char c, char type) |
765 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
766 ? new octave_char_matrix_dq_str (c) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
767 : new octave_char_matrix_sq_str (c)) |
3189 | 768 { |
769 maybe_mutate (); | |
770 } | |
771 | |
5279 | 772 octave_value::octave_value (const char *s, char type) |
773 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
774 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
775 : new octave_char_matrix_sq_str (s)) |
2423 | 776 { |
777 maybe_mutate (); | |
778 } | |
2376 | 779 |
5279 | 780 octave_value::octave_value (const std::string& s, char type) |
781 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
782 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
783 : new octave_char_matrix_sq_str (s)) |
2423 | 784 { |
785 maybe_mutate (); | |
786 } | |
2376 | 787 |
5279 | 788 octave_value::octave_value (const string_vector& s, char type) |
789 : rep (type == '"' | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
790 ? new octave_char_matrix_dq_str (s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
791 : new octave_char_matrix_sq_str (s)) |
2423 | 792 { |
793 maybe_mutate (); | |
794 } | |
2376 | 795 |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
796 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
|
797 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
798 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
799 : 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
|
800 { |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
801 maybe_mutate (); |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
802 } |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
803 |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9661
diff
changeset
|
804 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
|
805 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
806 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
807 : new octave_char_matrix_sq_str (chm)) |
2409 | 808 { |
4513 | 809 maybe_mutate (); |
810 } | |
2376 | 811 |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
812 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
|
813 : rep (type == '"' |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
814 ? new octave_char_matrix_dq_str (chm) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
815 : new octave_char_matrix_sq_str (chm)) |
4513 | 816 { |
2423 | 817 maybe_mutate (); |
2409 | 818 } |
2376 | 819 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
820 octave_value::octave_value (const SparseMatrix& m, const MatrixType& t) |
5164 | 821 : rep (new octave_sparse_matrix (m, t)) |
822 { | |
823 maybe_mutate (); | |
824 } | |
825 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
826 octave_value::octave_value (const Sparse<double>& m, const MatrixType& t) |
6863 | 827 : rep (new octave_sparse_matrix (m, t)) |
828 { | |
829 maybe_mutate (); | |
830 } | |
831 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
832 octave_value::octave_value (const SparseComplexMatrix& m, const MatrixType& t) |
5164 | 833 : rep (new octave_sparse_complex_matrix (m, t)) |
834 { | |
835 maybe_mutate (); | |
836 } | |
837 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
838 octave_value::octave_value (const Sparse<Complex>& m, const MatrixType& t) |
6863 | 839 : rep (new octave_sparse_complex_matrix (m, t)) |
840 { | |
841 maybe_mutate (); | |
842 } | |
843 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
844 octave_value::octave_value (const SparseBoolMatrix& bm, const MatrixType& t) |
5164 | 845 : rep (new octave_sparse_bool_matrix (bm, t)) |
846 { | |
847 maybe_mutate (); | |
848 } | |
849 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23352
diff
changeset
|
850 octave_value::octave_value (const Sparse<bool>& bm, const MatrixType& t) |
7433 | 851 : rep (new octave_sparse_bool_matrix (bm, t)) |
852 { | |
853 maybe_mutate (); | |
854 } | |
855 | |
4901 | 856 octave_value::octave_value (const octave_int8& i) |
857 : rep (new octave_int8_scalar (i)) | |
858 { | |
859 maybe_mutate (); | |
860 } | |
861 | |
862 octave_value::octave_value (const octave_uint8& i) | |
863 : rep (new octave_uint8_scalar (i)) | |
864 { | |
865 maybe_mutate (); | |
866 } | |
867 | |
868 octave_value::octave_value (const octave_int16& i) | |
869 : rep (new octave_int16_scalar (i)) | |
870 { | |
871 maybe_mutate (); | |
872 } | |
873 | |
874 octave_value::octave_value (const octave_uint16& i) | |
875 : rep (new octave_uint16_scalar (i)) | |
876 { | |
877 maybe_mutate (); | |
878 } | |
879 | |
880 octave_value::octave_value (const octave_int32& i) | |
881 : rep (new octave_int32_scalar (i)) | |
882 { | |
883 maybe_mutate (); | |
884 } | |
885 | |
886 octave_value::octave_value (const octave_uint32& i) | |
887 : rep (new octave_uint32_scalar (i)) | |
888 { | |
889 maybe_mutate (); | |
890 } | |
891 | |
892 octave_value::octave_value (const octave_int64& i) | |
893 : rep (new octave_int64_scalar (i)) | |
894 { | |
895 maybe_mutate (); | |
896 } | |
897 | |
898 octave_value::octave_value (const octave_uint64& i) | |
899 : rep (new octave_uint64_scalar (i)) | |
900 { | |
901 maybe_mutate (); | |
902 } | |
903 | |
904 octave_value::octave_value (const int8NDArray& inda) | |
905 : rep (new octave_int8_matrix (inda)) | |
906 { | |
907 maybe_mutate (); | |
908 } | |
909 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
910 octave_value::octave_value (const Array<octave_int8>& inda) |
7064 | 911 : rep (new octave_int8_matrix (inda)) |
912 { | |
913 maybe_mutate (); | |
914 } | |
915 | |
4901 | 916 octave_value::octave_value (const uint8NDArray& inda) |
917 : rep (new octave_uint8_matrix (inda)) | |
918 { | |
919 maybe_mutate (); | |
920 } | |
921 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
922 octave_value::octave_value (const Array<octave_uint8>& inda) |
7064 | 923 : rep (new octave_uint8_matrix (inda)) |
924 { | |
925 maybe_mutate (); | |
926 } | |
927 | |
4901 | 928 octave_value::octave_value (const int16NDArray& inda) |
929 : rep (new octave_int16_matrix (inda)) | |
930 { | |
931 maybe_mutate (); | |
932 } | |
933 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
934 octave_value::octave_value (const Array<octave_int16>& inda) |
7064 | 935 : rep (new octave_int16_matrix (inda)) |
936 { | |
937 maybe_mutate (); | |
938 } | |
939 | |
4901 | 940 octave_value::octave_value (const uint16NDArray& inda) |
941 : rep (new octave_uint16_matrix (inda)) | |
942 { | |
943 maybe_mutate (); | |
944 } | |
945 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
946 octave_value::octave_value (const Array<octave_uint16>& inda) |
7064 | 947 : rep (new octave_uint16_matrix (inda)) |
948 { | |
949 maybe_mutate (); | |
950 } | |
951 | |
4901 | 952 octave_value::octave_value (const int32NDArray& inda) |
953 : rep (new octave_int32_matrix (inda)) | |
954 { | |
955 maybe_mutate (); | |
956 } | |
957 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
958 octave_value::octave_value (const Array<octave_int32>& inda) |
7064 | 959 : rep (new octave_int32_matrix (inda)) |
960 { | |
961 maybe_mutate (); | |
962 } | |
963 | |
4901 | 964 octave_value::octave_value (const uint32NDArray& inda) |
965 : rep (new octave_uint32_matrix (inda)) | |
966 { | |
967 maybe_mutate (); | |
968 } | |
969 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
970 octave_value::octave_value (const Array<octave_uint32>& inda) |
7064 | 971 : rep (new octave_uint32_matrix (inda)) |
972 { | |
973 maybe_mutate (); | |
974 } | |
975 | |
4901 | 976 octave_value::octave_value (const int64NDArray& inda) |
977 : rep (new octave_int64_matrix (inda)) | |
978 { | |
979 maybe_mutate (); | |
980 } | |
981 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
982 octave_value::octave_value (const Array<octave_int64>& inda) |
7064 | 983 : rep (new octave_int64_matrix (inda)) |
984 { | |
985 maybe_mutate (); | |
986 } | |
987 | |
4901 | 988 octave_value::octave_value (const uint64NDArray& inda) |
989 : rep (new octave_uint64_matrix (inda)) | |
990 { | |
991 maybe_mutate (); | |
992 } | |
993 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9728
diff
changeset
|
994 octave_value::octave_value (const Array<octave_uint64>& inda) |
7064 | 995 : rep (new octave_uint64_matrix (inda)) |
996 { | |
997 maybe_mutate (); | |
998 } | |
999 | |
9351
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1000 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
|
1001 bool cache_index) |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1002 : 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
|
1003 { |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1004 maybe_mutate (); |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1005 } |
e2344f4af0cb
autocache indices returned from find et al.
Jaroslav Hajek <highegg@gmail.com>
parents:
9329
diff
changeset
|
1006 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1007 octave_value::octave_value (const octave::idx_vector& idx, bool lazy) |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1008 : rep () |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1009 { |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1010 double scalar; |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1011 octave::range<double> range; |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1012 NDArray array; |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1013 boolNDArray mask; |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1014 octave::idx_vector::idx_class_type idx_class; |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1015 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1016 if (lazy) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1017 { |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1018 // Only make lazy indices out of ranges and index vectors. |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1019 switch (idx.idx_class ()) |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1020 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1021 case octave::idx_vector::class_range: |
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1022 case octave::idx_vector::class_vector: |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1023 rep = new octave_lazy_index (idx); |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1024 maybe_mutate (); |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1025 return; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1026 |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1027 default: |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1028 break; |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1029 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1030 } |
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1031 |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1032 idx.unconvert (idx_class, scalar, range, array, mask); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1033 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1034 switch (idx_class) |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1035 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1036 case octave::idx_vector::class_colon: |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1037 rep = new octave_magic_colon (); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1038 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1039 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1040 case octave::idx_vector::class_range: |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1041 rep = new octave_range (range, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1042 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1043 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1044 case octave::idx_vector::class_scalar: |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1045 rep = new octave_scalar (scalar); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1046 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1047 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1048 case octave::idx_vector::class_vector: |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1049 rep = new octave_matrix (array, idx); |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1050 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1051 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29478
diff
changeset
|
1052 case octave::idx_vector::class_mask: |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9879
diff
changeset
|
1053 rep = new octave_bool_matrix (mask, idx); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1054 break; |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1055 |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1056 default: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
1057 panic_impossible (); |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1058 break; |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1059 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1060 |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1061 // FIXME: needed? |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1062 maybe_mutate (); |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1063 } |
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1064 |
9725 | 1065 octave_value::octave_value (const Array<std::string>& cellstr) |
1066 : rep (new octave_cell (cellstr)) | |
1067 { | |
1068 maybe_mutate (); | |
1069 } | |
1070 | |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1071 // Remove when public constructor that uses this function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1072 octave_base_value * |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1073 make_range_rep_deprecated (double base, double inc, double limit) |
2423 | 1074 { |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1075 return dynamic_cast<octave_base_value *> |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1076 (new ov_range<double> (octave::range<double> (base, inc, limit))); |
2423 | 1077 } |
2376 | 1078 |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1079 // Remove when public constructor that uses this function is removed. |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1080 octave_base_value * |
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1081 make_range_rep_deprecated (const Range& r, bool force_range) |
2423 | 1082 { |
28592
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1083 if (! force_range && ! r.ok ()) |
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1084 error ("invalid range"); |
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1085 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1086 if (force_range || Voptimize_range) |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1087 return make_range_rep_deprecated (r.base (), r.increment (), r.limit ()); |
28592
e70c859c4bff
allow infinite limits on for loop ranges (bug #45143)
John W. Eaton <jwe@octave.org>
parents:
28588
diff
changeset
|
1088 else |
29954
4c88a452519c
rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents:
29930
diff
changeset
|
1089 return dynamic_cast<octave_base_value *> (new octave_matrix (r.matrix_value ())); |
2423 | 1090 } |
2376 | 1091 |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1092 octave_value::octave_value (const octave::range<char>& r, char type, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1093 bool /*force_range*/) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1094 #if 0 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1095 : rep (force_range || optimize_range |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1096 ? dynamic_cast<octave_base_value *> (new octave_char_range (r, type)) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1097 : dynamic_cast<octave_base_value *> (type == '"' |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1098 ? new octave_char_matrix_dq_str (r.array_value ()) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1099 : new octave_char_matrix_sq_str (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1100 #else |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1101 : rep (type == '"' |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1102 ? new octave_char_matrix_dq_str (r.array_value ()) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1103 : new octave_char_matrix_sq_str (r.array_value ())) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1104 #endif |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1105 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1106 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1107 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1108 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1109 octave_value::octave_value (const octave::range<float>& r, bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1110 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1111 ? dynamic_cast<octave_base_value *> (new ov_range<float> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1112 : dynamic_cast<octave_base_value *> (new octave_float_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1113 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1114 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1115 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1116 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1117 octave_value::octave_value (const octave::range<double>& r, bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1118 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1119 ? dynamic_cast<octave_base_value *> (new ov_range<double> (r)) |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1120 : dynamic_cast<octave_base_value *> (new octave_matrix (r.array_value ()))) |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1121 { |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1122 maybe_mutate (); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1123 } |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
1124 |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1125 octave_value::octave_value (const octave::range<octave_int8>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1126 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1127 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1128 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int8> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1129 : dynamic_cast<octave_base_value *> (new octave_int8_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1130 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1131 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1132 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1133 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1134 octave_value::octave_value (const octave::range<octave_int16>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1135 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1136 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1137 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int16> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1138 : dynamic_cast<octave_base_value *> (new octave_int16_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1139 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1140 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1141 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1142 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1143 octave_value::octave_value (const octave::range<octave_int32>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1144 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1145 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1146 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int32> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1147 : dynamic_cast<octave_base_value *> (new octave_int32_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1148 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1149 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1150 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1151 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1152 octave_value::octave_value (const octave::range<octave_int64>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1153 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1154 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1155 ? dynamic_cast<octave_base_value *> (new ov_range<octave_int64> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1156 : dynamic_cast<octave_base_value *> (new octave_int64_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1157 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1158 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1159 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1160 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1161 octave_value::octave_value (const octave::range<octave_uint8>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1162 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1163 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1164 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint8> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1165 : dynamic_cast<octave_base_value *> (new octave_uint8_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1166 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1167 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1168 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1169 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1170 octave_value::octave_value (const octave::range<octave_uint16>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1171 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1172 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1173 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint16> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1174 : dynamic_cast<octave_base_value *> (new octave_uint16_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1175 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1176 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1177 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1178 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1179 octave_value::octave_value (const octave::range<octave_uint32>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1180 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1181 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1182 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint32> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1183 : dynamic_cast<octave_base_value *> (new octave_uint32_matrix (r.array_value ()))) |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1184 { |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1185 maybe_mutate (); |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1186 } |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1187 |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1188 octave_value::octave_value (const octave::range<octave_uint64>& r, |
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1189 bool force_range) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
1190 : rep (force_range || Voptimize_range |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
1191 ? dynamic_cast<octave_base_value *> (new ov_range<octave_uint64> (r)) |
28639
7ebe185e3818
new octave_value constructors for integer and float ranges.
John W. Eaton <jwe@octave.org>
parents:
28638
diff
changeset
|
1192 : dynamic_cast<octave_base_value *> (new octave_uint64_matrix (r.array_value ()))) |
2423 | 1193 { |
1194 maybe_mutate (); | |
1195 } | |
2376 | 1196 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1197 octave_value::octave_value (const octave_map& m) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1198 : rep (new octave_struct (m)) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1199 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1200 maybe_mutate (); |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1201 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1202 |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1203 octave_value::octave_value (const octave_scalar_map& m) |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1204 : rep (new octave_scalar_struct (m)) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
1205 { } |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1206 |
23678
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1207 octave_value::octave_value (const std::map<std::string, octave_value>& m) |
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1208 : rep (new octave_scalar_struct (m)) |
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1209 { } |
dcba41788495
new struct/map constructors
John W. Eaton <jwe@octave.org>
parents:
23614
diff
changeset
|
1210 |
18402
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1211 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
|
1212 const std::list<std::string>& plist) |
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1213 : rep (new octave_class (m, id, plist)) |
2825 | 1214 { |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1215 maybe_mutate (); |
2880 | 1216 } |
1217 | |
18402
4c064d3d2750
Remove Octave_map class deprecated in 3.8.
Rik <rik@octave.org>
parents:
18306
diff
changeset
|
1218 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
|
1219 const std::list<std::string>& plist) |
7dce7e110511
make concatenation of class objects work
John W. Eaton <jwe@octave.org>
parents:
13101
diff
changeset
|
1220 : 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
|
1221 { } |
7336 | 1222 |
23352
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1223 octave_value::octave_value (const octave_value_list& l) |
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1224 : rep (new octave_cs_list (l)) |
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1225 { } |
778fdffc09df
deprecate "octave_value (octave_value_list, bool)" constructor
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
1226 |
2376 | 1227 octave_value::octave_value (octave_value::magic_colon) |
2825 | 1228 : rep (new octave_magic_colon ()) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22390
diff
changeset
|
1229 { } |
2376 | 1230 |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1231 octave_value::octave_value (octave_base_value *new_rep, bool borrow) |
2825 | 1232 : rep (new_rep) |
1233 { | |
9728
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1234 if (borrow) |
70925b11ba46
again allow the obsolete syntax for cellfun
Jaroslav Hajek <highegg@gmail.com>
parents:
9725
diff
changeset
|
1235 rep->count++; |
2825 | 1236 } |
2376 | 1237 |
5759 | 1238 octave_base_value * |
3933 | 1239 octave_value::clone (void) const |
2880 | 1240 { |
10325
8b3cfc1288e2
implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
1241 return rep->clone (); |
2880 | 1242 } |
1243 | |
2409 | 1244 void |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1245 octave_value::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1246 { |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1247 if (is_function_handle ()) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1248 { |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1249 octave_fcn_handle *fhdl = rep->fcn_handle_value (); |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1250 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1251 if (fhdl->is_nested (frame) && ! fhdl->is_weak_nested ()) |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1252 *this = fhdl->make_weak_nested_handle (); |
29477
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
1253 else if (fhdl->is_anonymous () && ! fhdl->is_weak_anonymous ()) |
34d06c73b48d
hold references to closure frames in anon functions if needed (bug #60237)
John W. Eaton <jwe@octave.org>
parents:
29476
diff
changeset
|
1254 *this = fhdl->make_weak_anonymous_handle (); |
29476
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1255 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1256 else |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1257 { |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1258 // FIXME: Is there a efficient way to avoid calling make_unique |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1259 // if REP doesn't contain any nested function handles? |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1260 // |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1261 // Probably we should be asking REP to make a modified copy IFF it |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1262 // is needed, then replace our REP with that if a copy is made, |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1263 // otherwise we leave it alone. |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1264 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1265 make_unique (); |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1266 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1267 rep->break_closure_cycles (frame); |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1268 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1269 } |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1270 |
c74ff452e2bb
avoid memory leaks when returning handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
1271 void |
2409 | 1272 octave_value::maybe_mutate (void) |
1273 { | |
5759 | 1274 octave_base_value *tmp = rep->try_narrowing_conversion (); |
2409 | 1275 |
1276 if (tmp && tmp != rep) | |
1277 { | |
1278 if (--rep->count == 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1279 delete rep; |
2409 | 1280 |
1281 rep = tmp; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1282 } |
2409 | 1283 } |
1284 | |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1285 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1286 |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1287 DEFUN (double, args, , |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1288 doc: /* -*- texinfo -*- |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1289 @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
|
1290 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
|
1291 @seealso{single} |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1292 @end deftypefn */) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1293 { |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1294 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
|
1295 print_usage (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1296 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1297 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
|
1298 } |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1299 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1300 /* |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1301 %!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
|
1302 %!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
|
1303 %!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
|
1304 %!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
|
1305 %!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
|
1306 %!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
|
1307 %!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
|
1308 %!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
|
1309 %!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
|
1310 %!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
|
1311 %!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
|
1312 %!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
|
1313 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1314 %! 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
|
1315 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1316 %! 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
|
1317 %! 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
|
1318 %! assert (issparse (y)); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1319 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1320 %! 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
|
1321 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1322 %! 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
|
1323 %! 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
|
1324 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1325 %! 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
|
1326 %! y = double (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1327 %! 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
|
1328 %! 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
|
1329 */ |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1330 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1331 DEFUN (single, args, , |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1332 doc: /* -*- texinfo -*- |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1333 @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
|
1334 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
|
1335 @seealso{double} |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1336 @end deftypefn */) |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1337 { |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1338 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
|
1339 print_usage (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1340 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1341 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
|
1342 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1343 return ovl (); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1344 } |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1345 |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1346 /* |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1347 %!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
|
1348 %!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
|
1349 %!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
|
1350 %!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
|
1351 %!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
|
1352 %!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
|
1353 %!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
|
1354 %!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
|
1355 %!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
|
1356 %!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
|
1357 %!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
|
1358 %!assert (class (single ("A")), "single") |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28888
diff
changeset
|
1359 %!error single (sparse (1)) |
22283
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1360 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1361 %! 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
|
1362 %! y = single (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1363 %! 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
|
1364 %! 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
|
1365 %!test |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1366 %! 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
|
1367 %! y = single (x); |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1368 %! 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
|
1369 %! 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
|
1370 */ |
564203123065
move single and double type conversion functions to ov.cc
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1371 |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1372 DEFUN (int8, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1373 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1374 @deftypefn {} {} int8 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1375 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
|
1376 @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
|
1377 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1378 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1379 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1380 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1381 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1382 return args(0).as_int8 (); |
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 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1386 %!assert (class (int8 (1)), "int8") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1387 %!assert (int8 (1.25), int8 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1388 %!assert (int8 (1.5), int8 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1389 %!assert (int8 (-1.5), int8 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1390 %!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
|
1391 %!assert (int8 (-2^9), int8 (-2^8)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1392 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1393 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1394 DEFUN (int16, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1395 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1396 @deftypefn {} {} int16 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1397 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
|
1398 @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
|
1399 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1400 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1401 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1402 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1403 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1404 return args(0).as_int16 (); |
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 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1408 %!assert (class (int16 (1)), "int16") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1409 %!assert (int16 (1.25), int16 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1410 %!assert (int16 (1.5), int16 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1411 %!assert (int16 (-1.5), int16 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1412 %!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
|
1413 %!assert (int16 (-2^17), int16 (-2^16)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1414 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1415 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1416 DEFUN (int32, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1417 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1418 @deftypefn {} {} int32 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1419 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
|
1420 @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
|
1421 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1422 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1423 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1424 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1425 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1426 return args(0).as_int32 (); |
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 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1430 %!assert (class (int32 (1)), "int32") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1431 %!assert (int32 (1.25), int32 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1432 %!assert (int32 (1.5), int32 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1433 %!assert (int32 (-1.5), int32 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1434 %!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
|
1435 %!assert (int32 (-2^33), int32 (-2^32)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1436 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1437 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1438 DEFUN (int64, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1439 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1440 @deftypefn {} {} int64 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1441 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
|
1442 @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
|
1443 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1444 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1445 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1446 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1447 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1448 return args(0).as_int64 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1449 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1450 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1451 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1452 %!assert (class (int64 (1)), "int64") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1453 %!assert (int64 (1.25), int64 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1454 %!assert (int64 (1.5), int64 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1455 %!assert (int64 (-1.5), int64 (-2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1456 %!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
|
1457 %!assert (int64 (-2^65), int64 (-2^64)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1458 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1459 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1460 DEFUN (uint8, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1461 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1462 @deftypefn {} {} uint8 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1463 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
|
1464 @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
|
1465 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1466 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1467 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1468 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1469 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1470 return args(0).as_uint8 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1471 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1472 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1473 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1474 %!assert (class (uint8 (1)), "uint8") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1475 %!assert (uint8 (1.25), uint8 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1476 %!assert (uint8 (1.5), uint8 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1477 %!assert (uint8 (-1.5), uint8 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1478 %!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
|
1479 %!assert (uint8 (-2^9), uint8 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1480 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1481 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1482 DEFUN (uint16, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1483 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1484 @deftypefn {} {} uint16 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1485 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
|
1486 @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
|
1487 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1488 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1489 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1490 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1491 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1492 return args(0).as_uint16 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1493 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1494 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1495 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1496 %!assert (class (uint16 (1)), "uint16") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1497 %!assert (uint16 (1.25), uint16 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1498 %!assert (uint16 (1.5), uint16 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1499 %!assert (uint16 (-1.5), uint16 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1500 %!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
|
1501 %!assert (uint16 (-2^17), uint16 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1502 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1503 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1504 DEFUN (uint32, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1505 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1506 @deftypefn {} {} uint32 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1507 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
|
1508 @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
|
1509 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1510 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1511 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1512 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1513 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1514 return args(0).as_uint32 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1515 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1516 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1517 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1518 %!assert (class (uint32 (1)), "uint32") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1519 %!assert (uint32 (1.25), uint32 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1520 %!assert (uint32 (1.5), uint32 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1521 %!assert (uint32 (-1.5), uint32 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1522 %!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
|
1523 %!assert (uint32 (-2^33), uint32 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1524 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1525 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1526 DEFUN (uint64, args, , |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1527 doc: /* -*- texinfo -*- |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1528 @deftypefn {} {} uint64 (@var{x}) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1529 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
|
1530 @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
|
1531 @end deftypefn */) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1532 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1533 if (args.length () != 1) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1534 print_usage (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1535 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1536 return args(0).as_uint64 (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1537 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1538 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1539 /* |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1540 %!assert (class (uint64 (1)), "uint64") |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1541 %!assert (uint64 (1.25), uint64 (1)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1542 %!assert (uint64 (1.5), uint64 (2)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1543 %!assert (uint64 (-1.5), uint64 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1544 %!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
|
1545 %!assert (uint64 (-2^65), uint64 (0)) |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1546 */ |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1547 |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1548 OCTAVE_NAMESPACE_END |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
1549 |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22283
diff
changeset
|
1550 octave_value |
4271 | 1551 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
|
1552 const octave_value_list& idx) |
4247 | 1553 { |
1554 std::list<octave_value_list> i; | |
1555 | |
1556 i.push_back (idx); | |
1557 | |
1558 return rep->subsref (type, i); | |
1559 } | |
1560 | |
2974 | 1561 octave_value_list |
4247 | 1562 octave_value::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1563 const std::list<octave_value_list>& idx, int nargout) |
3933 | 1564 { |
23502
c6714ae1c06c
eliminate remaining do_multi_index_op methods
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
1565 return rep->subsref (type, idx, nargout); |
3933 | 1566 } |
1567 | |
1568 octave_value | |
4247 | 1569 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
|
1570 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1571 std::size_t skip) |
3933 | 1572 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1573 if (idx.size () > skip) |
3933 | 1574 { |
4219 | 1575 std::list<octave_value_list> new_idx (idx); |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1576 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1577 new_idx.erase (new_idx.begin ()); |
3933 | 1578 return subsref (type.substr (skip), new_idx); |
1579 } | |
1580 else | |
1581 return *this; | |
1582 } | |
1583 | |
1584 octave_value_list | |
4994 | 1585 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
|
1586 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1587 std::size_t skip) |
4994 | 1588 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1589 if (idx.size () > skip) |
4994 | 1590 { |
1591 std::list<octave_value_list> new_idx (idx); | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1592 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1593 new_idx.erase (new_idx.begin ()); |
4994 | 1594 return subsref (type.substr (skip), new_idx, nargout); |
1595 } | |
1596 else | |
1597 return *this; | |
1598 } | |
1599 | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1600 octave_value |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1601 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
|
1602 const std::list<octave_value_list>& idx, |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1603 std::size_t skip) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1604 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1605 if (idx.size () > skip) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1606 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1607 std::list<octave_value_list> new_idx (idx); |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29477
diff
changeset
|
1608 for (std::size_t i = 0; i < skip; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1609 new_idx.erase (new_idx.begin ()); |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1610 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
|
1611 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1612 else |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1613 return *this; |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1614 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8531
diff
changeset
|
1615 |
3933 | 1616 octave_value |
4247 | 1617 octave_value::subsasgn (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1618 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1619 const octave_value& rhs) |
3933 | 1620 { |
1621 return rep->subsasgn (type, idx, rhs); | |
1622 } | |
1623 | |
12171
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1624 octave_value |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1625 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
|
1626 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
|
1627 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
|
1628 { |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1629 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
|
1630 } |
d08901c05c1b
fix bug in class assignment to undefined object with index
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1631 |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1632 octave_value& |
4247 | 1633 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
|
1634 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1635 const octave_value& rhs) |
3933 | 1636 { |
1637 make_unique (); | |
1638 | |
1639 octave_value t_rhs = rhs; | |
1640 | |
1641 if (op != op_asn_eq) | |
1642 { | |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1643 if (! is_defined ()) |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1644 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
|
1645 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1646 octave_value t = subsref (type, idx); |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1647 |
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
1648 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
|
1649 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1650 t_rhs = octave::binary_op (binop, t, rhs); |
3933 | 1651 } |
1652 | |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
1653 *this = subsasgn (type, idx, t_rhs); |
3933 | 1654 |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1655 return *this; |
3933 | 1656 } |
1657 | |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1658 octave_value& |
3203 | 1659 octave_value::assign (assign_op op, const octave_value& rhs) |
2880 | 1660 { |
3533 | 1661 if (op == op_asn_eq) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
1662 // 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
|
1663 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
|
1664 else if (is_defined ()) |
3203 | 1665 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1666 octave::type_info::assign_op_fcn f = nullptr; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1667 |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1668 // 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
|
1669 if (rep->count == 1) |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1670 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1671 int tthis = this->type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1672 int trhs = rhs.type_id (); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1673 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1674 octave::type_info& ti |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1675 = octave::__get_type_info__ ("octave_value::assign"); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1676 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
1677 f = ti.lookup_assign_op (op, tthis, trhs); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1678 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1679 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1680 if (f) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1681 { |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1682 f (*rep, octave_value_list (), rhs.get_rep ()); |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
1683 // 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
|
1684 maybe_mutate (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1685 } |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1686 else |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1687 { |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1688 |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1689 binary_op binop = op_eq_to_binary_op (op); |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1690 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1691 octave_value t = octave::binary_op (binop, *this, rhs); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1692 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1693 operator = (t); |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
9479
diff
changeset
|
1694 } |
3204 | 1695 } |
10544
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1696 else |
9961fc022d9d
fix assignment to non-existing variables and octave_value::assign
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
1697 error ("in computed assignment A OP= X, A must be defined first"); |
3204 | 1698 |
3933 | 1699 return *this; |
2376 | 1700 } |
1701 | |
26078
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1702 // FIXME: This is a bit of a kluge. We'd like to just use val.dims() |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1703 // and if val is an object, expect that dims will call size if it is |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1704 // overloaded by a user-defined method. But there are currently some |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1705 // unresolved const issues that prevent that solution from working. |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1706 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1707 std::string |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1708 octave_value::get_dims_str (void) const |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1709 { |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1710 octave_value tmp = *this; |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1711 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1712 Matrix sz = tmp.size (); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1713 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1714 dim_vector dv = dim_vector::alloc (sz.numel ()); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1715 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1716 for (octave_idx_type i = 0; i < dv.ndims (); i++) |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1717 dv(i) = sz(i); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1718 |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1719 return dv.str (); |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1720 } |
0549d088f50e
move get_dims_str from variables.cc to octave_value class
John W. Eaton <jwe@octave.org>
parents:
25927
diff
changeset
|
1721 |
5275 | 1722 octave_idx_type |
4563 | 1723 octave_value::length (void) const |
1724 { | |
10654
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1725 octave_idx_type retval = 0; |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1726 |
984b8b6bee02
simplify octave_value::length
Jaroslav Hajek <highegg@gmail.com>
parents:
10614
diff
changeset
|
1727 const dim_vector dv = dims (); |
4584 | 1728 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1729 for (int i = 0; i < dv.ndims (); i++) |
4563 | 1730 { |
4584 | 1731 if (dv(i) == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1732 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1733 retval = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1734 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1735 } |
4584 | 1736 |
4563 | 1737 if (dv(i) > retval) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1738 retval = dv(i); |
4563 | 1739 } |
1740 | |
1741 return retval; | |
1742 } | |
1743 | |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1744 bool |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1745 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
|
1746 { |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1747 bool retval = false; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1748 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1749 // 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
|
1750 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1751 if (rows () == test.rows () && columns () == test.columns ()) |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1752 { |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
1753 octave_value tmp = octave::binary_op (octave_value::op_eq, *this, test); |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1754 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1755 // 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
|
1756 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
|
1757 { |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23576
diff
changeset
|
1758 if (tmp.isempty ()) |
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
|
1759 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
|
1760 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
|
1761 { |
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
|
1762 // 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
|
1763 // 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
|
1764 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
|
1765 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
|
1766 } |
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
|
1767 } |
8346
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1768 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1769 |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1770 return retval; |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1771 } |
8302788f09db
fix empty matrix handling in switch statement
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
1772 |
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
|
1773 // 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
|
1774 // 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
|
1775 |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1776 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
|
1777 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
|
1778 { |
21229
a83e7a384ee0
create and install a subset of config.h in octave-config.h
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1779 #if defined (OCTAVE_ENABLE_64) |
16323
e769440b39db
provide int64 extractors for octave_value class
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
1780 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
|
1781 #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
|
1782 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
|
1783 #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
|
1784 } |
260294a5520f
octave_value::idx_type_value: move definition to ov.cc from ov.h
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
1785 |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1786 Cell |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1787 octave_value::cell_value (void) const |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1788 { |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1789 return rep->cell_value (); |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1790 } |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
1791 |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1792 octave_map |
2376 | 1793 octave_value::map_value (void) const |
1794 { | |
1795 return rep->map_value (); | |
1796 } | |
1797 | |
10742
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1798 octave_scalar_map |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1799 octave_value::scalar_map_value (void) const |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1800 { |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1801 return rep->scalar_map_value (); |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1802 } |
604e13a89c7f
initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents:
10687
diff
changeset
|
1803 |
2974 | 1804 octave_function * |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1805 octave_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1806 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1807 return rep->function_value (silent); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1808 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7719
diff
changeset
|
1809 |
23881
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1810 octave_classdef * |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1811 octave_value::classdef_object_value (bool silent) const |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1812 { |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1813 return rep->classdef_object_value (silent); |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1814 } |
5aec653c88e7
new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents:
23807
diff
changeset
|
1815 |
4700 | 1816 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
|
1817 octave_value::user_function_value (bool silent) const |
4700 | 1818 { |
1819 return rep->user_function_value (silent); | |
1820 } | |
1821 | |
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
|
1822 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
|
1823 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
|
1824 { |
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
|
1825 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
|
1826 } |
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
|
1827 |
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
|
1828 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
|
1829 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
|
1830 { |
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
|
1831 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
|
1832 } |
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
|
1833 |
4346 | 1834 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
|
1835 octave_value::fcn_handle_value (bool silent) const |
4343 | 1836 { |
1837 return rep->fcn_handle_value (silent); | |
1838 } | |
1839 | |
2880 | 1840 octave_value_list |
1841 octave_value::list_value (void) const | |
1842 { | |
1843 return rep->list_value (); | |
1844 } | |
1845 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1846 static dim_vector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1847 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
|
1848 const std::string& my_type, const std::string& wanted_type) |
3419 | 1849 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1850 dim_vector retval (dv); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1851 retval.chop_trailing_singletons (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1852 octave_idx_type nel = dv.numel (); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1853 |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1854 if (retval.ndims () > 2 || (retval(0) != 1 && retval(1) != 1)) |
3419 | 1855 { |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
1856 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
|
1857 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
|
1858 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
|
1859 retval = dim_vector (nel, 1); |
3419 | 1860 } |
1861 | |
1862 return retval; | |
1863 } | |
1864 | |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1865 ColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1866 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
|
1867 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1868 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1869 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
|
1870 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1871 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1872 |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1873 ComplexColumnVector |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1874 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
|
1875 bool frc_vec_conv) const |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1876 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1877 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
|
1878 frc_vec_conv)); |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1879 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1880 |
3419 | 1881 RowVector |
1882 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
|
1883 bool frc_vec_conv) const |
3419 | 1884 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1885 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
|
1886 frc_vec_conv)); |
3419 | 1887 } |
1888 | |
1889 ComplexRowVector | |
1890 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
|
1891 bool frc_vec_conv) const |
3419 | 1892 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1893 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
|
1894 frc_vec_conv)); |
3419 | 1895 } |
1896 | |
1897 Array<double> | |
2376 | 1898 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
|
1899 bool force_vector_conversion) const |
2376 | 1900 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1901 Array<double> retval = array_value (force_string_conv); |
2376 | 1902 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1903 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
|
1904 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1905 type_name (), "real vector")); |
2376 | 1906 } |
1907 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21129
diff
changeset
|
1908 template <typename T> |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1909 static Array<int> |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23502
diff
changeset
|
1910 convert_to_int_array (const Array<octave_int<T>>& A) |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1911 { |
7999 | 1912 Array<int> retval (A.dims ()); |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1913 octave_idx_type n = A.numel (); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1914 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1915 for (octave_idx_type i = 0; i < n; i++) |
7999 | 1916 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
|
1917 |
7999 | 1918 return retval; |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1919 } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1920 |
4044 | 1921 Array<int> |
20743
b6408331bfa2
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20741
diff
changeset
|
1922 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
|
1923 bool force_vector_conversion) const |
4044 | 1924 { |
1925 Array<int> retval; | |
1926 | |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1927 if (isinteger ()) |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1928 { |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1929 if (is_int32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1930 retval = convert_to_int_array (int32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1931 else if (is_int64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1932 retval = convert_to_int_array (int64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1933 else if (is_int16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1934 retval = convert_to_int_array (int16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1935 else if (is_int8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1936 retval = convert_to_int_array (int8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1937 else if (is_uint32_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1938 retval = convert_to_int_array (uint32_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1939 else if (is_uint64_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1940 retval = convert_to_int_array (uint64_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1941 else if (is_uint16_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1942 retval = convert_to_int_array (uint16_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1943 else if (is_uint8_type ()) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1944 retval = convert_to_int_array (uint8_array_value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1945 else |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7892
diff
changeset
|
1946 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
|
1947 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1948 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1949 { |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1950 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
|
1951 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1952 if (require_int) |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1953 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1954 retval.resize (a.dims ()); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1955 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
|
1956 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1957 double ai = a.elem (i); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1958 int v = static_cast<int> (ai); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1959 if (ai == v) |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1960 retval.xelem (i) = v; |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1961 else |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1962 { |
25927
d6581134daaa
Emit an error when utility matrices (zeros, ones, rand, etc.) are given a fractional dimension in a dimension vector (bug #54781).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
1963 error_with_cfn ("conversion of %g to int value failed", ai); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1964 break; |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1965 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1966 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1967 } |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1968 else |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1969 retval = Array<int> (a); |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1970 } |
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1971 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1972 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
|
1973 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
1974 type_name (), "integer vector")); |
4044 | 1975 } |
1976 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
21129
diff
changeset
|
1977 template <typename T> |
8811 | 1978 static Array<octave_idx_type> |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23502
diff
changeset
|
1979 convert_to_octave_idx_type_array (const Array<octave_int<T>>& A) |
8811 | 1980 { |
1981 Array<octave_idx_type> retval (A.dims ()); | |
1982 octave_idx_type n = A.numel (); | |
1983 | |
1984 for (octave_idx_type i = 0; i < n; i++) | |
1985 retval.xelem (i) = octave_int<octave_idx_type> (A.xelem (i)); | |
1986 | |
1987 return retval; | |
1988 } | |
1989 | |
1990 Array<octave_idx_type> | |
9479
d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
Jaroslav Hajek <highegg@gmail.com>
parents:
9368
diff
changeset
|
1991 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
|
1992 bool force_string_conv, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1993 bool force_vector_conversion) const |
8811 | 1994 { |
1995 Array<octave_idx_type> retval; | |
1996 | |
23580
2230f9e10fb3
maint: Deprecate is_integer_type and replace with isinteger.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1997 if (isinteger ()) |
8811 | 1998 { |
1999 if (is_int32_type ()) | |
2000 retval = convert_to_octave_idx_type_array (int32_array_value ()); | |
2001 else if (is_int64_type ()) | |
2002 retval = convert_to_octave_idx_type_array (int64_array_value ()); | |
2003 else if (is_int16_type ()) | |
2004 retval = convert_to_octave_idx_type_array (int16_array_value ()); | |
2005 else if (is_int8_type ()) | |
2006 retval = convert_to_octave_idx_type_array (int8_array_value ()); | |
2007 else if (is_uint32_type ()) | |
2008 retval = convert_to_octave_idx_type_array (uint32_array_value ()); | |
2009 else if (is_uint64_type ()) | |
2010 retval = convert_to_octave_idx_type_array (uint64_array_value ()); | |
2011 else if (is_uint16_type ()) | |
2012 retval = convert_to_octave_idx_type_array (uint16_array_value ()); | |
2013 else if (is_uint8_type ()) | |
2014 retval = convert_to_octave_idx_type_array (uint8_array_value ()); | |
2015 else | |
2016 retval = array_value (force_string_conv); | |
2017 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2018 else |
8811 | 2019 { |
2020 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
|
2021 |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2022 if (require_int) |
8811 | 2023 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2024 retval.resize (a.dims ()); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2025 for (octave_idx_type i = 0; i < a.numel (); i++) |
8811 | 2026 { |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2027 double ai = a.elem (i); |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2028 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
|
2029 if (ai == v) |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2030 retval.xelem (i) = v; |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2031 else |
8811 | 2032 { |
25927
d6581134daaa
Emit an error when utility matrices (zeros, ones, rand, etc.) are given a fractional dimension in a dimension vector (bug #54781).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
2033 error_with_cfn ("conversion of %g to octave_idx_type value failed", ai); |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2034 break; |
8811 | 2035 } |
2036 } | |
2037 } | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2038 else |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2039 retval = Array<octave_idx_type> (a); |
8811 | 2040 } |
2041 | |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2042 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
|
2043 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2044 type_name (), "integer vector")); |
8811 | 2045 } |
2046 | |
3419 | 2047 Array<Complex> |
2376 | 2048 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
|
2049 bool force_vector_conversion) const |
2376 | 2050 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2051 Array<Complex> retval = complex_array_value (force_string_conv); |
2376 | 2052 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2053 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
|
2054 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2055 type_name (), "complex vector")); |
2376 | 2056 } |
2057 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2058 FloatColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2059 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
|
2060 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2061 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2062 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
|
2063 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2064 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2065 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2066 FloatComplexColumnVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2067 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
|
2068 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2069 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2070 return |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2071 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
|
2072 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2073 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2074 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2075 FloatRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2076 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
|
2077 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2078 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2079 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
|
2080 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2081 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2082 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2083 FloatComplexRowVector |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2084 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
|
2085 bool frc_vec_conv) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2086 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2087 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
|
2088 frc_vec_conv)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2089 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2090 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2091 Array<float> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2092 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
|
2093 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2094 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2095 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
|
2096 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2097 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
|
2098 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2099 type_name (), "real vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2100 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2101 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2102 Array<FloatComplex> |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2103 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
|
2104 bool force_vector_conversion) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2105 { |
7892
7ca2735d74c2
simplify & cleanup octave_value::XXX_vector_value functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
2106 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
|
2107 |
20560
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2108 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
|
2109 force_vector_conversion, |
56fee8f84fe7
eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2110 type_name (), "complex vector")); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2111 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
2112 |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2113 // 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
|
2114 // 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
|
2115 // 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
|
2116 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2117 #define XVALUE_EXTRACTOR(TYPE, NAME, FCN) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2118 TYPE \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2119 octave_value::NAME (const char *fmt, ...) const \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2120 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2121 TYPE retval; \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2122 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2123 try \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2124 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2125 retval = FCN (); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2126 } \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2127 catch (octave::execution_exception& ee) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2128 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2129 if (fmt) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2130 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2131 va_list args; \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2132 va_start (args, fmt); \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2133 verror (ee, fmt, args); \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2134 va_end (args); \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2135 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2136 \ |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28975
diff
changeset
|
2137 throw ee; \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2138 } \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2139 \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
2140 return retval; \ |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2141 } |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2142 |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2143 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
|
2144 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2145 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
|
2146 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2147 XVALUE_EXTRACTOR (int, xint_value, int_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2148 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2149 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
|
2150 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2151 XVALUE_EXTRACTOR (int, xnint_value, nint_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2152 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2153 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
|
2154 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2155 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
|
2156 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2157 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
|
2158 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2159 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
|
2160 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2161 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
|
2162 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2163 XVALUE_EXTRACTOR (double, xdouble_value, double_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2164 XVALUE_EXTRACTOR (float, xfloat_value, float_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2165 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2166 XVALUE_EXTRACTOR (double, xscalar_value, scalar_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2167 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
|
2168 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2169 XVALUE_EXTRACTOR (Matrix, xmatrix_value, matrix_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2170 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
|
2171 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2172 XVALUE_EXTRACTOR (NDArray, xarray_value, array_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2173 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
|
2174 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2175 XVALUE_EXTRACTOR (Complex, xcomplex_value, complex_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2176 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
|
2177 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2178 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
|
2179 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
|
2180 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2181 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
|
2182 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
|
2183 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2184 XVALUE_EXTRACTOR (bool, xbool_value, bool_value) |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2185 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
|
2186 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
|
2187 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2188 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
|
2189 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
|
2190 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2191 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
|
2192 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
|
2193 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
|
2194 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2195 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
|
2196 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
|
2197 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
|
2198 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
|
2199 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2200 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
|
2201 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2207 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
|
2208 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
|
2209 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
|
2210 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
|
2211 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2217 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
|
2218 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
|
2219 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
|
2220 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
|
2221 |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2222 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
|
2223 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
|
2224 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2225 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
|
2226 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
|
2227 |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2228 XVALUE_EXTRACTOR (octave::range<float>, xfloat_range_value, float_range_value) |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
2229 XVALUE_EXTRACTOR (octave::range<double>, xrange_value, range_value) |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2230 XVALUE_EXTRACTOR (octave::range<octave_int8>, xint8_range_value, int8_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2231 XVALUE_EXTRACTOR (octave::range<octave_int16>, xint16_range_value, int16_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2232 XVALUE_EXTRACTOR (octave::range<octave_int32>, xint32_range_value, int32_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2233 XVALUE_EXTRACTOR (octave::range<octave_int64>, xint64_range_value, int64_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2234 XVALUE_EXTRACTOR (octave::range<octave_uint8>, xuint8_range_value, uint8_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2235 XVALUE_EXTRACTOR (octave::range<octave_uint16>, xuint16_range_value, uint16_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2236 XVALUE_EXTRACTOR (octave::range<octave_uint32>, xuint32_range_value, uint32_range_value) |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
2237 XVALUE_EXTRACTOR (octave::range<octave_uint64>, xuint64_range_value, uint64_range_value) |
20703
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2238 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2239 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
|
2240 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
|
2241 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2242 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
|
2243 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
|
2244 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2245 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
|
2246 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
|
2247 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2248 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
|
2249 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
|
2250 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2251 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
|
2252 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
|
2253 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2254 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
|
2255 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
|
2256 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2257 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
|
2258 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
|
2259 |
85e5efae848a
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20700
diff
changeset
|
2260 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
|
2261 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
|
2262 |
20741
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2263 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
|
2264 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
|
2265 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
|
2266 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
|
2267 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
|
2268 |
a5ab31b52ae8
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20704
diff
changeset
|
2269 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
|
2270 |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2271 #undef XVALUE_EXTRACTOR |
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20687
diff
changeset
|
2272 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2273 octave_value |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2274 octave_value::storable_value (void) const |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2275 { |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2276 octave_value retval = *this; |
23589
63950abd2f81
maint: Deprecate is_null_type and replace with isnull.
Rik <rik@octave.org>
parents:
23587
diff
changeset
|
2277 if (isnull ()) |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2278 retval = octave_value (rep->empty_clone ()); |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2279 else if (is_magic_int ()) |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2280 retval = octave_value (rep->double_value ()); |
29353
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2281 else if (is_range () && ! rep->is_storable ()) |
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2282 error ("range with infinite number of elements cannot be stored"); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2283 else |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2284 retval.maybe_economize (); |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2285 |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2286 return retval; |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2287 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2288 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2289 void |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2290 octave_value::make_storable_value (void) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2291 { |
23589
63950abd2f81
maint: Deprecate is_null_type and replace with isnull.
Rik <rik@octave.org>
parents:
23587
diff
changeset
|
2292 if (isnull ()) |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2293 { |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2294 octave_base_value *rc = rep->empty_clone (); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2295 if (--rep->count == 0) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2296 delete rep; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2297 rep = rc; |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2298 } |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2299 else if (is_magic_int ()) |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2300 { |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2301 octave_base_value *rc = new octave_scalar (rep->double_value ()); |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2302 if (--rep->count == 0) |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2303 delete rep; |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2304 rep = rc; |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
2305 } |
29353
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2306 else if (is_range () && ! rep->is_storable ()) |
715344f405f0
improve handling of nan, infinite value, and empty ranges (bug #59229)
John W. Eaton <jwe@octave.org>
parents:
29163
diff
changeset
|
2307 error ("range with infinite number of elements cannot be stored"); |
8523
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2308 else |
ad3afaaa19c1
implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
2309 maybe_economize (); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2310 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
8039
diff
changeset
|
2311 |
24668
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2312 float_display_format |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2313 octave_value::get_edit_display_format (void) const |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2314 { |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2315 return rep->get_edit_display_format (); |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2316 } |
d4dd741b2794
new octave_value functions for formatting output
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
2317 |
4944 | 2318 int |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2319 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
|
2320 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
|
2321 octave::mach_info::float_format flt_fmt) const |
4944 | 2322 { |
2323 return rep->write (os, block_size, output_type, skip, flt_fmt); | |
2324 } | |
2325 | |
3933 | 2326 void |
2327 octave_value::print_info (std::ostream& os, const std::string& prefix) const | |
2328 { | |
2329 os << prefix << "type_name: " << type_name () << "\n" | |
2330 << prefix << "count: " << get_count () << "\n" | |
2331 << prefix << "rep info: "; | |
2332 | |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23804
diff
changeset
|
2333 rep->print_info (os, prefix + ' '); |
3933 | 2334 } |
2335 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2336 void * |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2337 octave_value::mex_get_data (mxClassID class_id, mxComplexity complexity) const |
3203 | 2338 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2339 // If class_id is set to mxUNKNOWN_CLASS, return data for any type. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2340 // Otherwise, require that REP matches the requested type and |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2341 // complexity. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2342 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2343 if (class_id != mxUNKNOWN_CLASS) |
3203 | 2344 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2345 bool type_ok = false; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2346 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2347 switch (class_id) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2348 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2349 case mxDOUBLE_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2350 type_ok = is_double_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2351 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2352 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2353 case mxSINGLE_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2354 type_ok = is_single_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2355 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2356 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2357 case mxINT8_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2358 type_ok = is_int8_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2359 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2360 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2361 case mxINT16_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2362 type_ok = is_int16_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2363 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2364 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2365 case mxINT32_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2366 type_ok = is_int32_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2367 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2368 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2369 case mxINT64_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2370 type_ok = is_int64_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2371 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2372 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2373 case mxUINT8_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2374 type_ok = is_uint8_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2375 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2376 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2377 case mxUINT16_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2378 type_ok = is_uint16_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2379 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2380 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2381 case mxUINT32_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2382 type_ok = is_uint32_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2383 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2384 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2385 case mxUINT64_CLASS: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2386 type_ok = is_uint64_type (); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2387 break; |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2388 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2389 default: |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2390 // We only expect to see numeric types explicitly requested. |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2391 error ("mex_get_data: unexpected type requested"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2392 } |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2393 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2394 if (! type_ok) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2395 error ("mex_get_data: type mismatch"); |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2396 |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2397 if (complexity == mxCOMPLEX && ! iscomplex ()) |
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2398 error ("mex_get_data: objectis not complex as requested"); |
3203 | 2399 } |
2400 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
2401 return rep->mex_get_data (); |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2402 } |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2403 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2404 OCTAVE_NORETURN static void |
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2405 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
|
2406 const std::string& tn) |
3203 | 2407 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
15428
diff
changeset
|
2408 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
|
2409 op.c_str (), tn.c_str ()); |
3203 | 2410 } |
2411 | |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2412 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2413 err_unary_op (const std::string& on, const std::string& tn) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2414 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2415 error ("unary operator '%s' not implemented for '%s' operands", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2416 on.c_str (), tn.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2417 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2418 |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2419 octave_value& |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2420 octave_value::non_const_unary_op (unary_op op) |
3203 | 2421 { |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2422 if (op == op_incr || op == op_decr) |
3203 | 2423 { |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
2424 // 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
|
2425 // 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
|
2426 // be confusing. |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2427 if (is_undefined ()) |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2428 { |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2429 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
|
2430 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
|
2431 op_str.c_str (), op_str.c_str ()); |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2432 return *this; |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2433 } |
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2434 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2435 // Genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2436 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2437 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2438 octave::type_info& ti = octave::__get_type_info__ ("non_const_unary_op"); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2439 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2440 octave::type_info::non_const_unary_op_fcn f |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2441 = ti.lookup_non_const_unary_op (op, t); |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2442 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2443 if (f) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2444 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2445 make_unique (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2446 |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
2447 f (*rep); |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2448 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2449 else |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2450 { |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2451 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
|
2452 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2453 if (! cf) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2454 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
|
2455 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2456 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
|
2457 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2458 if (! tmp) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2459 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
|
2460 (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
|
2461 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2462 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
|
2463 rep = tmp; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2464 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2465 t = type_id (); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2466 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2467 f = ti.lookup_non_const_unary_op (op, t); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2468 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2469 if (f) |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2470 { |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2471 f (*rep); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2472 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2473 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
|
2474 delete old_rep; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2475 } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2476 else |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2477 { |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2478 if (old_rep) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2479 { |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2480 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
|
2481 delete rep; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2482 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2483 rep = old_rep; |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2484 } |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2485 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2486 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
|
2487 type_name ()); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
2488 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2489 } |
3203 | 2490 } |
2491 else | |
2492 { | |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2493 // Non-genuine. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2494 int t = type_id (); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2495 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2496 octave::type_info::non_const_unary_op_fcn f = nullptr; |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2497 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2498 // 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
|
2499 if (rep->count == 1) |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2500 { |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2501 octave::type_info& ti |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2502 = octave::__get_type_info__ ("non_const_unary_op"); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2503 |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2504 f = ti.lookup_non_const_unary_op (op, t); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
2505 } |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2506 |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
2507 if (f) |
20535
b70cc4bd8109
begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents:
20232
diff
changeset
|
2508 f (*rep); |
3203 | 2509 else |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2510 *this = octave::unary_op (op, *this); |
3203 | 2511 } |
3933 | 2512 |
2513 return *this; | |
3203 | 2514 } |
2515 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2516 octave_value& |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2517 octave_value::non_const_unary_op (unary_op op, const std::string& type, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2518 const std::list<octave_value_list>& idx) |
3933 | 2519 { |
2520 if (idx.empty ()) | |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2521 non_const_unary_op (op); |
3933 | 2522 else |
2523 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2524 // FIXME: only do the following stuff if we can't find a |
3933 | 2525 // specific function to call to handle the op= operation for the |
2526 // types we have. | |
3205 | 2527 |
3933 | 2528 assign_op assop = unary_op_to_assign_op (op); |
2529 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2530 assign (assop, type, idx, 1.0); |
3933 | 2531 } |
2532 | |
10614
d1194069e58c
optimize code handling ++,--
Jaroslav Hajek <highegg@gmail.com>
parents:
10544
diff
changeset
|
2533 return *this; |
3205 | 2534 } |
2535 | |
2536 octave_value::assign_op | |
2537 octave_value::unary_op_to_assign_op (unary_op op) | |
2538 { | |
2539 switch (op) | |
2540 { | |
3533 | 2541 case op_incr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2542 return op_add_eq; |
3205 | 2543 |
3533 | 2544 case op_decr: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2545 return op_sub_eq; |
3205 | 2546 |
2547 default: | |
2548 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2549 std::string on = unary_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2550 error ("operator %s: no assign operator found", on.c_str ()); |
3205 | 2551 } |
2552 } | |
2553 } | |
2554 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2555 octave_value::binary_op |
3204 | 2556 octave_value::op_eq_to_binary_op (assign_op op) |
2557 { | |
2558 switch (op) | |
2559 { | |
3533 | 2560 case op_add_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2561 return op_add; |
3204 | 2562 |
3533 | 2563 case op_sub_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2564 return op_sub; |
3204 | 2565 |
3533 | 2566 case op_mul_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2567 return op_mul; |
3204 | 2568 |
3533 | 2569 case op_div_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2570 return op_div; |
3204 | 2571 |
3533 | 2572 case op_ldiv_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2573 return op_ldiv; |
3204 | 2574 |
4018 | 2575 case op_pow_eq: |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2576 return op_pow; |
3204 | 2577 |
3533 | 2578 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
|
2579 return op_el_mul; |
3204 | 2580 |
3533 | 2581 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
|
2582 return op_el_div; |
3204 | 2583 |
3533 | 2584 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
|
2585 return op_el_ldiv; |
3204 | 2586 |
4018 | 2587 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
|
2588 return op_el_pow; |
4018 | 2589 |
3533 | 2590 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
|
2591 return op_el_and; |
3204 | 2592 |
3533 | 2593 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
|
2594 return op_el_or; |
3204 | 2595 |
2596 default: | |
2597 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2598 std::string on = assign_op_as_string (op); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2599 error ("operator %s: no binary operator found", on.c_str ()); |
3204 | 2600 } |
2601 } | |
2602 } | |
2603 | |
3933 | 2604 octave_value |
2605 octave_value::empty_conv (const std::string& type, const octave_value& rhs) | |
2606 { | |
2607 if (type.length () > 0) | |
2608 { | |
2609 switch (type[0]) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2610 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2611 case '(': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2612 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
|
2613 return octave_map (); |
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2614 else |
21295
29a0e9e70879
* ov.h: Fix typo in previous change.
John W. Eaton <jwe@octave.org>
parents:
21294
diff
changeset
|
2615 return octave_value (rhs.empty_clone ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2616 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2617 case '{': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2618 return Cell (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2619 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2620 case '.': |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2621 return octave_scalar_map (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2622 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2623 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2624 panic_impossible (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
2625 } |
3933 | 2626 } |
2627 else | |
21293
350caa6afadf
* ov.cc: Use consistent style for switch statements.
John W. Eaton <jwe@octave.org>
parents:
21229
diff
changeset
|
2628 return octave_value (rhs.empty_clone ()); |
3933 | 2629 } |
2630 | |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2631 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
2632 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2633 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2634 err_binary_op (const std::string& on, const std::string& tn1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2635 const std::string& tn2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2636 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2637 error ("binary operator '%s' not implemented for '%s' by '%s' operations", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2638 on.c_str (), tn1.c_str (), tn2.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2639 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2640 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2641 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2642 err_binary_op_conv (const std::string& on) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2643 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2644 error ("type conversion failed for binary operator '%s'", on.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2645 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2646 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2647 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2648 binary_op (type_info& ti, octave_value::binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2649 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2650 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2651 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2652 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2653 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2654 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2655 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2656 if (t1 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2657 || t2 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2658 || t1 == octave_classdef::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2659 || t2 == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2660 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2661 type_info::binary_class_op_fcn f = ti.lookup_binary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2662 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2663 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2664 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2665 v1.class_name (), v2.class_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2666 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2667 retval = f (v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2668 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2669 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2670 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2671 // FIXME: we need to handle overloading operators for built-in |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2672 // classes (double, char, int8, etc.) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2673 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2674 type_info::binary_op_fcn f |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2675 = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2676 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2677 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2678 retval = f (v1.get_rep (), v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2679 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2680 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2681 octave_value tv1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2682 octave_base_value::type_conv_info cf1 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2683 = v1.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2684 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2685 octave_value tv2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2686 octave_base_value::type_conv_info cf2 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2687 = v2.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2688 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2689 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2690 if (cf2.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2691 && ti.lookup_binary_op (op, t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2692 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2693 else if (cf1.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2694 && ti.lookup_binary_op (op, cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2695 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2696 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2697 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2698 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2699 octave_base_value *tmp = cf1 (v1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2700 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2701 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2702 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2703 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2704 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2705 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2706 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2707 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2708 tv1 = v1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2709 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2710 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2711 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2712 octave_base_value *tmp = cf2 (v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2713 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2714 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2715 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2716 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2717 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2718 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2719 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2720 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2721 tv2 = v2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2722 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2723 if (cf1 || cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2724 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2725 retval = binary_op (op, tv1, tv2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2726 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2727 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2728 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2729 //demote double -> single and try again |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2730 cf1 = tv1.numeric_demotion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2731 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2732 cf2 = tv2.numeric_demotion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2733 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2734 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2735 if (cf2.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2736 && ti.lookup_binary_op (op, t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2737 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2738 else if (cf1.type_id () >= 0 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2739 && ti.lookup_binary_op (op, cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2740 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2741 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2742 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2743 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2744 octave_base_value *tmp = cf1 (tv1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2745 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2746 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2747 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2748 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2749 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2750 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2751 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2752 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2753 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2754 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2755 octave_base_value *tmp = cf2 (tv2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2756 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2757 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2758 err_binary_op_conv (octave_value::binary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2759 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2760 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2761 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2762 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2763 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2764 if (! cf1 && ! cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2765 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2766 v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2767 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2768 f = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2769 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2770 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2771 err_binary_op (octave_value::binary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2772 v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2773 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2774 retval = f (tv1.get_rep (), tv2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2775 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2776 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2777 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2778 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2779 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2780 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2781 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2782 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2783 binary_op (octave_value::binary_op op, const octave_value& v1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2784 const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2785 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2786 type_info& ti = __get_type_info__ ("binary_op"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2787 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2788 return binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2789 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2790 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2791 static octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2792 decompose_binary_op (type_info& ti, octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2793 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2794 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2795 switch (op) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2796 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2797 case octave_value::op_trans_mul: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2798 return binary_op (octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2799 unary_op (octave_value::op_transpose, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2800 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2801 case octave_value::op_mul_trans: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2802 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2803 v1, unary_op (octave_value::op_transpose, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2804 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2805 case octave_value::op_herm_mul: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2806 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2807 unary_op (octave_value::op_hermitian, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2808 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2809 case octave_value::op_mul_herm: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2810 return binary_op (ti, octave_value::op_mul, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2811 v1, unary_op (octave_value::op_hermitian, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2812 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2813 case octave_value::op_trans_ldiv: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2814 return binary_op (ti, octave_value::op_ldiv, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2815 unary_op (octave_value::op_transpose, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2816 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2817 case octave_value::op_herm_ldiv: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2818 return binary_op (ti, octave_value::op_ldiv, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2819 unary_op (octave_value::op_hermitian, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2820 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2821 case octave_value::op_el_not_and: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2822 return binary_op (ti, octave_value::op_el_and, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2823 unary_op (octave_value::op_not, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2824 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2825 case octave_value::op_el_not_or: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2826 return binary_op (ti, octave_value::op_el_or, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2827 unary_op (octave_value::op_not, v1), v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2828 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2829 case octave_value::op_el_and_not: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2830 return binary_op (ti, octave_value::op_el_and, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2831 v1, unary_op (octave_value::op_not, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2832 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2833 case octave_value::op_el_or_not: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2834 return binary_op (ti, octave_value::op_el_or, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2835 v1, unary_op (octave_value::op_not, v2)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2836 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2837 default: |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2838 error ("invalid compound operator"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2839 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2840 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2841 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2842 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2843 binary_op (type_info& ti, octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2844 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2845 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2846 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2847 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2848 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2849 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2850 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2851 if (t1 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2852 || t2 == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2853 || t1 == octave_classdef::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2854 || t2 == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2855 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2856 type_info::binary_class_op_fcn f = ti.lookup_binary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2857 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2858 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2859 retval = f (v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2860 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2861 retval = decompose_binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2862 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2863 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2864 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2865 type_info::binary_op_fcn f = ti.lookup_binary_op (op, t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2866 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2867 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2868 retval = f (v1.get_rep (), v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2869 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2870 retval = decompose_binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2871 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2872 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2873 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2874 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2875 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2876 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2877 binary_op (octave_value::compound_binary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2878 const octave_value& v1, const octave_value& v2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2879 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2880 type_info& ti = __get_type_info__ ("binary_op"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2881 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2882 return binary_op (ti, op, v1, v2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2883 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2884 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2885 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2886 err_cat_op (const std::string& tn1, const std::string& tn2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2887 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2888 error ("concatenation operator not implemented for '%s' by '%s' operations", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2889 tn1.c_str (), tn2.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2890 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2891 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2892 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2893 err_cat_op_conv (void) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2894 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2895 error ("type conversion failed for concatenation operator"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2896 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2897 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2898 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2899 cat_op (type_info& ti, const octave_value& v1, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2900 const octave_value& v2, const Array<octave_idx_type>& ra_idx) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2901 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2902 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2903 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2904 // Can't rapid return for concatenation with an empty object here as |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2905 // something like cat(1,[],single([]) must return the correct type. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2906 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2907 int t1 = v1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2908 int t2 = v2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2909 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2910 type_info::cat_op_fcn f = ti.lookup_cat_op (t1, t2); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2911 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2912 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2913 retval = f (v1.get_rep (), v2.get_rep (), ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2914 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2915 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2916 octave_value tv1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2917 octave_base_value::type_conv_info cf1 = v1.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2918 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2919 octave_value tv2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2920 octave_base_value::type_conv_info cf2 = v2.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2921 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2922 // Try biased (one-sided) conversions first. |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2923 if (cf2.type_id () >= 0 && ti.lookup_cat_op (t1, cf2.type_id ())) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2924 cf1 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2925 else if (cf1.type_id () >= 0 && ti.lookup_cat_op (cf1.type_id (), t2)) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2926 cf2 = nullptr; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2927 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2928 if (cf1) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2929 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2930 octave_base_value *tmp = cf1 (v1.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2931 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2932 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2933 err_cat_op_conv (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2934 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2935 tv1 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2936 t1 = tv1.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2937 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2938 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2939 tv1 = v1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2940 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2941 if (cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2942 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2943 octave_base_value *tmp = cf2 (v2.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2944 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2945 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2946 err_cat_op_conv (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2947 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2948 tv2 = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2949 t2 = tv2.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2950 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2951 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2952 tv2 = v2; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2953 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2954 if (! cf1 && ! cf2) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2955 err_cat_op (v1.type_name (), v2.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2956 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2957 retval = cat_op (ti, tv1, tv2, ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2958 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2959 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2960 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2961 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2962 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2963 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2964 cat_op (const octave_value& v1, const octave_value& v2, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2965 const Array<octave_idx_type>& ra_idx) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2966 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2967 type_info& ti = __get_type_info__ ("cat_op"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2968 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2969 return cat_op (ti, v1, v2, ra_idx); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2970 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
2971 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2972 // Unless the colon operator is used with a class or classdef object, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2973 // then all arguments must be the same type or mixed with double |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2974 // values. |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2975 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2976 static builtin_type_t |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2977 get_colon_op_type (builtin_type_t op1_type, builtin_type_t op2_type) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2978 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2979 if (op1_type == op2_type) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2980 return op1_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2981 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2982 if (op1_type == btyp_double) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2983 return op2_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2984 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2985 if (op2_type == btyp_double) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2986 return op1_type; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2987 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2988 return btyp_unknown; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2989 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2990 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2991 static builtin_type_t |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2992 get_colon_op_type (const octave_value& base, const octave_value& increment, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2993 const octave_value& limit) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2994 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2995 builtin_type_t typ |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2996 = get_colon_op_type (base.builtin_type (), increment.builtin_type ()); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2997 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2998 if (typ == btyp_unknown) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
2999 return typ; |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3000 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3001 return get_colon_op_type (typ, limit.builtin_type ()); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3002 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3003 |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3004 // Templated version used for various integer types (int8, uint16, ...) |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3005 template <typename T> |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3006 octave_value |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3007 make_range (const octave_value& base, const octave_value& increment, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3008 const octave_value& limit, bool for_cmd_expr) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3009 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3010 if (base.isempty () || increment.isempty () || limit.isempty ()) |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28646
diff
changeset
|
3011 return octave_value (range<T> (), for_cmd_expr); |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3012 |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3013 double dval; |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3014 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3015 T base_val = octave_value_extract<T> (base); |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3016 dval = base.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3017 if (base_val != dval) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3018 error ("colon operator lower bound invalid (not an integer or out of range for given integer type)"); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3019 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3020 T increment_val = octave_value_extract<T> (increment); |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3021 dval = increment.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3022 if (increment_val != dval) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3023 error ("colon operator increment invalid (not an integer or out of range for given integer type)"); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3024 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3025 T limit_val = octave_value_extract<T> (limit); |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3026 dval = limit.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3027 if (limit_val != dval) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3028 error ("colon operator upper bound invalid (not an integer or out of range for given integer type)"); |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3029 |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28646
diff
changeset
|
3030 range<T> r (base_val, increment_val, limit_val); |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3031 |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3032 return octave_value (r, for_cmd_expr); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3033 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3034 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3035 template <> |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3036 octave_value |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3037 make_range<double> (const octave_value& base, const octave_value& increment, |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3038 const octave_value& limit, bool for_cmd_expr) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3039 { |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3040 if (base.isempty () || increment.isempty () || limit.isempty ()) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3041 return octave_value (range<double> (), for_cmd_expr); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3042 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3043 double base_val = base.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3044 double increment_val = increment.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3045 double limit_val = limit.double_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3046 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3047 range<double> r (base_val, increment_val, limit_val); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3048 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3049 return octave_value (r, for_cmd_expr); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3050 } |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3051 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3052 template <> |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3053 octave_value |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3054 make_range<float> (const octave_value& base, const octave_value& increment, |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3055 const octave_value& limit, bool for_cmd_expr) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3056 { |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3057 if (base.isempty () || increment.isempty () || limit.isempty ()) |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3058 return octave_value (range<float> (), for_cmd_expr); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3059 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3060 float base_val = base.float_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3061 float increment_val = increment.float_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3062 float limit_val = limit.float_value (); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3063 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3064 range<float> r (base_val, increment_val, limit_val); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3065 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3066 return octave_value (r, for_cmd_expr); |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3067 } |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3068 |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3069 template <> |
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3070 octave_value |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3071 make_range<char> (const octave_value& base, const octave_value& increment, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3072 const octave_value& limit, bool for_cmd_expr) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3073 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3074 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3075 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3076 bool dq_str = (base.is_dq_string () || increment.is_dq_string () |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3077 || limit.is_dq_string ()); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3078 |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3079 char type = dq_str ? '"' : '\''; |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3080 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3081 if (base.isempty () || increment.isempty () || limit.isempty ()) |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3082 retval = octave_value ("", type); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3083 else |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3084 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3085 Matrix mtx_base = base.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3086 Matrix mtx_increment = increment.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3087 Matrix mtx_limit = limit.matrix_value (true); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3088 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3089 range<double> tmp (mtx_base(0), mtx_increment(0), mtx_limit(0)); |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3090 |
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3091 retval = octave_value (tmp, for_cmd_expr); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3092 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3093 |
28638
98192ec1621f
replace Range with range<double>
John W. Eaton <jwe@octave.org>
parents:
28633
diff
changeset
|
3094 return retval.convert_to_str (false, true, type); |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3095 } |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3096 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3097 octave_value |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3098 colon_op (const octave_value& base, const octave_value& increment_arg, |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3099 const octave_value& limit, bool is_for_cmd_expr) |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3100 { |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3101 if (base.isobject () || increment_arg.isobject () || limit.isobject ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3102 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3103 octave_value_list tmp1; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3104 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3105 if (increment_arg.is_defined ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3106 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3107 tmp1(2) = limit; |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3108 tmp1(1) = increment_arg; |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3109 tmp1(0) = base; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3110 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3111 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3112 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3113 tmp1(1) = limit; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3114 tmp1(0) = base; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3115 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3116 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3117 interpreter& interp = __get_interpreter__ ("colon_op"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3118 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3119 symbol_table& symtab = interp.get_symbol_table (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3120 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3121 octave_value fcn = symtab.find_function ("colon", tmp1); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3122 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3123 if (fcn.is_defined ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3124 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3125 octave_value_list tmp2 = interp.feval (fcn, tmp1, 1); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3126 |
29410
65979d33f147
Emit error if integer/floating point inputs to colon operator are incompatible (bug #59899).
Rik <rik@octave.org>
parents:
29369
diff
changeset
|
3127 return tmp2(0); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3128 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3129 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3130 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3131 octave_value increment |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3132 = increment_arg.is_defined () ? increment_arg : octave_value (1.0); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3133 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3134 if (base.numel () > 1 || limit.numel () > 1 || increment.numel () > 1) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3135 warning_with_id ("Octave:colon-nonscalar-argument", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3136 "colon arguments should be scalars"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3137 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3138 if (base.iscomplex () || limit.iscomplex () || increment.iscomplex ()) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3139 warning_with_id ("Octave:colon-complex-argument", |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3140 "imaginary part of complex colon arguments is ignored"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3141 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3142 // FIXME: is there a better way to do this job, maybe using type traits? |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3143 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3144 builtin_type_t type_id = get_colon_op_type (base, increment, limit); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3145 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3146 // For compatibility with Matlab, don't allow the range used in |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3147 // a FOR loop expression to be converted to a Matrix. |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3148 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3149 switch (type_id) |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3150 { |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3151 case btyp_double: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3152 case btyp_complex: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3153 return make_range<double> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3154 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3155 case btyp_float: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3156 case btyp_float_complex: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3157 return make_range<float> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3158 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3159 case btyp_int8: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3160 return make_range<octave_int8> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3161 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3162 case btyp_int16: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3163 return make_range<octave_int16> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3164 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3165 case btyp_int32: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3166 return make_range<octave_int32> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3167 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3168 case btyp_int64: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3169 return make_range<octave_int64> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3170 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3171 case btyp_uint8: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3172 return make_range<octave_uint8> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3173 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3174 case btyp_uint16: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3175 return make_range<octave_uint16> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3176 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3177 case btyp_uint32: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3178 return make_range<octave_uint32> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3179 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3180 case btyp_uint64: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3181 return make_range<octave_uint64> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3182 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3183 case btyp_char: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3184 return make_range<char> (base, increment, limit, is_for_cmd_expr); |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3185 |
29369
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3186 case btyp_unknown: |
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3187 error ("incompatible types found in range expression"); |
c75996cbe3ba
Emit more specific error when two different integer types used in range (bug #59899).
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
3188 |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3189 default: |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3190 error ("invalid types found in range expression"); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3191 } |
28633
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3192 |
c897ec8fb5d1
refactor octave_value colon_op function
John W. Eaton <jwe@octave.org>
parents:
28631
diff
changeset
|
3193 return octave_value (); |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3194 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3195 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3196 OCTAVE_NORETURN static void |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3197 err_unary_op_conv (const std::string& on) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3198 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3199 error ("type conversion failed for unary operator '%s'", on.c_str ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3200 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3201 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3202 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3203 unary_op (type_info& ti, octave_value::unary_op op, |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3204 const octave_value& v) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3205 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3206 octave_value retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3207 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3208 int t = v.type_id (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3209 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3210 if (t == octave_class::static_type_id () |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3211 || t == octave_classdef::static_type_id ()) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3212 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3213 type_info::unary_class_op_fcn f = ti.lookup_unary_class_op (op); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3214 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3215 if (! f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3216 err_unary_op (octave_value::unary_op_as_string (op), v.class_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3217 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3218 retval = f (v); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3219 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3220 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3221 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3222 // FIXME: we need to handle overloading operators for built-in |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3223 // classes (double, char, int8, etc.) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3224 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3225 type_info::unary_op_fcn f = ti.lookup_unary_op (op, t); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3226 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3227 if (f) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3228 retval = f (v.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3229 else |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3230 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3231 octave_value tv; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3232 octave_base_value::type_conv_fcn cf |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3233 = v.numeric_conversion_function (); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3234 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3235 if (! cf) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3236 err_unary_op (octave_value::unary_op_as_string (op), |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3237 v.type_name ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3238 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3239 octave_base_value *tmp = cf (v.get_rep ()); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3240 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3241 if (! tmp) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3242 err_unary_op_conv (octave_value::unary_op_as_string (op)); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3243 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3244 tv = octave_value (tmp); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3245 retval = unary_op (op, tv); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3246 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3247 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3248 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3249 return retval; |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3250 } |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3251 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3252 octave_value |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3253 unary_op (octave_value::unary_op op, const octave_value& v) |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3254 { |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3255 type_info& ti = __get_type_info__ ("unary_op"); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3256 |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3257 return unary_op (ti, op, v); |
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3258 } |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
3259 |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
3260 OCTAVE_NAMESPACE_END |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28592
diff
changeset
|
3261 |
2376 | 3262 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3263 install_types (octave::type_info& ti) |
2376 | 3264 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3265 octave_base_value::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3266 octave_cell::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3267 octave_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3268 octave_complex::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3269 octave_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3270 octave_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3271 octave_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3272 octave_complex_diag_matrix::register_type (ti); |
28646
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3273 ov_range<float>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3274 ov_range<double>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3275 ov_range<octave_int8>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3276 ov_range<octave_int16>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3277 ov_range<octave_int32>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3278 ov_range<octave_int64>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3279 ov_range<octave_uint8>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3280 ov_range<octave_uint16>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3281 ov_range<octave_uint32>::register_type (ti); |
e26201931ea3
new template class for octave_range objects
John W. Eaton <jwe@octave.org>
parents:
28639
diff
changeset
|
3282 ov_range<octave_uint64>::register_type (ti); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3283 octave_bool::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3284 octave_bool_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3285 octave_char_matrix_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3286 octave_char_matrix_sq_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3287 octave_int8_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3288 octave_int16_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3289 octave_int32_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3290 octave_int64_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3291 octave_uint8_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3292 octave_uint16_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3293 octave_uint32_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3294 octave_uint64_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3295 octave_int8_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3296 octave_int16_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3297 octave_int32_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3298 octave_int64_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3299 octave_uint8_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3300 octave_uint16_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3301 octave_uint32_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3302 octave_uint64_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3303 octave_sparse_bool_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3304 octave_sparse_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3305 octave_sparse_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3306 octave_struct::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3307 octave_scalar_struct::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3308 octave_class::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3309 octave_cs_list::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3310 octave_magic_colon::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3311 octave_builtin::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3312 octave_user_function::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3313 octave_dld_function::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3314 octave_fcn_handle::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3315 octave_float_scalar::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3316 octave_float_complex::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3317 octave_float_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3318 octave_float_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3319 octave_float_complex_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3320 octave_float_complex_diag_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3321 octave_perm_matrix::register_type (ti); |
28588
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
3322 octave_magic_int::register_type (ti); |
ee9b1081471f
allow integer constants > flintmax to be represented exactly (bug #45945)
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
3323 octave_magic_uint::register_type (ti); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3324 octave_null_matrix::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3325 octave_null_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3326 octave_null_sq_str::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3327 octave_lazy_index::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3328 octave_oncleanup::register_type (ti); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
3329 octave_java::register_type (ti); |
2376 | 3330 } |
3331 | |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
3332 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
3333 |
4791 | 3334 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
|
3335 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
|
3336 @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
|
3337 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
|
3338 @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
|
3339 @end deftypefn */) |
4791 | 3340 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3341 if (args.length () != 1) |
5823 | 3342 print_usage (); |
4791 | 3343 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3344 return ovl (args(0).byte_size ()); |
4791 | 3345 } |
3346 | |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3347 /* |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3348 %!assert (sizeof (uint64 (ones (3))), 72) |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3349 %!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
|
3350 %!assert (sizeof ({"foo", "bar", "baaz"}), 10) |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3351 */ |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3352 |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3353 static void |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
3354 decode_subscripts (const char *name, const octave_value& arg, |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3355 std::string& type_string, |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3356 std::list<octave_value_list>& idx) |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3357 { |
20704
571508c1ed06
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20703
diff
changeset
|
3358 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
|
3359 |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3360 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
|
3361 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
|
3362 name); |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3363 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3364 octave_idx_type nel = m.numel (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3365 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3366 type_string = std::string (nel, '\0'); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3367 idx = std::list<octave_value_list> (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3368 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3369 if (nel == 0) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3370 return; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3371 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3372 const Cell type = m.contents ("type"); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3373 const Cell subs = m.contents ("subs"); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3374 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3375 for (int k = 0; k < nel; k++) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3376 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3377 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
|
3378 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3379 if (item == "{}") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3380 type_string[k] = '{'; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3381 else if (item == "()") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3382 type_string[k] = '('; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3383 else if (item == ".") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3384 type_string[k] = '.'; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3385 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3386 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
|
3387 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3388 octave_value_list idx_item; |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3389 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3390 if (subs(k).is_string ()) |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3391 idx_item(0) = subs(k); |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
3392 else if (subs(k).iscell ()) |
20978
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3393 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3394 Cell subs_cell = subs(k).cell_value (); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3395 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3396 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
|
3397 { |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3398 if (subs_cell(n).is_string () |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3399 && subs_cell(n).string_value () == ":") |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3400 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
|
3401 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3402 idx_item(n) = subs_cell(n); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3403 } |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3404 } |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3405 else |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3406 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
|
3407 |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3408 idx.push_back (idx_item); |
a5b500efca9f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20962
diff
changeset
|
3409 } |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3410 } |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3411 |
6153 | 3412 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
|
3413 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
|
3414 @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
|
3415 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
|
3416 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
|
3417 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3418 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
|
3419 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
|
3420 @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
|
3421 @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
|
3422 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3423 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
|
3424 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3425 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3426 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3427 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
|
3428 @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
|
3429 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
|
3430 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
|
3431 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
|
3432 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
|
3433 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
|
3434 @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
|
3435 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
|
3436 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
|
3437 @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
|
3438 @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
|
3439 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3440 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3441 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
|
3442 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3443 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
|
3444 @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
|
3445 @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
|
3446 @end deftypefn */) |
6153 | 3447 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3448 if (args.length () != 2) |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3449 print_usage (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3450 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3451 std::string type; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3452 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
|
3453 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3454 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
|
3455 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3456 octave_value arg0 = args(0); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3457 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3458 if (type.empty ()) |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3459 return ovl (arg0); |
6153 | 3460 else |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3461 return arg0.subsref (type, idx, nargout); |
6153 | 3462 } |
3463 | |
3464 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
|
3465 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
|
3466 @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
|
3467 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
|
3468 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
|
3469 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3470 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
|
3471 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
|
3472 @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
|
3473 @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
|
3474 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3475 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
|
3476 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
|
3477 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3478 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3479 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3480 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
|
3481 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
|
3482 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
|
3483 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
|
3484 @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
|
3485 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
|
3486 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
|
3487 @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
|
3488 @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
|
3489 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3490 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
|
3491 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3492 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
|
3493 @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
|
3494 @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
|
3495 @end deftypefn */) |
6153 | 3496 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3497 if (args.length () != 3) |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3498 print_usage (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3499 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3500 std::string type; |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3501 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
|
3502 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3503 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
|
3504 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3505 if (type.empty ()) |
6153 | 3506 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3507 // 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
|
3508 return ovl (args(2).storable_value ()); |
6153 | 3509 } |
3510 else | |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3511 { |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3512 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
|
3513 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
|
3514 |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3515 arg0.make_unique (); |
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3516 |
22390
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3517 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
|
3518 |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3519 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
|
3520 ? 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
|
3521 : arg2))); |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3522 } |
6153 | 3523 } |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3524 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3525 /* |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3526 %!test |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3527 %! a = reshape ([1:25], 5,5); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3528 %! idx1 = substruct ("()", {3, 3}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3529 %! 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
|
3530 %! idx3 = substruct ("()", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3531 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3532 %! assert (subsref (a, idx1), 13); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3533 %! 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
|
3534 %! 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
|
3535 %! assert (subsref (a, idx4), a); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3536 %! a = subsasgn (a, idx1, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3537 %! a = subsasgn (a, idx2, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3538 %! a = subsasgn (a, idx3, 0); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3539 %!# a = subsasgn (a, idx4, 0); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3540 %! b = [0 6 11 16 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3541 %! 0 0 12 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3542 %! 0 8 0 18 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3543 %! 0 0 14 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3544 %! 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
|
3545 %! assert (a, b); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3546 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3547 %!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
|
3548 %! 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
|
3549 %! 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
|
3550 |
6cbbd550aa91
allow subsasgn (x, idx, zeros(0,0)) to remove elements (bug #48867)
John W. Eaton <jwe@octave.org>
parents:
22327
diff
changeset
|
3551 %!test |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3552 %! 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
|
3553 %! idx1 = substruct ("{}", {3, 3}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3554 %! 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
|
3555 %! idx3 = substruct ("()", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3556 %! 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
|
3557 %! idx3p = substruct ("{}", {":", [1,5]}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3558 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3559 %! assert ({ subsref(c, idx1) }, {13}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3560 %! 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
|
3561 %! 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
|
3562 %! assert (subsref (c, idx4), c); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3563 %! c = subsasgn (c, idx1, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3564 %! c = subsasgn (c, idx2, 0); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3565 %! c = subsasgn (c, idx3, 0); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3566 %!# c = subsasgn (c, idx4, 0); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3567 %! d = {0 6 11 16 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3568 %! 0 0 12 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3569 %! 0 8 0 18 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3570 %! 0 0 14 0 0 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3571 %! 0 10 15 20 0}; |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3572 %! assert (c, d); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3573 |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3574 %!test |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3575 %! s.a = "ohai"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3576 %! s.b = "dere"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3577 %! s.c = 42; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3578 %! idx1 = substruct (".", "a"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3579 %! idx2 = substruct (".", "b"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3580 %! idx3 = substruct (".", "c"); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3581 %! idx4 = struct ("type", {}, "subs", {}); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3582 %! assert (subsref (s, idx1), "ohai"); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3583 %! assert (subsref (s, idx2), "dere"); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3584 %! assert (subsref (s, idx3), 42); |
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3585 %! assert (subsref (s, idx4), s); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3586 %! s = subsasgn (s, idx1, "Hello"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3587 %! s = subsasgn (s, idx2, "There"); |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3588 %! s = subsasgn (s, idx3, 163); |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3589 %!# s = subsasgn (s, idx4, 163); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3590 %! t.a = "Hello"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3591 %! t.b = "There"; |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3592 %! t.c = 163; |
13932
6ead4dc1ca55
subsref, subsasgn: allow empty subscript structs
John W. Eaton <jwe@octave.org>
parents:
13793
diff
changeset
|
3593 %! assert (s, t); |
13100
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3594 */ |
06bf445ee778
Add 6 tests for ov.cc
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12642
diff
changeset
|
3595 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3596 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
|
3597 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
|
3598 @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
|
3599 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
|
3600 @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
|
3601 @end deftypefn */) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3602 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3603 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
|
3604 print_usage (); |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3605 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3606 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
|
3607 } |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3608 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3609 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
3610 %!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
|
3611 %!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
|
3612 %!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
|
3613 %!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
|
3614 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3615 %!error is_sq_string () |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3616 %!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
|
3617 */ |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3618 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3619 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
|
3620 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
|
3621 @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
|
3622 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
|
3623 @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
|
3624 @end deftypefn */) |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3625 { |
20797
492738d32c60
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
3626 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
|
3627 print_usage (); |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3628 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
3629 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
|
3630 } |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3631 |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3632 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
3633 %!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
|
3634 %!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
|
3635 %!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
|
3636 %!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
|
3637 |
13712
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3638 %!error is_dq_string () |
f80473f24553
new functions is_sq_string and is_dq_string
John W. Eaton <jwe@octave.org>
parents:
13294
diff
changeset
|
3639 %!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
|
3640 */ |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3641 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3642 DEFUN (optimize_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
|
3643 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3644 @deftypefn {} {@var{val} =} optimize_permutation_matrix () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3645 @deftypefnx {} {@var{old_val} =} optimize_permutation_matrix (@var{new_val}) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3646 @deftypefnx {} {} optimize_permutation_matrix (@var{new_val}, "local") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3647 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3648 permutation matrices. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3649 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3650 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3651 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
|
3652 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3653 When called from inside a function with the @qcode{"local"} option, the setting |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3654 is changed locally for the function and any subroutines it calls. The original |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3655 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3656 @seealso{optimize_range, optimize_diagonal_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3657 @end deftypefn */) |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3658 { |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3659 return SET_INTERNAL_VARIABLE (optimize_permutation_matrix); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3660 } |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3661 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3662 /* |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3663 %!function p = __test_dpm__ (dpm) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3664 %! optimize_permutation_matrix (dpm, "local"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3665 %! [~, ~, p] = lu ([1,2;3,4]); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3666 %!endfunction |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3667 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3668 %!assert (typeinfo (__test_dpm__ (true)), "permutation matrix") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3669 %!assert (typeinfo (__test_dpm__ (false)), "matrix") |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3670 */ |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3671 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3672 DEFUN (optimize_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
|
3673 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3674 @deftypefn {} {@var{val} =} optimize_diagonal_matrix () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3675 @deftypefnx {} {@var{old_val} =} optimize_diagonal_matrix (@var{new_val}) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3676 @deftypefnx {} {} optimize_diagonal_matrix (@var{new_val}, "local") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3677 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3678 diagonal matrices. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3679 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3680 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3681 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
|
3682 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3683 When called from inside a function with the @qcode{"local"} option, the setting |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3684 is changed locally for the function and any subroutines it calls. The original |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3685 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3686 @seealso{optimize_range, optimize_permutation_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3687 @end deftypefn */) |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3688 { |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3689 return SET_INTERNAL_VARIABLE (optimize_diagonal_matrix); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3690 } |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3691 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3692 /* |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3693 %!function [x, xi, fx, fxi] = __test_ddm__ (ddm) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3694 %! optimize_diagonal_matrix (ddm, "local"); |
19391
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3695 %! x = eye (2); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3696 %! xi = x*i; |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3697 %! fx = single (x); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3698 %! fxi = single (xi); |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3699 %!endfunction |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3700 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3701 %!shared x, xi, fx, fxi |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3702 %! [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
|
3703 %!assert (typeinfo (x), "diagonal matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
3704 %!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
|
3705 %!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
|
3706 %!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
|
3707 |
385499581a5e
allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents:
18537
diff
changeset
|
3708 %!shared x, xi, fx, fxi |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3709 %! [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
|
3710 %!assert (typeinfo (x), "matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
3711 %!assert (typeinfo (xi), "complex matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
3712 %!assert (typeinfo (fx), "float matrix") |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
3713 %!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
|
3714 */ |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3715 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3716 DEFUN (optimize_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
|
3717 doc: /* -*- texinfo -*- |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3718 @deftypefn {} {@var{val} =} optimize_range () |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3719 @deftypefnx {} {@var{old_val} =} optimize_range (@var{new_val}) |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3720 @deftypefnx {} {} optimize_range (@var{new_val}, "local") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3721 Query or set whether a special space-efficient format is used for storing |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3722 ranges. |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3723 |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3724 The default value is true. If this option is set to false, Octave will store |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3725 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
|
3726 |
29929
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3727 When called from inside a function with the @qcode{"local"} option, the setting |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3728 is changed locally for the function and any subroutines it calls. The original |
a3ac00db296b
doc: disable_diagonal_matrix, disable_diagonal_matrix, and disable_range (patch #10089).
José Luis García Pallero <jgpallero@gmail.com>
parents:
29654
diff
changeset
|
3729 setting is restored when exiting the function. |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3730 @seealso{optimize_diagonal_matrix, optimize_permutation_matrix} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
3731 @end deftypefn */) |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3732 { |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3733 return SET_INTERNAL_VARIABLE (optimize_range); |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3734 } |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3735 |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3736 /* |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3737 %!function r = __test_dr__ (dr) |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3738 %! optimize_range (dr, "local"); |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3739 %! ## Constant folding will produce range for 1:13. |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3740 %! base = 1; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3741 %! limit = 13; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3742 %! r = base:limit; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3743 %!endfunction |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3744 |
29982
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3745 %!assert (typeinfo (__test_dr__ (true)), "range") |
605275522c37
Deprecate disable_range, disable_diagonal_matrix, disable_permutation_matrix.
Rik <rik@octave.org>
parents:
29960
diff
changeset
|
3746 %!assert (typeinfo (__test_dr__ (false)), "matrix") |
19394
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
19391
diff
changeset
|
3747 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
3748 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
3749 OCTAVE_NAMESPACE_END |