Mercurial > hg > octave-nkf
changeset 14625:bb5ecda3b975
periodic merge of stable to default
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 11 May 2012 12:36:25 -0400 |
parents | fd3acd55dd42 (current diff) edf9ca8a92a8 (diff) |
children | 9e4ad3f1f291 |
files | liboctave/Array.cc liboctave/dim-vector.h src/ov-struct.cc |
diffstat | 4 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -1165,16 +1165,21 @@ Array<T>::assign (const idx_vector& i, const idx_vector& j, const Array<T>& rhs, const T& rfv) { + bool initial_dims_all_zero = dimensions.all_zero (); + // Get RHS extents, discarding singletons. dim_vector rhdv = rhs.dims (); + // Get LHS extents, allowing Fortran indexing in the second dim. dim_vector dv = dimensions.redim (2); + // Check for out-of-bounds and form resizing dimensions. dim_vector rdv; + // In the special when all dimensions are zero, colons are allowed // to inquire the shape of RHS. The rules are more obscure, so we // solve that elsewhere. - if (dv.all_zero ()) + if (initial_dims_all_zero) rdv = zero_dims_inquire (i, j, rhdv); else { @@ -1268,6 +1273,8 @@ assign (ia(0), ia(1), rhs, rfv); else if (ial > 0) { + bool initial_dims_all_zero = dimensions.all_zero (); + // Get RHS extents, discarding singletons. dim_vector rhdv = rhs.dims (); @@ -1280,7 +1287,7 @@ // In the special when all dimensions are zero, colons are // allowed to inquire the shape of RHS. The rules are more // obscure, so we solve that elsewhere. - if (dv.all_zero ()) + if (initial_dims_all_zero) rdv = zero_dims_inquire (ia, rhdv); else {
--- a/liboctave/dim-vector.cc +++ b/liboctave/dim-vector.cc @@ -272,16 +272,11 @@ { dim_vector retval = alloc (n); - int pad = 0; for (int i = 0; i < n_dims; i++) - { - retval.rep[i] = rep[i]; - if (rep[i] != 0) - pad = 1; - } + retval.rep[i] = rep[i]; for (int i = n_dims; i < n; i++) - retval.rep[i] = pad; + retval.rep[i] = 1; return retval; }
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -381,8 +381,7 @@ // Force certain dimensionality, preserving numel (). Missing // dimensions are set to 1, redundant are folded into the trailing // one. If n = 1, the result is 2d and the second dim is 1 - // (dim_vectors are always at least 2D). If the original dimensions - // were all zero, the padding value is zero. + // (dim_vectors are always at least 2D). dim_vector redim (int n) const;