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