Mercurial > hg > octave-nkf
diff liboctave/Array.cc @ 5992:4289ed95dde8
[project @ 2006-09-15 20:29:18 by jwe]
author | jwe |
---|---|
date | Fri, 15 Sep 2006 20:29:18 +0000 |
parents | 0dd8428bb260 |
children | 4036e6fca790 |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2358,7 +2358,7 @@ template <class T> Array<T> -Array<T>::index (Array<idx_vector>& ra_idx, int resize_ok, const T&) const +Array<T>::index (Array<idx_vector>& ra_idx, int resize_ok, const T& rfv) const { // This function handles all calls with more than one idx. // For (3x3x3), the call can be A(2,5), A(2,:,:), A(3,2,3) etc. @@ -2381,14 +2381,17 @@ else trim_trailing_singletons = false; - for (octave_idx_type i = 0; i < iidx.capacity (); i++) - if (iidx (i) != 0) - { - (*current_liboctave_error_handler) - ("index exceeds N-d array dimensions"); - - return retval; - } + if (! resize_ok) + { + for (octave_idx_type i = 0; i < iidx.capacity (); i++) + if (iidx (i) != 0) + { + (*current_liboctave_error_handler) + ("index exceeds N-d array dimensions"); + + return retval; + } + } } ra_idx.resize (ra_idx_len); @@ -2437,9 +2440,8 @@ octave_idx_type numelem_elt = get_scalar_idx (elt_idx, new_dims); - if (numelem_elt > length () || numelem_elt < 0) - (*current_liboctave_error_handler) - ("invalid N-d array index"); + if (numelem_elt >= length () || numelem_elt < 0) + retval.elem (i) = rfv; else retval.elem (i) = elem (numelem_elt);