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