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