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