Mercurial > octave-nkf
annotate src/ov-base.cc @ 10232:0efd486813fe
remove deprecated list datatype
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 30 Jan 2010 22:35:27 +0100 |
parents | cd96d29c5efa |
children | 57a59eae83cc |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 John W. Eaton |
2376 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
4254 | 28 #include <climits> |
29 | |
3503 | 30 #include <iostream> |
2901 | 31 |
2376 | 32 #include "lo-ieee.h" |
4732 | 33 #include "lo-mappers.h" |
2376 | 34 |
5759 | 35 #include "defun.h" |
2376 | 36 #include "gripes.h" |
37 #include "oct-map.h" | |
2974 | 38 #include "oct-obj.h" |
2979 | 39 #include "oct-lvalue.h" |
3340 | 40 #include "oct-stream.h" |
2376 | 41 #include "ops.h" |
42 #include "ov-base.h" | |
3928 | 43 #include "ov-cell.h" |
44 #include "ov-ch-mat.h" | |
2376 | 45 #include "ov-complex.h" |
46 #include "ov-cx-mat.h" | |
3928 | 47 #include "ov-range.h" |
48 #include "ov-re-mat.h" | |
49 #include "ov-scalar.h" | |
2376 | 50 #include "ov-str-mat.h" |
4343 | 51 #include "ov-fcn-handle.h" |
5759 | 52 #include "parse.h" |
53 #include "utils.h" | |
2948 | 54 #include "variables.h" |
2376 | 55 |
9790
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
56 builtin_type_t btyp_mixed_numeric (builtin_type_t x, builtin_type_t y) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
57 { |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
58 builtin_type_t retval = btyp_unknown; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
59 |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
60 if (x == btyp_bool) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
61 x = btyp_double; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
62 if (y == btyp_bool) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
63 y = btyp_double; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
64 |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
65 if (x <= btyp_float_complex && y <= btyp_float_complex) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
66 retval = static_cast<builtin_type_t> (x | y); |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
67 else if (x <= btyp_uint64 && y <= btyp_float) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
68 retval = x; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
69 else if (x <= btyp_float && y <= btyp_uint64) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
70 retval = y; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
71 else if ((x >= btyp_int8 && x <= btyp_int64 |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
72 && y >= btyp_int8 && y <= btyp_int64) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
73 || (x >= btyp_uint8 && x <= btyp_uint64 |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
74 && y >= btyp_uint8 && y <= btyp_uint64)) |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
75 retval = (x > y) ? x : y; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
76 |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
77 return retval; |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
78 } |
a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
Jaroslav Hajek <highegg@gmail.com>
parents:
9753
diff
changeset
|
79 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
80 std::string btyp_class_name[btyp_num_types] = |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
81 { |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
82 "double", "single", "double", "single", |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
83 "int8", "int16", "int32", "int64", |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
84 "uint8", "uint16", "uint32", "uint64", |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
85 "logical", "char", |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
86 "struct", "cell", "function_handle" |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
87 }; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
88 |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
89 string_vector |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
90 get_builtin_classes (void) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
91 { |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
92 static string_vector retval; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
93 |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
94 if (retval.is_empty ()) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
95 { |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
96 int n = btyp_num_types - 2; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
97 retval = string_vector (n); |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
98 int j = 0; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
99 for (int i = 0; i < btyp_num_types; i++) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
100 { |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
101 builtin_type_t ityp = static_cast<builtin_type_t> (i); |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
102 if (ityp != btyp_complex && ityp != btyp_float_complex) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
103 retval(j++) = btyp_class_name[i]; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
104 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
105 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
106 |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
107 return retval; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
108 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
10075
diff
changeset
|
109 |
4612 | 110 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, |
111 "<unknown type>", "unknown"); | |
2376 | 112 |
7193 | 113 // TRUE means to perform automatic sparse to real mutation if there |
114 // is memory to be saved | |
115 bool Vsparse_auto_mutate = false; | |
116 | |
2376 | 117 octave_value |
4532 | 118 octave_base_value::squeeze (void) const |
119 { | |
120 std::string nm = type_name (); | |
121 error ("squeeze: invalid operation for %s type", nm.c_str ()); | |
122 return octave_value (); | |
123 } | |
124 | |
125 octave_value | |
8458
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
126 octave_base_value::full_value (void) const |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
127 { |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
128 gripe_wrong_type_arg ("full: invalid operation for %s type", type_name ()); |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
129 return octave_value (); |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
130 } |
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
131 |
9329
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
132 Matrix |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
133 octave_base_value::size (void) |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
134 { |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
135 const dim_vector dv = dims (); |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
136 Matrix mdv (1, dv.length ()); |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
137 for (octave_idx_type i = 0; i < dv.length (); i++) |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
138 mdv(i) = dv(i); |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
139 return mdv; |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
140 } |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
141 |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
142 octave_idx_type |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
143 octave_base_value::numel (const octave_value_list& idx) |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
144 { |
9705
5acd99c3e794
avoid recursive overloaded calls in builtin numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
145 return dims_to_numel (dims (), idx); |
9329
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
146 } |
67fc970dad7d
improve indexed assignment using indexed numel
Jaroslav Hajek <highegg@gmail.com>
parents:
9286
diff
changeset
|
147 |
8458
d254a21e0120
reimplement full as method of octave_base_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
148 octave_value |
4247 | 149 octave_base_value::subsref (const std::string&, |
4219 | 150 const std::list<octave_value_list>&) |
3933 | 151 { |
152 std::string nm = type_name (); | |
153 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
154 return octave_value (); | |
155 } | |
156 | |
157 octave_value_list | |
4247 | 158 octave_base_value::subsref (const std::string&, |
4219 | 159 const std::list<octave_value_list>&, int) |
3933 | 160 { |
161 std::string nm = type_name (); | |
162 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
163 return octave_value (); | |
164 } | |
165 | |
166 octave_value | |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
167 octave_base_value::subsref (const std::string& type, |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
168 const std::list<octave_value_list>& idx, |
8677
095ae5e0a831
eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
169 bool /* auto_add */) |
8551
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
170 { |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
171 // This way we may get a more meaningful error message. |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
172 return subsref (type, idx); |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
173 } |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
174 |
906f976d35a8
further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
8458
diff
changeset
|
175 octave_value |
5885 | 176 octave_base_value::do_index_op (const octave_value_list&, bool) |
2974 | 177 { |
3523 | 178 std::string nm = type_name (); |
2974 | 179 error ("can't perform indexing operations for %s type", nm.c_str ()); |
180 return octave_value (); | |
181 } | |
182 | |
183 octave_value_list | |
3544 | 184 octave_base_value::do_multi_index_op (int, const octave_value_list&) |
2376 | 185 { |
3523 | 186 std::string nm = type_name (); |
2376 | 187 error ("can't perform indexing operations for %s type", nm.c_str ()); |
188 return octave_value (); | |
189 } | |
190 | |
191 idx_vector | |
192 octave_base_value::index_vector (void) const | |
193 { | |
3523 | 194 std::string nm = type_name (); |
2376 | 195 error ("%s type invalid as index value", nm.c_str ()); |
196 return idx_vector (); | |
197 } | |
198 | |
5759 | 199 int |
200 octave_base_value::ndims (void) const | |
201 { | |
202 dim_vector dv = dims (); | |
203 | |
204 int n_dims = dv.length (); | |
205 | |
206 // Remove trailing singleton dimensions. | |
207 | |
208 for (int i = n_dims; i > 2; i--) | |
209 { | |
210 if (dv(i-1) == 1) | |
211 n_dims--; | |
212 else | |
213 break; | |
214 } | |
215 | |
216 // The result is always >= 2. | |
217 | |
218 if (n_dims < 2) | |
219 n_dims = 2; | |
220 | |
221 return n_dims; | |
222 } | |
223 | |
2376 | 224 octave_value |
4247 | 225 octave_base_value::subsasgn (const std::string& type, |
4219 | 226 const std::list<octave_value_list>& idx, |
3933 | 227 const octave_value& rhs) |
2376 | 228 { |
3933 | 229 octave_value retval; |
2376 | 230 |
3933 | 231 if (is_defined ()) |
232 { | |
4139 | 233 if (is_numeric_type ()) |
234 { | |
235 switch (type[0]) | |
236 { | |
237 case '(': | |
238 { | |
239 if (type.length () == 1) | |
240 retval = numeric_assign (type, idx, rhs); | |
4436 | 241 else if (is_empty ()) |
242 { | |
243 // Allow conversion of empty matrix to some other | |
244 // type in cases like | |
245 // | |
246 // x = []; x(i).f = rhs | |
247 | |
248 octave_value tmp = octave_value::empty_conv (type, rhs); | |
249 | |
250 retval = tmp.subsasgn (type, idx, rhs); | |
251 } | |
4139 | 252 else |
253 { | |
254 std::string nm = type_name (); | |
255 error ("in indexed assignment of %s, last rhs index must be ()", | |
256 nm.c_str ()); | |
257 } | |
258 } | |
259 break; | |
260 | |
261 case '{': | |
262 case '.': | |
263 { | |
264 std::string nm = type_name (); | |
265 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); | |
266 } | |
267 break; | |
268 | |
269 default: | |
270 panic_impossible (); | |
271 } | |
272 } | |
273 else | |
274 { | |
275 std::string nm = type_name (); | |
276 error ("can't perform indexed assignment for %s type", nm.c_str ()); | |
277 } | |
3933 | 278 } |
279 else | |
280 { | |
281 // Create new object of appropriate type for given index and rhs | |
282 // types and then call subsasgn again for that object. | |
283 | |
284 octave_value tmp = octave_value::empty_conv (type, rhs); | |
285 | |
286 retval = tmp.subsasgn (type, idx, rhs); | |
287 } | |
288 | |
289 return retval; | |
2376 | 290 } |
291 | |
5602 | 292 octave_idx_type |
293 octave_base_value::nnz (void) const | |
294 { | |
295 gripe_wrong_type_arg ("octave_base_value::nnz ()", type_name ()); | |
296 return -1; | |
297 } | |
298 | |
5604 | 299 octave_idx_type |
300 octave_base_value::nzmax (void) const | |
301 { | |
302 gripe_wrong_type_arg ("octave_base_value::nzmax ()", type_name ()); | |
303 return -1; | |
304 } | |
305 | |
5900 | 306 octave_idx_type |
307 octave_base_value::nfields (void) const | |
308 { | |
309 gripe_wrong_type_arg ("octave_base_value::nfields ()", type_name ()); | |
310 return -1; | |
311 } | |
312 | |
2376 | 313 octave_value |
4567 | 314 octave_base_value::reshape (const dim_vector&) const |
315 { | |
316 gripe_wrong_type_arg ("octave_base_value::reshape ()", type_name ()); | |
317 return octave_value (); | |
318 } | |
319 | |
320 octave_value | |
4593 | 321 octave_base_value::permute (const Array<int>&, bool) const |
322 { | |
323 gripe_wrong_type_arg ("octave_base_value::permute ()", type_name ()); | |
324 return octave_value (); | |
325 } | |
326 | |
327 octave_value | |
5731 | 328 octave_base_value::resize (const dim_vector&, bool) const |
4915 | 329 { |
330 gripe_wrong_type_arg ("octave_base_value::resize ()", type_name ()); | |
331 return octave_value (); | |
332 } | |
333 | |
5785 | 334 MatrixType |
335 octave_base_value::matrix_type (void) const | |
336 { | |
337 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
338 return MatrixType (); | |
339 } | |
340 | |
341 MatrixType | |
342 octave_base_value::matrix_type (const MatrixType&) const | |
343 { | |
344 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
345 return MatrixType (); | |
346 } | |
347 | |
4915 | 348 octave_value |
5759 | 349 octave_base_value::all (int) const |
350 { | |
351 return 0.0; | |
352 } | |
353 | |
354 octave_value | |
355 octave_base_value::any (int) const | |
356 { | |
357 return 0.0; | |
358 } | |
359 | |
360 octave_value | |
361 octave_base_value::convert_to_str (bool pad, bool force, char type) const | |
362 { | |
363 octave_value retval = convert_to_str_internal (pad, force, type); | |
364 | |
5781 | 365 if (! force && is_numeric_type ()) |
366 gripe_implicit_conversion ("Octave:num-to-str", | |
367 type_name (), retval.type_name ()); | |
5759 | 368 |
369 return retval; | |
370 } | |
371 | |
372 octave_value | |
5279 | 373 octave_base_value::convert_to_str_internal (bool, bool, char) const |
2376 | 374 { |
4452 | 375 gripe_wrong_type_arg ("octave_base_value::convert_to_str_internal ()", |
2376 | 376 type_name ()); |
377 return octave_value (); | |
378 } | |
379 | |
380 void | |
381 octave_base_value::convert_to_row_or_column_vector (void) | |
382 { | |
383 gripe_wrong_type_arg | |
384 ("octave_base_value::convert_to_row_or_column_vector ()", | |
385 type_name ()); | |
386 } | |
387 | |
388 void | |
3523 | 389 octave_base_value::print (std::ostream&, bool) const |
2376 | 390 { |
3195 | 391 gripe_wrong_type_arg ("octave_base_value::print ()", type_name ()); |
2376 | 392 } |
393 | |
2901 | 394 void |
3523 | 395 octave_base_value::print_raw (std::ostream&, bool) const |
2901 | 396 { |
3195 | 397 gripe_wrong_type_arg ("octave_base_value::print_raw ()", type_name ()); |
2901 | 398 } |
399 | |
400 bool | |
3523 | 401 octave_base_value::print_name_tag (std::ostream& os, const std::string& name) const |
2901 | 402 { |
4604 | 403 bool retval = false; |
404 | |
2901 | 405 indent (os); |
4604 | 406 |
407 if (print_as_scalar ()) | |
408 os << name << " = "; | |
409 else | |
410 { | |
411 os << name << " ="; | |
412 newline (os); | |
413 newline (os); | |
414 retval = true; | |
415 } | |
416 | |
417 return retval; | |
2901 | 418 } |
419 | |
3933 | 420 void |
5759 | 421 octave_base_value::print_with_name (std::ostream& output_buf, |
422 const std::string& name, | |
9521 | 423 bool print_padding) |
5759 | 424 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
425 bool pad_after = print_name_tag (output_buf, name); |
5759 | 426 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
427 print (output_buf); |
5759 | 428 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
429 if (print_padding && pad_after) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8551
diff
changeset
|
430 newline (output_buf); |
5759 | 431 } |
432 | |
433 void | |
3933 | 434 octave_base_value::print_info (std::ostream& os, |
4661 | 435 const std::string& /* prefix */) const |
3933 | 436 { |
437 os << "no info for type: " << type_name () << "\n"; | |
438 } | |
439 | |
4254 | 440 #define INT_CONV_METHOD(T, F, MIN_LIMIT, MAX_LIMIT) \ |
441 T \ | |
442 octave_base_value::F ## _value (bool require_int, bool frc_str_conv) const \ | |
443 { \ | |
444 T retval = 0; \ | |
445 \ | |
446 double d = double_value (frc_str_conv); \ | |
447 \ | |
448 if (! error_state) \ | |
449 { \ | |
450 if (require_int && D_NINT (d) != d) \ | |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9705
diff
changeset
|
451 error_with_cfn ("conversion of %g to " #T " value failed", d); \ |
5054 | 452 else if (d < MIN_LIMIT) \ |
453 retval = MIN_LIMIT; \ | |
454 else if (d > MAX_LIMIT) \ | |
455 retval = MAX_LIMIT; \ | |
4254 | 456 else \ |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
457 retval = static_cast<T> (::fix (d)); \ |
4254 | 458 } \ |
459 else \ | |
460 gripe_wrong_type_arg ("octave_base_value::" #F "_value ()", \ | |
461 type_name ()); \ | |
462 \ | |
463 return retval; \ | |
464 } | |
3202 | 465 |
4254 | 466 INT_CONV_METHOD (short int, short, SHRT_MIN, SHRT_MAX) |
467 INT_CONV_METHOD (unsigned short int, ushort, 0, USHRT_MAX) | |
3202 | 468 |
4254 | 469 INT_CONV_METHOD (int, int, INT_MIN, INT_MAX) |
470 INT_CONV_METHOD (unsigned int, uint, 0, UINT_MAX) | |
3202 | 471 |
4254 | 472 INT_CONV_METHOD (long int, long, LONG_MIN, LONG_MAX) |
473 INT_CONV_METHOD (unsigned long int, ulong, 0, ULONG_MAX) | |
3202 | 474 |
475 int | |
476 octave_base_value::nint_value (bool frc_str_conv) const | |
477 { | |
478 int retval = 0; | |
479 | |
480 double d = double_value (frc_str_conv); | |
481 | |
482 if (! error_state) | |
483 { | |
484 if (xisnan (d)) | |
485 { | |
486 error ("conversion of NaN to integer value failed"); | |
487 return retval; | |
488 } | |
489 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
490 retval = static_cast<int> (::fix (d)); |
3202 | 491 } |
492 else | |
493 gripe_wrong_type_arg ("octave_base_value::nint_value ()", type_name ()); | |
494 | |
495 return retval; | |
496 } | |
497 | |
2376 | 498 double |
499 octave_base_value::double_value (bool) const | |
500 { | |
4102 | 501 double retval = lo_ieee_nan_value (); |
2376 | 502 gripe_wrong_type_arg ("octave_base_value::double_value ()", type_name ()); |
503 return retval; | |
504 } | |
505 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
506 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
507 octave_base_value::float_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
508 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
509 float retval = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
510 gripe_wrong_type_arg ("octave_base_value::float_value ()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
511 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
512 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
513 |
3351 | 514 Cell |
3539 | 515 octave_base_value::cell_value () const |
3351 | 516 { |
517 Cell retval; | |
518 gripe_wrong_type_arg ("octave_base_value::cell_value()", type_name ()); | |
519 return retval; | |
520 } | |
521 | |
2376 | 522 Matrix |
523 octave_base_value::matrix_value (bool) const | |
524 { | |
525 Matrix retval; | |
526 gripe_wrong_type_arg ("octave_base_value::matrix_value()", type_name ()); | |
527 return retval; | |
528 } | |
529 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
530 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
531 octave_base_value::float_matrix_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
532 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
533 FloatMatrix retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
534 gripe_wrong_type_arg ("octave_base_value::float_matrix_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
535 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
536 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
537 |
4507 | 538 NDArray |
4550 | 539 octave_base_value::array_value (bool) const |
4505 | 540 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
541 FloatNDArray retval; |
4550 | 542 gripe_wrong_type_arg ("octave_base_value::array_value()", type_name ()); |
4505 | 543 return retval; |
544 } | |
545 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
546 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
547 octave_base_value::float_array_value (bool) const |
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 FloatNDArray retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
550 gripe_wrong_type_arg ("octave_base_value::float_array_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
551 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
552 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
553 |
2376 | 554 Complex |
555 octave_base_value::complex_value (bool) const | |
556 { | |
4102 | 557 double tmp = lo_ieee_nan_value (); |
558 Complex retval (tmp, tmp); | |
2376 | 559 gripe_wrong_type_arg ("octave_base_value::complex_value()", type_name ()); |
560 return retval; | |
561 } | |
562 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
563 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
564 octave_base_value::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
565 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
566 float tmp = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
567 FloatComplex retval (tmp, tmp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
568 gripe_wrong_type_arg ("octave_base_value::float_complex_value()", type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
569 return retval; |
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 |
2376 | 572 ComplexMatrix |
573 octave_base_value::complex_matrix_value (bool) const | |
574 { | |
575 ComplexMatrix retval; | |
576 gripe_wrong_type_arg ("octave_base_value::complex_matrix_value()", | |
577 type_name ()); | |
578 return retval; | |
579 } | |
580 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
581 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
582 octave_base_value::float_complex_matrix_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
583 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
584 FloatComplexMatrix retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
585 gripe_wrong_type_arg ("octave_base_value::float_complex_matrix_value()", |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
586 type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
587 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
588 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
589 |
4550 | 590 ComplexNDArray |
591 octave_base_value::complex_array_value (bool) const | |
592 { | |
593 ComplexNDArray retval; | |
594 gripe_wrong_type_arg ("octave_base_value::complex_array_value()", | |
595 type_name ()); | |
596 return retval; | |
597 } | |
598 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
599 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
600 octave_base_value::float_complex_array_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
601 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
602 FloatComplexNDArray retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
603 gripe_wrong_type_arg ("octave_base_value::float_complex_array_value()", |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
604 type_name ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
605 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
606 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7761
diff
changeset
|
607 |
4550 | 608 bool |
5943 | 609 octave_base_value::bool_value (bool) const |
4550 | 610 { |
611 bool retval = false; | |
612 gripe_wrong_type_arg ("octave_base_value::bool_value()", type_name ()); | |
613 return retval; | |
614 } | |
615 | |
616 boolMatrix | |
5943 | 617 octave_base_value::bool_matrix_value (bool) const |
4550 | 618 { |
619 boolMatrix retval; | |
620 gripe_wrong_type_arg ("octave_base_value::bool_matrix_value()", | |
621 type_name ()); | |
622 return retval; | |
623 } | |
624 | |
625 boolNDArray | |
5943 | 626 octave_base_value::bool_array_value (bool) const |
4550 | 627 { |
628 boolNDArray retval; | |
629 gripe_wrong_type_arg ("octave_base_value::bool_array_value()", | |
630 type_name ()); | |
631 return retval; | |
632 } | |
633 | |
2376 | 634 charMatrix |
4741 | 635 octave_base_value::char_matrix_value (bool force) const |
2376 | 636 { |
637 charMatrix retval; | |
4257 | 638 |
4741 | 639 octave_value tmp = convert_to_str (false, force); |
4257 | 640 |
4452 | 641 if (! error_state) |
642 retval = tmp.char_matrix_value (); | |
643 | |
2376 | 644 return retval; |
645 } | |
646 | |
4550 | 647 charNDArray |
648 octave_base_value::char_array_value (bool) const | |
649 { | |
650 charNDArray retval; | |
651 gripe_wrong_type_arg ("octave_base_value::char_array_value()", | |
652 type_name ()); | |
653 return retval; | |
654 } | |
655 | |
5164 | 656 SparseMatrix |
657 octave_base_value::sparse_matrix_value (bool) const | |
658 { | |
659 SparseMatrix retval; | |
660 gripe_wrong_type_arg ("octave_base_value::sparse_matrix_value()", type_name ()); | |
661 return retval; | |
662 } | |
663 | |
664 SparseComplexMatrix | |
665 octave_base_value::sparse_complex_matrix_value (bool) const | |
666 { | |
667 SparseComplexMatrix retval; | |
668 gripe_wrong_type_arg ("octave_base_value::sparse_complex_matrix_value()", type_name ()); | |
669 return retval; | |
670 } | |
671 | |
672 SparseBoolMatrix | |
673 octave_base_value::sparse_bool_matrix_value (bool) const | |
674 { | |
675 SparseBoolMatrix retval; | |
676 gripe_wrong_type_arg ("octave_base_value::sparse_bool_matrix_value()", type_name ()); | |
677 return retval; | |
678 } | |
679 | |
8916
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
680 DiagMatrix |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
681 octave_base_value::diag_matrix_value (bool) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
682 { |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
683 DiagMatrix retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
684 gripe_wrong_type_arg ("octave_base_value::diag_matrix_value()", type_name ()); |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
685 return retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
686 } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
687 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
688 FloatDiagMatrix |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
689 octave_base_value::float_diag_matrix_value (bool) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
690 { |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
691 FloatDiagMatrix retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
692 gripe_wrong_type_arg ("octave_base_value::float_diag_matrix_value()", type_name ()); |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
693 return retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
694 } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
695 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
696 ComplexDiagMatrix |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
697 octave_base_value::complex_diag_matrix_value (bool) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
698 { |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
699 ComplexDiagMatrix retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
700 gripe_wrong_type_arg ("octave_base_value::complex_diag_matrix_value()", type_name ()); |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
701 return retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
702 } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
703 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
704 FloatComplexDiagMatrix |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
705 octave_base_value::float_complex_diag_matrix_value (bool) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
706 { |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
707 FloatComplexDiagMatrix retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
708 gripe_wrong_type_arg ("octave_base_value::float_complex_diag_matrix_value()", type_name ()); |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
709 return retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
710 } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
711 |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
712 PermMatrix |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
713 octave_base_value::perm_matrix_value (void) const |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
714 { |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
715 PermMatrix retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
716 gripe_wrong_type_arg ("octave_base_value::perm_matrix_value()", type_name ()); |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
717 return retval; |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
718 } |
a2878ba31a9e
add diag & perm matrix query methods to octave_value
Jaroslav Hajek <highegg@gmail.com>
parents:
8734
diff
changeset
|
719 |
4910 | 720 octave_int8 |
721 octave_base_value::int8_scalar_value (void) const | |
722 { | |
723 octave_int8 retval; | |
724 gripe_wrong_type_arg ("octave_base_value::int8_scalar_value()", | |
725 type_name ()); | |
726 return retval; | |
727 } | |
728 | |
729 octave_int16 | |
730 octave_base_value::int16_scalar_value (void) const | |
731 { | |
732 octave_int16 retval; | |
733 gripe_wrong_type_arg ("octave_base_value::int16_scalar_value()", | |
734 type_name ()); | |
735 return retval; | |
736 } | |
737 | |
738 octave_int32 | |
739 octave_base_value::int32_scalar_value (void) const | |
740 { | |
741 octave_int32 retval; | |
742 gripe_wrong_type_arg ("octave_base_value::int32_scalar_value()", | |
743 type_name ()); | |
744 return retval; | |
745 } | |
746 | |
747 octave_int64 | |
748 octave_base_value::int64_scalar_value (void) const | |
749 { | |
750 octave_int64 retval; | |
751 gripe_wrong_type_arg ("octave_base_value::int64_scalar_value()", | |
752 type_name ()); | |
753 return retval; | |
754 } | |
755 | |
756 octave_uint8 | |
757 octave_base_value::uint8_scalar_value (void) const | |
758 { | |
759 octave_uint8 retval; | |
760 gripe_wrong_type_arg ("octave_base_value::uint8_scalar_value()", | |
761 type_name ()); | |
762 return retval; | |
763 } | |
764 | |
765 octave_uint16 | |
766 octave_base_value::uint16_scalar_value (void) const | |
767 { | |
768 octave_uint16 retval; | |
769 gripe_wrong_type_arg ("octave_base_value::uint16_scalar_value()", | |
770 type_name ()); | |
771 return retval; | |
772 } | |
773 | |
774 octave_uint32 | |
775 octave_base_value::uint32_scalar_value (void) const | |
776 { | |
777 octave_uint32 retval; | |
778 gripe_wrong_type_arg ("octave_base_value::uint32_scalar_value()", | |
779 type_name ()); | |
780 return retval; | |
781 } | |
782 | |
783 octave_uint64 | |
784 octave_base_value::uint64_scalar_value (void) const | |
785 { | |
786 octave_uint64 retval; | |
787 gripe_wrong_type_arg ("octave_base_value::uint64_scalar_value()", | |
788 type_name ()); | |
789 return retval; | |
790 } | |
791 | |
4906 | 792 int8NDArray |
793 octave_base_value::int8_array_value (void) const | |
794 { | |
795 int8NDArray retval; | |
796 gripe_wrong_type_arg ("octave_base_value::int8_array_value()", | |
797 type_name ()); | |
4910 | 798 return retval; |
4906 | 799 } |
800 | |
801 int16NDArray | |
802 octave_base_value::int16_array_value (void) const | |
803 { | |
804 int16NDArray retval; | |
805 gripe_wrong_type_arg ("octave_base_value::int16_array_value()", | |
806 type_name ()); | |
4910 | 807 return retval; |
4906 | 808 } |
809 | |
810 int32NDArray | |
811 octave_base_value::int32_array_value (void) const | |
812 { | |
813 int32NDArray retval; | |
814 gripe_wrong_type_arg ("octave_base_value::int32_array_value()", | |
815 type_name ()); | |
4910 | 816 return retval; |
4906 | 817 } |
818 | |
819 int64NDArray | |
820 octave_base_value::int64_array_value (void) const | |
821 { | |
822 int64NDArray retval; | |
823 gripe_wrong_type_arg ("octave_base_value::int64_array_value()", | |
824 type_name ()); | |
4910 | 825 return retval; |
4906 | 826 } |
827 | |
828 uint8NDArray | |
829 octave_base_value::uint8_array_value (void) const | |
830 { | |
831 uint8NDArray retval; | |
832 gripe_wrong_type_arg ("octave_base_value::uint8_array_value()", | |
833 type_name ()); | |
4910 | 834 return retval; |
4906 | 835 } |
836 | |
837 uint16NDArray | |
838 octave_base_value::uint16_array_value (void) const | |
839 { | |
840 uint16NDArray retval; | |
841 gripe_wrong_type_arg ("octave_base_value::uint16_array_value()", | |
842 type_name ()); | |
4910 | 843 return retval; |
4906 | 844 } |
845 | |
846 uint32NDArray | |
847 octave_base_value::uint32_array_value (void) const | |
848 { | |
849 uint32NDArray retval; | |
850 gripe_wrong_type_arg ("octave_base_value::uint32_array_value()", | |
851 type_name ()); | |
4910 | 852 return retval; |
4906 | 853 } |
854 | |
855 uint64NDArray | |
856 octave_base_value::uint64_array_value (void) const | |
857 { | |
858 uint64NDArray retval; | |
859 gripe_wrong_type_arg ("octave_base_value::uint64_array_value()", | |
860 type_name ()); | |
4910 | 861 return retval; |
4906 | 862 } |
863 | |
2493 | 864 string_vector |
5715 | 865 octave_base_value::all_strings (bool pad) const |
2376 | 866 { |
2493 | 867 string_vector retval; |
4257 | 868 |
5715 | 869 octave_value tmp = convert_to_str (pad, true); |
4257 | 870 |
4452 | 871 if (! error_state) |
872 retval = tmp.all_strings (); | |
4257 | 873 |
2376 | 874 return retval; |
875 } | |
876 | |
3536 | 877 std::string |
4457 | 878 octave_base_value::string_value (bool force) const |
2376 | 879 { |
3523 | 880 std::string retval; |
4257 | 881 |
4457 | 882 octave_value tmp = convert_to_str (force); |
4257 | 883 |
4452 | 884 if (! error_state) |
885 retval = tmp.string_value (); | |
4257 | 886 |
2376 | 887 return retval; |
888 } | |
889 | |
8732 | 890 Array<std::string> |
891 octave_base_value::cellstr_value (void) const | |
892 { | |
893 Array<std::string> retval; | |
894 gripe_wrong_type_arg ("octave_base_value::cellstry_value()", | |
895 type_name ()); | |
896 return retval; | |
897 } | |
898 | |
2376 | 899 Range |
900 octave_base_value::range_value (void) const | |
901 { | |
902 Range retval; | |
903 gripe_wrong_type_arg ("octave_base_value::range_value()", type_name ()); | |
904 return retval; | |
905 } | |
906 | |
907 Octave_map | |
908 octave_base_value::map_value (void) const | |
909 { | |
910 Octave_map retval; | |
911 gripe_wrong_type_arg ("octave_base_value::map_value()", type_name ()); | |
912 return retval; | |
913 } | |
914 | |
3933 | 915 string_vector |
916 octave_base_value::map_keys (void) const | |
917 { | |
918 string_vector retval; | |
919 gripe_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); | |
920 return retval; | |
921 } | |
922 | |
9151 | 923 size_t |
924 octave_base_value::nparents (void) const | |
925 { | |
926 size_t retval = 0; | |
927 gripe_wrong_type_arg ("octave_base_value::nparents()", type_name ()); | |
928 return retval; | |
929 } | |
930 | |
931 std::list<std::string> | |
932 octave_base_value::parent_class_name_list (void) const | |
933 { | |
934 std::list<std::string> retval; | |
935 gripe_wrong_type_arg ("octave_base_value::parent_class_name_list()", | |
936 type_name ()); | |
937 return retval; | |
938 } | |
939 | |
940 string_vector | |
941 octave_base_value::parent_class_names (void) const | |
942 { | |
943 string_vector retval; | |
944 gripe_wrong_type_arg ("octave_base_value::parent_class_names()", | |
945 type_name ()); | |
946 return retval; | |
947 } | |
948 | |
2974 | 949 octave_function * |
950 octave_base_value::function_value (bool silent) | |
951 { | |
952 octave_function *retval = 0; | |
953 | |
954 if (! silent) | |
955 gripe_wrong_type_arg ("octave_base_value::function_value()", | |
956 type_name ()); | |
957 return retval; | |
958 } | |
959 | |
4700 | 960 octave_user_function * |
961 octave_base_value::user_function_value (bool silent) | |
962 { | |
963 octave_user_function *retval = 0; | |
964 | |
965 if (! silent) | |
966 gripe_wrong_type_arg ("octave_base_value::user_function_value()", | |
967 type_name ()); | |
968 return retval; | |
969 } | |
970 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
971 octave_user_script * |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
972 octave_base_value::user_script_value (bool silent) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
973 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
974 octave_user_script *retval = 0; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
975 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
976 if (! silent) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
977 gripe_wrong_type_arg ("octave_base_value::user_script_value()", |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
978 type_name ()); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
979 return retval; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
980 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
981 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
982 octave_user_code * |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
983 octave_base_value::user_code_value (bool silent) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
984 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
985 octave_user_code *retval = 0; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
986 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
987 if (! silent) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
988 gripe_wrong_type_arg ("octave_base_value::user_code_value()", |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
989 type_name ()); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
990 return retval; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
991 } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
992 |
4346 | 993 octave_fcn_handle * |
4343 | 994 octave_base_value::fcn_handle_value (bool silent) |
995 { | |
4346 | 996 octave_fcn_handle *retval = 0; |
4343 | 997 |
998 if (! silent) | |
999 gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()", | |
1000 type_name ()); | |
1001 return retval; | |
1002 } | |
1003 | |
4933 | 1004 octave_fcn_inline * |
1005 octave_base_value::fcn_inline_value (bool silent) | |
1006 { | |
1007 octave_fcn_inline *retval = 0; | |
1008 | |
1009 if (! silent) | |
1010 gripe_wrong_type_arg ("octave_base_value::fcn_inline_value()", | |
1011 type_name ()); | |
1012 return retval; | |
1013 } | |
1014 | |
2882 | 1015 octave_value_list |
1016 octave_base_value::list_value (void) const | |
1017 { | |
1018 octave_value_list retval; | |
1019 gripe_wrong_type_arg ("octave_base_value::list_value()", type_name ()); | |
1020 return retval; | |
1021 } | |
1022 | |
4687 | 1023 bool |
6974 | 1024 octave_base_value::save_ascii (std::ostream&) |
4687 | 1025 { |
1026 gripe_wrong_type_arg ("octave_base_value::save_ascii()", type_name ()); | |
1027 return false; | |
1028 } | |
1029 | |
1030 bool | |
1031 octave_base_value::load_ascii (std::istream&) | |
1032 { | |
1033 gripe_wrong_type_arg ("octave_base_value::load_ascii()", type_name ()); | |
1034 return false; | |
1035 } | |
1036 | |
1037 bool | |
1038 octave_base_value::save_binary (std::ostream&, bool&) | |
1039 { | |
1040 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
1041 return false; | |
1042 } | |
1043 | |
1044 bool | |
1045 octave_base_value::load_binary (std::istream&, bool, | |
1046 oct_mach_info::float_format) | |
1047 { | |
1048 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
1049 return false; | |
1050 } | |
1051 | |
1052 #if defined (HAVE_HDF5) | |
4944 | 1053 |
4687 | 1054 bool |
1055 octave_base_value::save_hdf5 (hid_t, const char *, bool) | |
1056 { | |
1057 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
1058 | |
1059 return false; | |
1060 } | |
1061 | |
1062 bool | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9835
diff
changeset
|
1063 octave_base_value::load_hdf5 (hid_t, const char *) |
4687 | 1064 { |
1065 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
1066 | |
1067 return false; | |
1068 } | |
4944 | 1069 |
4687 | 1070 #endif |
1071 | |
4944 | 1072 int |
1073 octave_base_value::write (octave_stream&, int, oct_data_conv::data_type, | |
1074 int, oct_mach_info::float_format) const | |
1075 { | |
1076 gripe_wrong_type_arg ("octave_base_value::write()", type_name ()); | |
1077 | |
1078 return false; | |
1079 } | |
1080 | |
5900 | 1081 mxArray * |
1082 octave_base_value::as_mxArray (void) const | |
1083 { | |
1084 gripe_wrong_type_arg ("octave_base_value::as_mxArray ()", type_name ()); | |
1085 | |
1086 return 0; | |
1087 } | |
1088 | |
7433 | 1089 octave_value |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1090 octave_base_value::diag (octave_idx_type) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1091 { |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1092 gripe_wrong_type_arg ("octave_base_value::diag ()", type_name ()); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1093 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1094 return octave_value(); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1095 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1096 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
1097 octave_value |
7433 | 1098 octave_base_value::sort (octave_idx_type, sortmode) const |
1099 { | |
1100 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
1101 | |
1102 return octave_value(); | |
1103 } | |
1104 | |
1105 octave_value | |
1106 octave_base_value::sort (Array<octave_idx_type> &, | |
1107 octave_idx_type, sortmode) const | |
1108 { | |
1109 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
1110 | |
1111 return octave_value(); | |
1112 } | |
1113 | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1114 sortmode |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1115 octave_base_value::is_sorted (sortmode) const |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1116 { |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1117 gripe_wrong_type_arg ("octave_base_value::is_sorted ()", type_name ()); |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1118 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1119 return UNSORTED; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1120 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1121 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1122 Array<octave_idx_type> |
8733
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
1123 octave_base_value::sort_rows_idx (sortmode) const |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1124 { |
8733
3ef774603887
rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents:
8732
diff
changeset
|
1125 gripe_wrong_type_arg ("octave_base_value::sort_rows_idx ()", type_name ()); |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1126 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1127 return Array<octave_idx_type> (); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1128 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1129 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1130 sortmode |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1131 octave_base_value::is_sorted_rows (sortmode) const |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1132 { |
8734
767ed8cc6634
rename internal issorted and issorted_rows functions to is_sorted and is_sorted_rows
John W. Eaton <jwe@octave.org>
parents:
8733
diff
changeset
|
1133 gripe_wrong_type_arg ("octave_base_value::is_sorted_rows ()", type_name ()); |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1134 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1135 return UNSORTED; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1136 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1137 |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
1138 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
1139 const char * |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
1140 octave_base_value::get_umap_name (unary_mapper_t umap) |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1141 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1142 static const char *names[num_unary_mappers] = |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1143 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1144 "abs", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1145 "acos", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1146 "acosh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1147 "angle", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1148 "arg", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1149 "asin", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1150 "asinh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1151 "atan", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1152 "atanh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1153 "ceil", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1154 "conj", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1155 "cos", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1156 "cosh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1157 "erf", |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
1158 "erfinv", |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1159 "erfc", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1160 "exp", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1161 "expm1", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1162 "finite", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1163 "fix", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1164 "floor", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1165 "gamma", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1166 "imag", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1167 "isinf", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1168 "isna", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1169 "isnan", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1170 "lgamma", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1171 "log", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1172 "log2", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1173 "log10", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1174 "log1p", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1175 "real", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1176 "round", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1177 "roundb", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1178 "signum", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1179 "sin", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1180 "sinh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1181 "sqrt", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1182 "tan", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1183 "tanh", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1184 "isalnum", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1185 "isalpha", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1186 "isascii", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1187 "iscntrl", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1188 "isdigit", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1189 "isgraph", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1190 "islower", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1191 "isprint", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1192 "ispunct", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1193 "isspace", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1194 "isupper", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1195 "isxdigit", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1196 "toascii", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1197 "tolower", |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1198 "toupper" |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1199 }; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1200 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1201 if (umap < 0 || umap >= num_unary_mappers) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1202 return "unknown"; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1203 else |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1204 return names[umap]; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1205 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1206 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1207 octave_value |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1208 octave_base_value::map (unary_mapper_t umap) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1209 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1210 error ("%s: not defined for %s", get_umap_name (umap), type_name ().c_str ()); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1211 return octave_value (); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9790
diff
changeset
|
1212 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1213 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1214 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1215 octave_base_value::lock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1216 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1217 gripe_wrong_type_arg ("octave_base_value::lock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1218 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1219 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1220 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1221 octave_base_value::unlock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1222 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1223 gripe_wrong_type_arg ("octave_base_value::unlock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1224 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1225 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1226 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1227 octave_base_value::dump (std::ostream& os) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1228 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1229 dim_vector dv = this->dims (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1230 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1231 os << "class: " << this->class_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1232 << " type: " << this->type_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1233 << " dims: " << dv.str (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1234 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1235 |
5759 | 1236 static void |
1237 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) | |
1238 { | |
1239 error ("assignment of `%s' to indexed `%s' not implemented", | |
1240 tn2.c_str (), tn1.c_str ()); | |
1241 } | |
1242 | |
1243 static void | |
1244 gripe_assign_conversion_failed (const std::string& tn1, | |
1245 const std::string& tn2) | |
1246 { | |
1247 error ("type conversion for assignment of `%s' to indexed `%s' failed", | |
1248 tn2.c_str (), tn1.c_str ()); | |
1249 } | |
1250 | |
1251 static void | |
1252 gripe_no_conversion (const std::string& on, const std::string& tn1, | |
1253 const std::string& tn2) | |
1254 { | |
1255 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", | |
1256 on.c_str (), tn2.c_str (), tn1.c_str ()); | |
1257 } | |
1258 | |
1259 octave_value | |
1260 octave_base_value::numeric_assign (const std::string& type, | |
1261 const std::list<octave_value_list>& idx, | |
1262 const octave_value& rhs) | |
1263 { | |
1264 octave_value retval; | |
1265 | |
9286
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1266 if (idx.front ().empty ()) |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1267 { |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1268 error ("missing index in indexed assignment"); |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1269 return retval; |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1270 } |
c2248cc4821a
don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
1271 |
5759 | 1272 int t_lhs = type_id (); |
1273 int t_rhs = rhs.type_id (); | |
1274 | |
1275 octave_value_typeinfo::assign_op_fcn f | |
1276 = octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, | |
1277 t_lhs, t_rhs); | |
1278 | |
1279 bool done = false; | |
1280 | |
1281 if (f) | |
1282 { | |
1283 f (*this, idx.front (), rhs.get_rep ()); | |
1284 | |
1285 done = (! error_state); | |
1286 } | |
1287 | |
1288 if (done) | |
1289 { | |
1290 count++; | |
1291 retval = octave_value (this); | |
1292 } | |
1293 else | |
1294 { | |
1295 int t_result | |
1296 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); | |
1297 | |
1298 if (t_result >= 0) | |
1299 { | |
1300 octave_base_value::type_conv_fcn cf | |
1301 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); | |
1302 | |
1303 if (cf) | |
1304 { | |
5874 | 1305 octave_base_value *tmp = cf (*this); |
5759 | 1306 |
1307 if (tmp) | |
1308 { | |
5874 | 1309 octave_value val (tmp); |
1310 | |
1311 retval = val.subsasgn (type, idx, rhs); | |
5759 | 1312 |
1313 done = (! error_state); | |
1314 } | |
1315 else | |
1316 gripe_assign_conversion_failed (type_name (), | |
1317 rhs.type_name ()); | |
1318 } | |
1319 else | |
1320 gripe_indexed_assignment (type_name (), rhs.type_name ()); | |
1321 } | |
1322 | |
1323 if (! (done || error_state)) | |
1324 { | |
1325 octave_value tmp_rhs; | |
1326 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1327 octave_base_value::type_conv_info cf_rhs |
5759 | 1328 = rhs.numeric_conversion_function (); |
1329 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1330 octave_base_value::type_conv_info cf_this |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1331 = numeric_conversion_function (); |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1332 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1333 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1334 if (cf_rhs.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1335 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1336 t_lhs, cf_rhs.type_id ()) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1337 || octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1338 cf_rhs.type_id ()) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1339 cf_this = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1340 else if (cf_this.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1341 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1342 cf_this.type_id (), t_rhs) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1343 || octave_value_typeinfo::lookup_pref_assign_conv (cf_this.type_id (), |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1344 t_rhs) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1345 cf_rhs = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1346 |
5759 | 1347 if (cf_rhs) |
1348 { | |
1349 octave_base_value *tmp = cf_rhs (rhs.get_rep ()); | |
1350 | |
1351 if (tmp) | |
1352 tmp_rhs = octave_value (tmp); | |
1353 else | |
1354 { | |
1355 gripe_assign_conversion_failed (type_name (), | |
1356 rhs.type_name ()); | |
1357 return octave_value (); | |
1358 } | |
1359 } | |
1360 else | |
1361 tmp_rhs = rhs; | |
1362 | |
5897 | 1363 count++; |
1364 octave_value tmp_lhs = octave_value (this); | |
5759 | 1365 |
1366 if (cf_this) | |
1367 { | |
1368 octave_base_value *tmp = cf_this (*this); | |
1369 | |
1370 if (tmp) | |
5897 | 1371 tmp_lhs = octave_value (tmp); |
5759 | 1372 else |
1373 { | |
1374 gripe_assign_conversion_failed (type_name (), | |
1375 rhs.type_name ()); | |
1376 return octave_value (); | |
1377 } | |
1378 } | |
1379 | |
1380 if (cf_this || cf_rhs) | |
1381 { | |
5897 | 1382 retval = tmp_lhs.subsasgn (type, idx, tmp_rhs); |
5759 | 1383 |
1384 done = (! error_state); | |
1385 } | |
1386 else | |
1387 gripe_no_conversion (octave_value::assign_op_as_string (octave_value::op_asn_eq), | |
1388 type_name (), rhs.type_name ()); | |
1389 } | |
1390 } | |
1391 | |
1392 // The assignment may have converted to a type that is wider than | |
1393 // necessary. | |
1394 | |
1395 retval.maybe_mutate (); | |
1396 | |
1397 return retval; | |
1398 } | |
1399 | |
1400 // Current indentation. | |
1401 int octave_base_value::curr_print_indent_level = 0; | |
1402 | |
1403 // TRUE means we are at the beginning of a line. | |
1404 bool octave_base_value::beginning_of_line = true; | |
1405 | |
1406 // Each print() function should call this before printing anything. | |
1407 // | |
1408 // This doesn't need to be fast, but isn't there a better way? | |
1409 | |
1410 void | |
1411 octave_base_value::indent (std::ostream& os) const | |
1412 { | |
1413 assert (curr_print_indent_level >= 0); | |
1414 | |
1415 if (beginning_of_line) | |
1416 { | |
5775 | 1417 // FIXME -- do we need this? |
5759 | 1418 // os << prefix; |
1419 | |
1420 for (int i = 0; i < curr_print_indent_level; i++) | |
1421 os << " "; | |
1422 | |
1423 beginning_of_line = false; | |
1424 } | |
1425 } | |
1426 | |
1427 // All print() functions should use this to print new lines. | |
1428 | |
1429 void | |
1430 octave_base_value::newline (std::ostream& os) const | |
1431 { | |
1432 os << "\n"; | |
1433 | |
1434 beginning_of_line = true; | |
1435 } | |
1436 | |
1437 // For ressetting print state. | |
1438 | |
1439 void | |
1440 octave_base_value::reset (void) const | |
1441 { | |
1442 beginning_of_line = true; | |
1443 curr_print_indent_level = 0; | |
1444 } | |
1445 | |
3203 | 1446 CONVDECLX (matrix_conv) |
2376 | 1447 { |
1448 return new octave_matrix (); | |
1449 } | |
1450 | |
3203 | 1451 CONVDECLX (complex_matrix_conv) |
2376 | 1452 { |
1453 return new octave_complex_matrix (); | |
1454 } | |
1455 | |
3203 | 1456 CONVDECLX (string_conv) |
2376 | 1457 { |
1458 return new octave_char_matrix_str (); | |
1459 } | |
1460 | |
3928 | 1461 CONVDECLX (cell_conv) |
1462 { | |
1463 return new octave_cell (); | |
1464 } | |
1465 | |
2376 | 1466 void |
1467 install_base_type_conversions (void) | |
1468 { | |
1469 INSTALL_ASSIGNCONV (octave_base_value, octave_scalar, octave_matrix); | |
1470 INSTALL_ASSIGNCONV (octave_base_value, octave_matrix, octave_matrix); | |
1471 INSTALL_ASSIGNCONV (octave_base_value, octave_complex, octave_complex_matrix); | |
1472 INSTALL_ASSIGNCONV (octave_base_value, octave_complex_matrix, octave_complex_matrix); | |
1473 INSTALL_ASSIGNCONV (octave_base_value, octave_range, octave_matrix); | |
1474 INSTALL_ASSIGNCONV (octave_base_value, octave_char_matrix_str, octave_char_matrix_str); | |
3928 | 1475 INSTALL_ASSIGNCONV (octave_base_value, octave_cell, octave_cell); |
2376 | 1476 |
1477 INSTALL_WIDENOP (octave_base_value, octave_matrix, matrix_conv); | |
1478 INSTALL_WIDENOP (octave_base_value, octave_complex_matrix, complex_matrix_conv); | |
1479 INSTALL_WIDENOP (octave_base_value, octave_char_matrix_str, string_conv); | |
3928 | 1480 INSTALL_WIDENOP (octave_base_value, octave_cell, cell_conv); |
2376 | 1481 } |
1482 | |
7193 | 1483 DEFUN (sparse_auto_mutate, args, nargout, |
1484 "-*- texinfo -*-\n\ | |
1485 @deftypefn {Built-in Function} {@var{val} =} sparse_auto_mutate ()\n\ | |
1486 @deftypefnx {Built-in Function} {@var{old_val} =} sparse_auto_mutate (@var{new_val})\n\ | |
1487 Query or set the internal variable that controls whether Octave will\n\ | |
1488 automatically mutate sparse matrices to real matrices to save memory.\n\ | |
1489 For example,\n\ | |
1490 \n\ | |
1491 @example\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1492 @group\n\ |
7193 | 1493 s = speye(3);\n\ |
1494 sparse_auto_mutate (false)\n\ | |
1495 s (:, 1) = 1;\n\ | |
1496 typeinfo (s)\n\ | |
1497 @result{} sparse matrix\n\ | |
1498 sparse_auto_mutate (true)\n\ | |
1499 s (1, :) = 1;\n\ | |
1500 typeinfo (s)\n\ | |
1501 @result{} matrix\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
1502 @end group\n\ |
7193 | 1503 @end example\n\ |
1504 @end deftypefn") | |
1505 { | |
1506 return SET_INTERNAL_VARIABLE (sparse_auto_mutate); | |
1507 } |