Mercurial > hg > octave-terminal
changeset 4657:a585a2dfca6c
[project @ 2003-11-25 01:30:09 by jwe]
author | jwe |
---|---|
date | Tue, 25 Nov 2003 01:30:09 +0000 |
parents | e3da702f7502 |
children | c7ee06a9fbc3 |
files | liboctave/Array.cc liboctave/ChangeLog |
diffstat | 2 files changed, 47 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2539,53 +2539,57 @@ { lhs.maybe_delete_elements (idx, rfv); } - else if (rhs_is_scalar) + else if (n_idx == 1) { - if (n_idx == 0) - (*current_liboctave_error_handler) - ("number of indices is zero"); - else if (n_idx == 1) + idx_vector iidx = idx(0); + + if (liboctave_wfi_flag + && ! (iidx.is_colon () + || (iidx.one_zero_only () + && iidx.orig_dimensions () == lhs.dims ()))) + (*current_liboctave_warning_handler) + ("single index used for n-d array"); + + int lhs_len = lhs.length (); + + int len = iidx.freeze (lhs_len, "n-d arrray"); + + if (iidx) { - idx_vector iidx = idx(0); - - if (liboctave_wfi_flag - && ! (iidx.is_colon () - || (iidx.one_zero_only () - && iidx.orig_dimensions () == lhs.dims ()))) - (*current_liboctave_warning_handler) - ("single index used for n-d array"); - - int lhs_len = lhs.length (); - - int len = iidx.freeze (lhs_len, "n-d arrray"); - - if (iidx) + if (len == 0) { - if (len == 0) - { - if (! (rhs_dims.all_ones () || rhs_dims.all_zero ())) - (*current_liboctave_error_handler) - ("A([]) = X: X must be an empty matrix or scalar"); - } - else if (len <= lhs_len) + if (! (rhs_dims.all_ones () || rhs_dims.all_zero ())) + (*current_liboctave_error_handler) + ("A([]) = X: X must be an empty matrix or scalar"); + } + else if (len == rhs.length ()) + { + for (int i = 0; i < len; i++) { - RT scalar = rhs.elem (0); - - for (int i = 0; i < len; i++) - { - int ii = iidx.elem (i); - - lhs.elem (ii) = scalar; - } - } - else - { - (*current_liboctave_error_handler) - ("A(I) = X: X must be a scalar or a matrix with the same size as I"); - - retval = 0; + int ii = iidx.elem (i); + + lhs.elem (ii) = rhs.elem (i); } } + else if (rhs_is_scalar && len <= lhs_len) + { + RT scalar = rhs.elem (0); + + for (int i = 0; i < len; i++) + { + int ii = iidx.elem (i); + + lhs.elem (ii) = scalar; + } + } + else + { + (*current_liboctave_error_handler) + ("A(I) = X: X must be a scalar or a matrix with the same size as I"); + + retval = 0; + } + // idx_vector::freeze() printed an error message for us. } else if (n_idx < lhs_dims.length ()) @@ -2839,7 +2843,7 @@ // 2D info: // - // << prefix << "rows: " << rows () << "\n" + // << pefix << "rows: " << rows () << "\n" // << prefix << "cols: " << cols () << "\n"; }