Mercurial > hg > octave-nkf
diff liboctave/Array.cc @ 9310:256c0db275b6
fix behavior of find
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 07 Jun 2009 08:15:31 +0200 |
parents | 3c1762c7e787 |
children | 9fd5c56ce57a |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2476,7 +2476,7 @@ const T *src = data (); octave_idx_type nel = nelem (); const T zero = T (); - if (n < 0) + if (n < 0 || n >= nel) { // We want all elements, which means we'll almost surely need // to resize. So count first, then allocate array of exact size. @@ -2509,6 +2509,8 @@ } if (k < n) retval.resize (k); + octave_idx_type *rdata = retval.fortran_vec (); + std::reverse (rdata, rdata + k); } else {