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