# HG changeset patch # User jwe # Date 1076018271 0 # Node ID e44d0ac643a544ac85146a9d88e78ba5f5eb5302 # Parent 65f30438c2a3ea52edd88b103d1221a431c2d113 [project @ 2004-02-05 21:57:50 by jwe] diff -r 65f30438c2a3 -r e44d0ac643a5 liboctave/Array.cc --- a/liboctave/Array.cc Thu Feb 05 19:58:57 2004 +0000 +++ b/liboctave/Array.cc Thu Feb 05 21:57:51 2004 +0000 @@ -1468,6 +1468,17 @@ // We have colons in all indices except for one. // This index tells us which slice to delete + if (n_idx < lhs_dims.length ()) + { + for (int i = n_idx; i < lhs_dims.length (); i++) + lhs_dims(n_idx-1) *= lhs_dims(i); + + lhs_dims.resize (n_idx); + + // Reshape *this. + dimensions = lhs_dims; + } + int non_col = 0; // Find the non-colon column. @@ -1543,12 +1554,6 @@ Array result_idx (lhs_dims.length (), 0); - dim_vector lhs_inc; - lhs_inc.resize (lhs_dims.length ()); - - for (int i = 0; i < lhs_dims.length (); i++) - lhs_inc(i) = lhs_dims(i) + 1; - dim_vector new_lhs_dim = lhs_dims; new_lhs_dim(non_col) = new_dim; @@ -2851,17 +2856,11 @@ for (int i = 0; i < rhs_dims.length (); i++) frozen_rhs(i) = rhs_dims(i); - dim_vector lhs_inc; - lhs_inc.resize (lhs_dims.length ()); - - for (int i = 0; i < lhs_dims.length (); i++) - lhs_inc(i) = lhs_dims(i) + 1; - for (int i = 0; i < n; i++) { elt_idx = get_elt_idx (idx, result_idx); - if (index_in_bounds (elt_idx, lhs_inc)) + if (index_in_bounds (elt_idx, lhs_dims)) { int s = compute_index (result_rhs_idx, rhs_dims); diff -r 65f30438c2a3 -r e44d0ac643a5 liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Feb 05 19:58:57 2004 +0000 +++ b/liboctave/ChangeLog Thu Feb 05 21:57:51 2004 +0000 @@ -1,5 +1,11 @@ 2004-02-05 Petter Risholm + * Array.cc (Array::maybe_delete_elements): Reshape LHS + when number of indices is less than number of dimensions. + + * Array.cc (Array::assignN, Array::maybe_delete_elements): + Remove unsued variable lhs_inc. + * Array.cc (Array::maybe_delete_elements): Declare idx_is_colon and idx_is_colon_equiv Array instead of dim_vector. diff -r 65f30438c2a3 -r e44d0ac643a5 src/ChangeLog --- a/src/ChangeLog Thu Feb 05 19:58:57 2004 +0000 +++ b/src/ChangeLog Thu Feb 05 21:57:51 2004 +0000 @@ -1,5 +1,12 @@ 2004-02-05 John W. Eaton + * data.cc (Fsize): Update for N-d objects. + + * ls-mat5.cc (read_mat5_binary_element): Force conversion. + + * ov-base.cc (octave_base_value::char_matrix_value): + Pass force arg to convert_to_str. + * data.cc (Freshape): Chop trailing singletons from new dimensions. 2004-02-03 John W. Eaton diff -r 65f30438c2a3 -r e44d0ac643a5 src/data.cc --- a/src/data.cc Thu Feb 05 19:58:57 2004 +0000 +++ b/src/data.cc Thu Feb 05 21:57:51 2004 +0000 @@ -792,9 +792,9 @@ Return the number rows and columns of @var{a}.\n\ \n\ With one input argument and one output argument, the result is returned\n\ -in a 2 element row vector. If there are two output arguments, the\n\ -number of rows is assigned to the first, and the number of columns to\n\ -the second. For example,\n\ +in a row vector. If there are multiple output arguments, the number of\n\ +rows is assigned to the first, and the number of columns to the second,\n\ +etc. For example,\n\ \n\ @example\n\ @group\n\ @@ -807,8 +807,8 @@ @end group\n\ @end example\n\ \n\ -If given a second argument of either 1 or 2, @code{size} will return\n\ -only the row or column dimension. For example\n\ +If given a second argument, @code{size} will return the size of the\n\ +corresponding dimension. For example\n\ \n\ @example\n\ size ([1, 2; 3, 4; 5, 6], 2)\n\ @@ -852,12 +852,12 @@ error ("size: expecting scalar as second argument"); else { - if (nd == 1) - retval(0) = args(0).rows (); - else if (nd == 2) - retval(0) = args(0).columns (); + dim_vector dv = args(0).dims (); + + if (nd > 0 && nd <= dv.length ()) + retval(0) = dv(nd-1); else - error ("size: invalid second argument -- expecting 1 or 2"); + error ("size: requested dimension (= %d) out of range", nd); } } else diff -r 65f30438c2a3 -r e44d0ac643a5 src/ls-mat5.cc --- a/src/ls-mat5.cc Thu Feb 05 19:58:57 2004 +0000 +++ b/src/ls-mat5.cc Thu Feb 05 21:57:51 2004 +0000 @@ -508,7 +508,7 @@ tc = re; if (arrayclass == mxCHAR_CLASS) - tc = tc.convert_to_str (); + tc = tc.convert_to_str (false, true); } is.seekg (pos + static_cast (element_length)); diff -r 65f30438c2a3 -r e44d0ac643a5 src/ov-base.cc --- a/src/ov-base.cc Thu Feb 05 19:58:57 2004 +0000 +++ b/src/ov-base.cc Thu Feb 05 21:57:51 2004 +0000 @@ -388,11 +388,11 @@ } charMatrix -octave_base_value::char_matrix_value (bool) const +octave_base_value::char_matrix_value (bool force) const { charMatrix retval; - octave_value tmp = convert_to_str (); + octave_value tmp = convert_to_str (false, force); if (! error_state) retval = tmp.char_matrix_value (); diff -r 65f30438c2a3 -r e44d0ac643a5 src/ov-base.h --- a/src/ov-base.h Thu Feb 05 19:58:57 2004 +0000 +++ b/src/ov-base.h Thu Feb 05 21:57:51 2004 +0000 @@ -210,7 +210,7 @@ boolNDArray bool_array_value (void) const; - charMatrix char_matrix_value (bool = false) const; + charMatrix char_matrix_value (bool force = false) const; charNDArray char_array_value (bool = false) const;