Mercurial > hg > octave-nkf
comparison src/ov-cell.cc @ 3354:87721841efd7
[project @ 1999-11-17 19:06:11 by jwe]
author | jwe |
---|---|
date | Wed, 17 Nov 1999 19:06:15 +0000 |
parents | 6b36317855ff |
children | 0fb75d95b14f |
comparison
equal
deleted
inserted
replaced
3353:6b36317855ff | 3354:87721841efd7 |
---|---|
34 #include "lo-utils.h" | 34 #include "lo-utils.h" |
35 | 35 |
36 #include "defun.h" | 36 #include "defun.h" |
37 #include "error.h" | 37 #include "error.h" |
38 #include "ov-cell.h" | 38 #include "ov-cell.h" |
39 #include "oct-obj.h" | |
39 #include "unwind-prot.h" | 40 #include "unwind-prot.h" |
41 #include "utils.h" | |
40 | 42 |
41 DEFINE_OCTAVE_ALLOCATOR (octave_cell); | 43 DEFINE_OCTAVE_ALLOCATOR (octave_cell); |
42 | 44 |
43 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell"); | 45 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell"); |
44 | 46 |
45 octave_value | 47 octave_value |
46 octave_cell::do_index_op (const octave_value_list& idx) | 48 octave_cell::do_index_op (const octave_value_list& idx) |
47 { | 49 { |
48 octave_value retval; | 50 octave_value retval; |
49 | 51 |
50 #if 0 | 52 int len = idx.length (); |
51 if (idx.length () == 1) | 53 |
52 { | 54 switch (len) |
53 idx_vector i = idx (0).index_vector (); | 55 { |
54 | 56 case 2: |
55 retval = octave_value_list (lst.index (i)); | 57 { |
56 } | 58 idx_vector i = idx (0).index_vector (); |
57 else | 59 idx_vector j = idx (1).index_vector (); |
58 error ("lists may only be indexed by a single scalar"); | 60 |
59 #endif | 61 retval = cell_val.index (i, j); |
62 } | |
63 break; | |
64 | |
65 case 1: | |
66 { | |
67 idx_vector i = idx (0).index_vector (); | |
68 | |
69 retval = cell_val.index (i); | |
70 } | |
71 break; | |
72 | |
73 default: | |
74 { | |
75 string n = type_name (); | |
76 | |
77 error ("invalid number of indices (%d) for %s value", | |
78 len, n.c_str ()); | |
79 } | |
80 break; | |
81 } | |
60 | 82 |
61 return retval; | 83 return retval; |
62 } | 84 } |
63 | 85 |
64 void | 86 void |
150 newline (os); | 172 newline (os); |
151 } | 173 } |
152 return false; | 174 return false; |
153 } | 175 } |
154 | 176 |
177 DEFUN (iscell, args, , | |
178 "iscell (x): return nonzero if x is a cell array") | |
179 { | |
180 octave_value retval; | |
181 | |
182 if (args.length () == 1) | |
183 retval = args(0).is_cell (); | |
184 else | |
185 print_usage ("iscell"); | |
186 | |
187 return retval; | |
188 } | |
189 | |
190 DEFUN (cell, args, , | |
191 "cell (N)\n\ | |
192 cell (M, N)\n\ | |
193 cell (size (A))") | |
194 { | |
195 octave_value retval; | |
196 | |
197 int nargin = args.length (); | |
198 | |
199 switch (nargin) | |
200 { | |
201 case 1: | |
202 { | |
203 int nr, nc; | |
204 get_dimensions (args(0), "cell", nr, nc); | |
205 | |
206 if (! error_state) | |
207 retval = Cell (nr, nc, Matrix ()); | |
208 } | |
209 break; | |
210 | |
211 case 2: | |
212 { | |
213 int nr, nc; | |
214 get_dimensions (args(0), args(1), "cell", nr, nc); | |
215 | |
216 if (! error_state) | |
217 retval = Cell (nr, nc, Matrix ()); | |
218 } | |
219 break; | |
220 | |
221 default: | |
222 print_usage ("cell"); | |
223 break; | |
224 } | |
225 | |
226 return retval; | |
227 } | |
228 | |
155 /* | 229 /* |
156 ;;; Local Variables: *** | 230 ;;; Local Variables: *** |
157 ;;; mode: C++ *** | 231 ;;; mode: C++ *** |
158 ;;; End: *** | 232 ;;; End: *** |
159 */ | 233 */ |