Mercurial > hg > octave-lyh
changeset 4742:2527c2fd4345
[project @ 2004-02-06 00:59:45 by jwe]
author | jwe |
---|---|
date | Fri, 06 Feb 2004 00:59:45 +0000 |
parents | e44d0ac643a5 |
children | 754e2855a32d |
files | src/ChangeLog src/ov-base-mat.cc |
diffstat | 2 files changed, 27 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-02-05 Petter Risholm <risholm@stud.ntnu.no> + + * ov-base-mat.cc (octave_base_matrix<MT>::do_index_op): + Don't fail if number of indices is greater than 2. + 2004-02-05 John W. Eaton <jwe@bevo.che.wisc.edu> * data.cc (Fsize): Update for N-d objects.
--- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -121,26 +121,14 @@ { octave_value retval; - int len = idx.length (); + int n_idx = idx.length (); - switch (len) - { - case 2: - { - int nd = matrix.ndims (); + int nd = matrix.ndims (); - if (nd == 2) - { - idx_vector i = idx (0).index_vector (); - idx_vector j = idx (1).index_vector (); - - retval = MT (matrix.index (i, j, resize_ok, - MT::resize_fill_value ())); - } - else - error ("invalid number of indices (= 2) for %d-dimensional array", - nd); - } + switch (n_idx) + { + case 0: + error ("invalid number of indices (= 0) for %d-dimensional array", nd); break; case 1: @@ -153,13 +141,24 @@ default: { - Array<idx_vector> idx_vec (len); + if (n_idx == 2 && nd == 2) + { + idx_vector i = idx (0).index_vector (); + idx_vector j = idx (1).index_vector (); - for (int i = 0; i < len; i++) - idx_vec(i) = idx(i).index_vector (); + retval = MT (matrix.index (i, j, resize_ok, + MT::resize_fill_value ())); + } + else + { + Array<idx_vector> idx_vec (n_idx); - retval = MT (matrix.index (idx_vec, resize_ok, - MT::resize_fill_value ())); + for (int i = 0; i < n_idx; i++) + idx_vec(i) = idx(i).index_vector (); + + retval = MT (matrix.index (idx_vec, resize_ok, + MT::resize_fill_value ())); + } } break; }