Mercurial > hg > octave-lojdl
changeset 6922:f806e2740216
[project @ 2007-09-21 18:18:27 by jwe]
author | jwe |
---|---|
date | Fri, 21 Sep 2007 18:18:27 +0000 |
parents | 2ae5d4353d0b |
children | 1fcee6e2c4d3 |
files | liboctave/Array.cc liboctave/ChangeLog test/ChangeLog test/test_slice.m |
diffstat | 4 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -2494,14 +2494,9 @@ { dim_vector lhs_dims = lhs.dims (); - if (lhs_len == 0 && ! lhs_dims.all_zero ()) - { - (*current_liboctave_error_handler) - ("A(I) = X: unable to resize A"); - - retval = 0; - } - else + if (lhs_len != 0 + || lhs_dims.all_zero () + || (lhs_dims.length () == 2 && lhs_dims(0) < 2)) { if (rhs_len == n || rhs_len == 1) { @@ -2558,6 +2553,13 @@ retval = 0; } } + else + { + (*current_liboctave_error_handler) + ("A(I) = X: unable to resize A"); + + retval = 0; + } } else if (lhs_idx.is_colon ()) {
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2007-09-21 John W. Eaton <jwe@octave.org> + + * Array.cc (assign1 (Array<LT>&, const Array<RT>&, const LT&)): + Also allow resizing empty LHS if it is 1x0 or 0xN. + 2007-09-19 John W. Eaton <jwe@octave.org> * cmd-edit.cc (command_editor::remove_startup_hook):
--- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2007-09-21 John W. Eaton <jwe@octave.org> + + * test_slice.m: Fix test for x = ones ([0, 2]); x(idx) = N case. + See change for liboctave/Array.cc. + 2007-06-15 John W. Eaton <jwe@octave.org> * fntests.m: Also report expected failures in summary.
--- a/test/test_slice.m +++ b/test/test_slice.m @@ -46,9 +46,9 @@ ## size = [0 2] %!assert(set_slice([0 2], 11, []), zeros([0 2])); -%!error <A\(I\) = X: unable to resize A> set_slice([0 2], 11, 1) -%!error <A\(I\) = X: unable to resize A> set_slice([0 2], 11, 2) -%!error <A\(I\) = X: unable to resize A> set_slice([0 2], 11, 3) +%!assert(set_slice([0 2], 11, 1), 2); +%!assert(set_slice([0 2], 11, 2), [0, 2]); +%!assert(set_slice([0 2], 11, 3), [0, 0, 2]); %!assert(set_slice([0 2], 21, []), zeros([0 2])); %!assert(set_slice([0 2], 21, 1), [2 2]); %!assert(set_slice([0 2], 21, 2), [0 0;2 2]);