From bug-request at octave dot org Fri Sep 24 18:47:19 2004 Subject: failure on assignment of Nx0 subarray From: "John W. Eaton" To: Quentin Spencer Cc: bug at octave dot org Date: Fri, 24 Sep 2004 19:43:16 -0400 On 24-Sep-2004, Quentin Spencer wrote: | Bug report for Octave 2.1.60 configured for i686-pc-linux-gnu | | Description: | ----------- | | Assignments on Nx0 subarrays of certain arrays fail. This appears to | happen when A(X) = B when both X and B are Nx0, but not when B is 0x0 or | if A has only one non-singleton dimension. | | | Repeat-By: | --------- | | octave:1> z=zeros(1,0); | octave:2> a=ones(2,2,1); | octave:3> a(z) = []; | octave:4> a(z) = a(z); | error: A([]) = X: X must be an empty matrix or scalar | error: assignment failed, or no method for `matrix = matrix' | error: evaluating assignment expression near line 4, column 6 | octave:4> | octave:4> a=ones(1,2,1); | octave:5> a(z) = a(z); | octave:6> | octave:6> a=ones(2,2); | octave:7> a(z) = a(z); | error: A([]) = X: X must be an empty matrix or scalar | error: assignment failed, or no method for `matrix = matrix' | error: evaluating assignment expression near line 7, column 6 Please try the following patch. Thanks, jwe liboctave/ChangeLog: 2004-09-24 John W. Eaton * Array.cc (assign2, assignN): If index is empty, allow RHS to be any empty matrix, not just []. Index: liboctave/Array.cc =================================================================== RCS file: /usr/local/cvsroot/octave/liboctave/Array.cc,v retrieving revision 1.120 diff -u -r1.120 Array.cc --- a/liboctave/Array.cc 3 Aug 2004 20:45:34 -0000 1.120 +++ b/liboctave/Array.cc 24 Sep 2004 23:40:30 -0000 at @ -2642,7 +2642,7 @@ else if (n == 0 && m == 0) { if (! ((rhs_nr == 1 && rhs_nc == 1) - || (rhs_nr == 0 && rhs_nc == 0))) + || (rhs_nr == 0 || rhs_nc == 0))) { (*current_liboctave_error_handler) ("A([], []) = X: X must be an empty matrix or a scalar"); at @ -2780,7 +2780,7 @@ else if (len == 0) { if (! ((rhs_nr == 1 && rhs_nc == 1) - || (rhs_nr == 0 && rhs_nc == 0))) + || (rhs_nr == 0 || rhs_nc == 0))) (*current_liboctave_error_handler) ("A([]) = X: X must be an empty matrix or scalar"); } at @ -2873,7 +2873,7 @@ { if (len == 0) { - if (! (rhs_dims.all_ones () || rhs_dims.all_zero ())) + if (! (rhs_dims.all_ones () || rhs_dims.any_zero ())) { (*current_liboctave_error_handler) ("A([]) = X: X must be an empty matrix or scalar"); ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------