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