Mercurial > hg > octave-lyh
diff src/ov-class.cc @ 13695:348857854c52
correctly handle multidimensional objects in num2cell
* cellfun.cc (get_object_dims, do_object2cell): New functions.
(Fnum2cell): Call do_object2cell to handle class objects.
* ov-class.cc (octave_class::size): Return dims when size method
is not available.
* test_classes.m: Delete tests for concatenation and num2cell.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 12 Oct 2011 22:25:01 -0400 |
parents | 441af0aa125a |
children | c7fac37a2afc |
line wrap: on
line diff
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -322,6 +322,17 @@ else error ("@%s/size: invalid return value", class_name ().c_str ()); } + else + { + dim_vector dv = dims (); + + int nel = dv.numel (); + + retval.resize (1, nel); + + for (int i = 0; i < nel; i++) + retval(i) = dv(i); + } return retval; }