Mercurial > hg > octave-nkf
changeset 5081:273205761b4d
[project @ 2004-11-17 15:15:00 by jwe]
author | jwe |
---|---|
date | Wed, 17 Nov 2004 15:15:01 +0000 |
parents | 7929486ef2ed |
children | acbf858264d6 |
files | liboctave/Array.cc liboctave/ChangeLog src/pt-arg-list.cc |
diffstat | 3 files changed, 30 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -1934,19 +1934,27 @@ { Array<T> retval; - switch (ndims ()) + dim_vector dv = idx_arg.orig_dimensions (); + + if (dv.length () > 2 || ndims () > 2) + retval = indexN (idx_arg, resize_ok, rfv); + else { - case 1: - retval = index1 (idx_arg, resize_ok, rfv); - break; - - case 2: - retval = index2 (idx_arg, resize_ok, rfv); - break; - - default: - retval = indexN (idx_arg, resize_ok, rfv); - break; + switch (ndims ()) + { + case 1: + retval = index1 (idx_arg, resize_ok, rfv); + break; + + case 2: + retval = index2 (idx_arg, resize_ok, rfv); + break; + + default: + (*current_liboctave_error_handler) + ("invalid array (internal error)"); + break; + } } return retval;
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2004-11-17 John W. Eaton <jwe@octave.org> + + * Array.cc (Array<T>::index): Call generic N-d indexing function + if idx_arg is N-d. + 2004-11-09 David Bateman <dbateman@free.fr> * dNDArray.cc (concat): Delete.
--- a/src/pt-arg-list.cc +++ b/src/pt-arg-list.cc @@ -129,7 +129,11 @@ { case -1: { - int numel = indexed_object->numel (); + // We want numel = prod (size ()) here, so dont' use + // index_object->numel () as that may be different (it is + // the number of nonzero elements for sparse arrays). + + int numel = dv.numel (); if (numel < 0) {