# HG changeset patch # User jwe # Date 1045187892 0 # Node ID 0b24abe1ba0bd461904d061683f1e55dbb309984 # Parent 8460c03f3b4bcd8f8eb7a19caf494ad0e5c8ebad [project @ 2003-02-14 01:58:12 by jwe] diff --git a/liboctave/Array2-idx.h b/liboctave/Array2-idx.h --- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -89,20 +89,27 @@ } else if (nr == 1 || nc == 1) { - int result_is_column_vector = (nc == 1); + // If indexing a vector with a matrix, return value has same + // shape as the index. Otherwise, it has same orientation as + // indexed object. Array tmp = Array::index (idx_arg, resize_ok); int len = tmp.length (); if (len == 0) - retval = Array2 (0, 0); + retval = Array2 (idx_orig_rows, idx_orig_columns); else { - if (result_is_column_vector) - retval = Array2 (tmp, len, 1); + if (idx_orig_rows == 1 || idx_orig_columns == 1) + { + if (nr == 1) + retval = Array2 (tmp, 1, len); + else + retval = Array2 (tmp, len, 1); + } else - retval = Array2 (tmp, 1, len); + retval = Array2 (tmp, idx_orig_rows, idx_orig_columns); } } else if (liboctave_dfi_flag diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2003-02-13 John W. Eaton + + * Array2-idx.h (Array2::index (idx_vector&, int, const T&)): + Compatibility fix. + 2003-02-10 John W. Eaton * CColVector.cc (ComplexColumnVector::extract_n): New function.