Mercurial > hg > octave-terminal
changeset 4741:e44d0ac643a5
[project @ 2004-02-05 21:57:50 by jwe]
author | jwe |
---|---|
date | Thu, 05 Feb 2004 21:57:51 +0000 |
parents | 65f30438c2a3 |
children | 2527c2fd4345 |
files | liboctave/Array.cc liboctave/ChangeLog src/ChangeLog src/data.cc src/ls-mat5.cc src/ov-base.cc src/ov-base.h |
diffstat | 7 files changed, 39 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -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<int> 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);
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,5 +1,11 @@ 2004-02-05 Petter Risholm <risholm@stud.ntnu.no> + * Array.cc (Array<T>::maybe_delete_elements): Reshape LHS + when number of indices is less than number of dimensions. + + * Array.cc (Array<T>::assignN, Array<T>::maybe_delete_elements): + Remove unsued variable lhs_inc. + * Array.cc (Array<T>::maybe_delete_elements): Declare idx_is_colon and idx_is_colon_equiv Array<int> instead of dim_vector.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2004-02-05 John W. Eaton <jwe@bevo.che.wisc.edu> + * 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 <jwe@bevo.che.wisc.edu>
--- a/src/data.cc +++ b/src/data.cc @@ -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
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -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<std::streamoff> (element_length));
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -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 ();