Mercurial > octave-nkf
annotate src/ov-base.cc @ 8721:e9cb742df9eb
imported patch sort3.diff
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 11 Feb 2009 15:25:53 +0100 |
parents | 095ae5e0a831 |
children | a669df7beb73 |
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 | |
781 Range | |
782 octave_base_value::range_value (void) const | |
783 { | |
784 Range retval; | |
785 gripe_wrong_type_arg ("octave_base_value::range_value()", type_name ()); | |
786 return retval; | |
787 } | |
788 | |
789 Octave_map | |
790 octave_base_value::map_value (void) const | |
791 { | |
792 Octave_map retval; | |
793 gripe_wrong_type_arg ("octave_base_value::map_value()", type_name ()); | |
794 return retval; | |
795 } | |
796 | |
3933 | 797 string_vector |
798 octave_base_value::map_keys (void) const | |
799 { | |
800 string_vector retval; | |
801 gripe_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); | |
802 return retval; | |
803 } | |
804 | |
2974 | 805 octave_function * |
806 octave_base_value::function_value (bool silent) | |
807 { | |
808 octave_function *retval = 0; | |
809 | |
810 if (! silent) | |
811 gripe_wrong_type_arg ("octave_base_value::function_value()", | |
812 type_name ()); | |
813 return retval; | |
814 } | |
815 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
816 const octave_function * |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
817 octave_base_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
818 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
819 const octave_function *retval = 0; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
820 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
821 if (! silent) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
822 gripe_wrong_type_arg ("octave_base_value::function_value()", |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
823 type_name ()); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
824 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
825 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
826 |
4700 | 827 octave_user_function * |
828 octave_base_value::user_function_value (bool silent) | |
829 { | |
830 octave_user_function *retval = 0; | |
831 | |
832 if (! silent) | |
833 gripe_wrong_type_arg ("octave_base_value::user_function_value()", | |
834 type_name ()); | |
835 return retval; | |
836 } | |
837 | |
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
|
838 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
|
839 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
|
840 { |
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
|
841 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
|
842 |
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
|
843 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
|
844 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
|
845 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
|
846 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
|
847 } |
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 |
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 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
|
850 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
|
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 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
|
853 |
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 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
|
855 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
|
856 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
|
857 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
|
858 } |
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 |
4346 | 860 octave_fcn_handle * |
4343 | 861 octave_base_value::fcn_handle_value (bool silent) |
862 { | |
4346 | 863 octave_fcn_handle *retval = 0; |
4343 | 864 |
865 if (! silent) | |
866 gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()", | |
867 type_name ()); | |
868 return retval; | |
869 } | |
870 | |
4933 | 871 octave_fcn_inline * |
872 octave_base_value::fcn_inline_value (bool silent) | |
873 { | |
874 octave_fcn_inline *retval = 0; | |
875 | |
876 if (! silent) | |
877 gripe_wrong_type_arg ("octave_base_value::fcn_inline_value()", | |
878 type_name ()); | |
879 return retval; | |
880 } | |
881 | |
2882 | 882 octave_value_list |
883 octave_base_value::list_value (void) const | |
884 { | |
885 octave_value_list retval; | |
886 gripe_wrong_type_arg ("octave_base_value::list_value()", type_name ()); | |
887 return retval; | |
888 } | |
889 | |
4687 | 890 bool |
6974 | 891 octave_base_value::save_ascii (std::ostream&) |
4687 | 892 { |
893 gripe_wrong_type_arg ("octave_base_value::save_ascii()", type_name ()); | |
894 return false; | |
895 } | |
896 | |
897 bool | |
898 octave_base_value::load_ascii (std::istream&) | |
899 { | |
900 gripe_wrong_type_arg ("octave_base_value::load_ascii()", type_name ()); | |
901 return false; | |
902 } | |
903 | |
904 bool | |
905 octave_base_value::save_binary (std::ostream&, bool&) | |
906 { | |
907 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
908 return false; | |
909 } | |
910 | |
911 bool | |
912 octave_base_value::load_binary (std::istream&, bool, | |
913 oct_mach_info::float_format) | |
914 { | |
915 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
916 return false; | |
917 } | |
918 | |
919 #if defined (HAVE_HDF5) | |
4944 | 920 |
4687 | 921 bool |
922 octave_base_value::save_hdf5 (hid_t, const char *, bool) | |
923 { | |
924 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
925 | |
926 return false; | |
927 } | |
928 | |
929 bool | |
930 octave_base_value::load_hdf5 (hid_t, const char *, bool) | |
931 { | |
932 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
933 | |
934 return false; | |
935 } | |
4944 | 936 |
4687 | 937 #endif |
938 | |
4944 | 939 int |
940 octave_base_value::write (octave_stream&, int, oct_data_conv::data_type, | |
941 int, oct_mach_info::float_format) const | |
942 { | |
943 gripe_wrong_type_arg ("octave_base_value::write()", type_name ()); | |
944 | |
945 return false; | |
946 } | |
947 | |
5900 | 948 mxArray * |
949 octave_base_value::as_mxArray (void) const | |
950 { | |
951 gripe_wrong_type_arg ("octave_base_value::as_mxArray ()", type_name ()); | |
952 | |
953 return 0; | |
954 } | |
955 | |
7433 | 956 octave_value |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
957 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
|
958 { |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
959 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
|
960 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
961 return octave_value(); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
962 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
963 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
964 octave_value |
7433 | 965 octave_base_value::sort (octave_idx_type, sortmode) const |
966 { | |
967 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
968 | |
969 return octave_value(); | |
970 } | |
971 | |
972 octave_value | |
973 octave_base_value::sort (Array<octave_idx_type> &, | |
974 octave_idx_type, sortmode) const | |
975 { | |
976 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
977 | |
978 return octave_value(); | |
979 } | |
980 | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
981 sortmode |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
982 octave_base_value::issorted (sortmode) const |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
983 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
984 gripe_wrong_type_arg ("octave_base_value::issorted ()", type_name ()); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
985 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
986 return UNSORTED; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
987 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
988 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
989 Array<octave_idx_type> |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
990 octave_base_value::sortrows_idx (sortmode) const |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
991 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
992 gripe_wrong_type_arg ("octave_base_value::sortrows_idx ()", type_name ()); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
993 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
994 return Array<octave_idx_type> (); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
995 } |
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 sortmode |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
998 octave_base_value::issorted_rows (sortmode) const |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
999 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1000 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
|
1001 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1002 return UNSORTED; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1003 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
1004 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1005 #define UNDEFINED_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1006 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1007 octave_base_value::F (void) const \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1008 { \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1009 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
|
1010 return octave_value (); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1011 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1012 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1013 UNDEFINED_MAPPER (abs) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1014 UNDEFINED_MAPPER (acos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1015 UNDEFINED_MAPPER (acosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1016 UNDEFINED_MAPPER (angle) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1017 UNDEFINED_MAPPER (arg) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1018 UNDEFINED_MAPPER (asin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1019 UNDEFINED_MAPPER (asinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1020 UNDEFINED_MAPPER (atan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1021 UNDEFINED_MAPPER (atanh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1022 UNDEFINED_MAPPER (ceil) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1023 UNDEFINED_MAPPER (conj) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1024 UNDEFINED_MAPPER (cos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1025 UNDEFINED_MAPPER (cosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1026 UNDEFINED_MAPPER (erf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1027 UNDEFINED_MAPPER (erfc) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1028 UNDEFINED_MAPPER (exp) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1029 UNDEFINED_MAPPER (expm1) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1030 UNDEFINED_MAPPER (finite) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1031 UNDEFINED_MAPPER (fix) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1032 UNDEFINED_MAPPER (floor) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1033 UNDEFINED_MAPPER (gamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1034 UNDEFINED_MAPPER (imag) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1035 UNDEFINED_MAPPER (isinf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1036 UNDEFINED_MAPPER (isna) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1037 UNDEFINED_MAPPER (isnan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1038 UNDEFINED_MAPPER (lgamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1039 UNDEFINED_MAPPER (log) |
7740 | 1040 UNDEFINED_MAPPER (log2) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1041 UNDEFINED_MAPPER (log10) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1042 UNDEFINED_MAPPER (log1p) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1043 UNDEFINED_MAPPER (real) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1044 UNDEFINED_MAPPER (round) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
1045 UNDEFINED_MAPPER (roundb) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1046 UNDEFINED_MAPPER (signum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1047 UNDEFINED_MAPPER (sin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1048 UNDEFINED_MAPPER (sinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1049 UNDEFINED_MAPPER (sqrt) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1050 UNDEFINED_MAPPER (tan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1051 UNDEFINED_MAPPER (tanh) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1052 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1053 // String mapper functions, convert to a string |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1054 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1055 #define STRING_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1056 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1057 octave_base_value::F (void) const \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1058 { \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1059 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
|
1060 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
|
1061 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1062 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1063 STRING_MAPPER (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1064 STRING_MAPPER (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1065 STRING_MAPPER (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1066 STRING_MAPPER (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1067 STRING_MAPPER (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1068 STRING_MAPPER (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1069 STRING_MAPPER (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1070 STRING_MAPPER (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1071 STRING_MAPPER (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1072 STRING_MAPPER (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1073 STRING_MAPPER (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1074 STRING_MAPPER (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1075 STRING_MAPPER (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1076 STRING_MAPPER (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1077 STRING_MAPPER (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1078 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1079 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1080 octave_base_value::lock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1081 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1082 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
|
1083 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1084 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1085 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1086 octave_base_value::unlock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1087 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1088 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
|
1089 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1090 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1091 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1092 octave_base_value::dump (std::ostream& os) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1093 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1094 dim_vector dv = this->dims (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1095 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1096 os << "class: " << this->class_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1097 << " type: " << this->type_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1098 << " dims: " << dv.str (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1099 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1100 |
5759 | 1101 static void |
1102 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) | |
1103 { | |
1104 error ("assignment of `%s' to indexed `%s' not implemented", | |
1105 tn2.c_str (), tn1.c_str ()); | |
1106 } | |
1107 | |
1108 static void | |
1109 gripe_assign_conversion_failed (const std::string& tn1, | |
1110 const std::string& tn2) | |
1111 { | |
1112 error ("type conversion for assignment of `%s' to indexed `%s' failed", | |
1113 tn2.c_str (), tn1.c_str ()); | |
1114 } | |
1115 | |
1116 static void | |
1117 gripe_no_conversion (const std::string& on, const std::string& tn1, | |
1118 const std::string& tn2) | |
1119 { | |
1120 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", | |
1121 on.c_str (), tn2.c_str (), tn1.c_str ()); | |
1122 } | |
1123 | |
1124 octave_value | |
1125 octave_base_value::numeric_assign (const std::string& type, | |
1126 const std::list<octave_value_list>& idx, | |
1127 const octave_value& rhs) | |
1128 { | |
1129 octave_value retval; | |
1130 | |
1131 int t_lhs = type_id (); | |
1132 int t_rhs = rhs.type_id (); | |
1133 | |
1134 octave_value_typeinfo::assign_op_fcn f | |
1135 = octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, | |
1136 t_lhs, t_rhs); | |
1137 | |
1138 bool done = false; | |
1139 | |
1140 if (f) | |
1141 { | |
1142 f (*this, idx.front (), rhs.get_rep ()); | |
1143 | |
1144 done = (! error_state); | |
1145 } | |
1146 | |
1147 if (done) | |
1148 { | |
1149 count++; | |
1150 retval = octave_value (this); | |
1151 } | |
1152 else | |
1153 { | |
1154 int t_result | |
1155 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); | |
1156 | |
1157 if (t_result >= 0) | |
1158 { | |
1159 octave_base_value::type_conv_fcn cf | |
1160 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); | |
1161 | |
1162 if (cf) | |
1163 { | |
5874 | 1164 octave_base_value *tmp = cf (*this); |
5759 | 1165 |
1166 if (tmp) | |
1167 { | |
5874 | 1168 octave_value val (tmp); |
1169 | |
1170 retval = val.subsasgn (type, idx, rhs); | |
5759 | 1171 |
1172 done = (! error_state); | |
1173 } | |
1174 else | |
1175 gripe_assign_conversion_failed (type_name (), | |
1176 rhs.type_name ()); | |
1177 } | |
1178 else | |
1179 gripe_indexed_assignment (type_name (), rhs.type_name ()); | |
1180 } | |
1181 | |
1182 if (! (done || error_state)) | |
1183 { | |
1184 octave_value tmp_rhs; | |
1185 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1186 octave_base_value::type_conv_info cf_rhs |
5759 | 1187 = rhs.numeric_conversion_function (); |
1188 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1189 octave_base_value::type_conv_info cf_this |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1190 = numeric_conversion_function (); |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1191 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1192 // Try biased (one-sided) conversions first. |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1193 if (cf_rhs.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1194 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1195 t_lhs, cf_rhs.type_id ()) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1196 || octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1197 cf_rhs.type_id ()) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1198 cf_this = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1199 else if (cf_this.type_id () >= 0 |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1200 && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1201 cf_this.type_id (), t_rhs) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1202 || octave_value_typeinfo::lookup_pref_assign_conv (cf_this.type_id (), |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1203 t_rhs) >= 0)) |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1204 cf_rhs = 0; |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7885
diff
changeset
|
1205 |
5759 | 1206 if (cf_rhs) |
1207 { | |
1208 octave_base_value *tmp = cf_rhs (rhs.get_rep ()); | |
1209 | |
1210 if (tmp) | |
1211 tmp_rhs = octave_value (tmp); | |
1212 else | |
1213 { | |
1214 gripe_assign_conversion_failed (type_name (), | |
1215 rhs.type_name ()); | |
1216 return octave_value (); | |
1217 } | |
1218 } | |
1219 else | |
1220 tmp_rhs = rhs; | |
1221 | |
5897 | 1222 count++; |
1223 octave_value tmp_lhs = octave_value (this); | |
5759 | 1224 |
1225 if (cf_this) | |
1226 { | |
1227 octave_base_value *tmp = cf_this (*this); | |
1228 | |
1229 if (tmp) | |
5897 | 1230 tmp_lhs = octave_value (tmp); |
5759 | 1231 else |
1232 { | |
1233 gripe_assign_conversion_failed (type_name (), | |
1234 rhs.type_name ()); | |
1235 return octave_value (); | |
1236 } | |
1237 } | |
1238 | |
1239 if (cf_this || cf_rhs) | |
1240 { | |
5897 | 1241 retval = tmp_lhs.subsasgn (type, idx, tmp_rhs); |
5759 | 1242 |
1243 done = (! error_state); | |
1244 } | |
1245 else | |
1246 gripe_no_conversion (octave_value::assign_op_as_string (octave_value::op_asn_eq), | |
1247 type_name (), rhs.type_name ()); | |
1248 } | |
1249 } | |
1250 | |
1251 // The assignment may have converted to a type that is wider than | |
1252 // necessary. | |
1253 | |
1254 retval.maybe_mutate (); | |
1255 | |
1256 return retval; | |
1257 } | |
1258 | |
1259 // Current indentation. | |
1260 int octave_base_value::curr_print_indent_level = 0; | |
1261 | |
1262 // TRUE means we are at the beginning of a line. | |
1263 bool octave_base_value::beginning_of_line = true; | |
1264 | |
1265 // Each print() function should call this before printing anything. | |
1266 // | |
1267 // This doesn't need to be fast, but isn't there a better way? | |
1268 | |
1269 void | |
1270 octave_base_value::indent (std::ostream& os) const | |
1271 { | |
1272 assert (curr_print_indent_level >= 0); | |
1273 | |
1274 if (beginning_of_line) | |
1275 { | |
5775 | 1276 // FIXME -- do we need this? |
5759 | 1277 // os << prefix; |
1278 | |
1279 for (int i = 0; i < curr_print_indent_level; i++) | |
1280 os << " "; | |
1281 | |
1282 beginning_of_line = false; | |
1283 } | |
1284 } | |
1285 | |
1286 // All print() functions should use this to print new lines. | |
1287 | |
1288 void | |
1289 octave_base_value::newline (std::ostream& os) const | |
1290 { | |
1291 os << "\n"; | |
1292 | |
1293 beginning_of_line = true; | |
1294 } | |
1295 | |
1296 // For ressetting print state. | |
1297 | |
1298 void | |
1299 octave_base_value::reset (void) const | |
1300 { | |
1301 beginning_of_line = true; | |
1302 curr_print_indent_level = 0; | |
1303 } | |
1304 | |
3203 | 1305 CONVDECLX (matrix_conv) |
2376 | 1306 { |
1307 return new octave_matrix (); | |
1308 } | |
1309 | |
3203 | 1310 CONVDECLX (complex_matrix_conv) |
2376 | 1311 { |
1312 return new octave_complex_matrix (); | |
1313 } | |
1314 | |
3203 | 1315 CONVDECLX (string_conv) |
2376 | 1316 { |
1317 return new octave_char_matrix_str (); | |
1318 } | |
1319 | |
3928 | 1320 CONVDECLX (cell_conv) |
1321 { | |
1322 return new octave_cell (); | |
1323 } | |
1324 | |
2376 | 1325 void |
1326 install_base_type_conversions (void) | |
1327 { | |
1328 INSTALL_ASSIGNCONV (octave_base_value, octave_scalar, octave_matrix); | |
1329 INSTALL_ASSIGNCONV (octave_base_value, octave_matrix, octave_matrix); | |
1330 INSTALL_ASSIGNCONV (octave_base_value, octave_complex, octave_complex_matrix); | |
1331 INSTALL_ASSIGNCONV (octave_base_value, octave_complex_matrix, octave_complex_matrix); | |
1332 INSTALL_ASSIGNCONV (octave_base_value, octave_range, octave_matrix); | |
1333 INSTALL_ASSIGNCONV (octave_base_value, octave_char_matrix_str, octave_char_matrix_str); | |
3928 | 1334 INSTALL_ASSIGNCONV (octave_base_value, octave_cell, octave_cell); |
2376 | 1335 |
1336 INSTALL_WIDENOP (octave_base_value, octave_matrix, matrix_conv); | |
1337 INSTALL_WIDENOP (octave_base_value, octave_complex_matrix, complex_matrix_conv); | |
1338 INSTALL_WIDENOP (octave_base_value, octave_char_matrix_str, string_conv); | |
3928 | 1339 INSTALL_WIDENOP (octave_base_value, octave_cell, cell_conv); |
2376 | 1340 } |
1341 | |
7193 | 1342 DEFUN (sparse_auto_mutate, args, nargout, |
1343 "-*- texinfo -*-\n\ | |
1344 @deftypefn {Built-in Function} {@var{val} =} sparse_auto_mutate ()\n\ | |
1345 @deftypefnx {Built-in Function} {@var{old_val} =} sparse_auto_mutate (@var{new_val})\n\ | |
1346 Query or set the internal variable that controls whether Octave will\n\ | |
1347 automatically mutate sparse matrices to real matrices to save memory.\n\ | |
1348 For example,\n\ | |
1349 \n\ | |
1350 @example\n\ | |
1351 s = speye(3);\n\ | |
1352 sparse_auto_mutate (false)\n\ | |
1353 s (:, 1) = 1;\n\ | |
1354 typeinfo (s)\n\ | |
1355 @result{} sparse matrix\n\ | |
1356 sparse_auto_mutate (true)\n\ | |
1357 s (1, :) = 1;\n\ | |
1358 typeinfo (s)\n\ | |
1359 @result{} matrix\n\ | |
1360 @end example\n\ | |
1361 @end deftypefn") | |
1362 { | |
1363 return SET_INTERNAL_VARIABLE (sparse_auto_mutate); | |
1364 } | |
1365 | |
2376 | 1366 /* |
1367 ;;; Local Variables: *** | |
1368 ;;; mode: C++ *** | |
1369 ;;; End: *** | |
1370 */ |