From bug-request at octave dot org Tue Jan 18 14:02:41 2005 Subject: cross.m doesn't work when warn_resize_on_range_error = 1 From: "John W. Eaton" To: Thomas Weber Cc: bug at octave dot org Date: Tue, 18 Jan 2005 15:05:45 -0500 On 14-Jan-2005, Thomas Weber wrote: | To: bug at octave dot org | Cc: weber at num dot uni-sb dot de | Subject: cross.m doesn't work when warn_resize_on_range_error = 1 | | Bug report for Octave 2.1.64 configured for i386-pc-linux-gnu | | Description: | ----------- | | Subject says it all, see below | | Repeat-By: | --------- | | octave:1> warn_resize_on_range_error = 1; a=[1;2;3]; | octave:2> cross(a,a) | error: resizing object with index = 1 out of bounds | error: assignment failed, or no method for `cell = range' | error: evaluating assignment expression near line 76, column 13 | error: evaluating for command near line 75, column 3 | error: called from `cross' in file `/usr/share/octave/2.1.64/m/linear-algebra/cross.m' Please try the following patch. Thanks, jwe liboctave/ChangeLog: 2005-01-18 John W. Eaton * idx-vector.cc (IDX_VEC_REP::freeze): Call warning handler, not error handler, to warn about resizing. scripts/ChangeLog: 2005-01-18 John W. Eaton * linear-algebra/cross.m: Allocate idx1 before use. Index: liboctave/idx-vector.cc =================================================================== RCS file: /usr/local/cvsroot/octave/liboctave/idx-vector.cc,v retrieving revision 1.59 diff -u -r1.59 idx-vector.cc --- liboctave/idx-vector.cc 9 Aug 2004 20:21:59 -0000 1.59 +++ liboctave/idx-vector.cc 18 Jan 2005 19:10:42 -0000 at @ -589,11 +589,11 @@ if (warn_resize && max_val >= z_len) { if (tag) - (*current_liboctave_error_handler) + (*current_liboctave_warning_handler) ("resizing object with %s index = %d out of bounds", tag, max_val+1); else - (*current_liboctave_error_handler) + (*current_liboctave_warning_handler) ("resizing object with index = %d out of bounds", max_val+1); } Index: scripts/linear-algebra/cross.m =================================================================== RCS file: /usr/local/cvsroot/octave/scripts/linear-algebra/cross.m,v retrieving revision 1.9 diff -u -r1.9 cross.m --- scripts/linear-algebra/cross.m 6 May 2004 20:36:29 -0000 1.9 +++ scripts/linear-algebra/cross.m 18 Jan 2005 20:00:45 -0000 at @ -71,7 +71,7 @@ nd = ndims (x); sz = size (x); - idx1 = cell (); + idx1 = cell (1, nd); for i = 1:nd idx1{i} = 1:sz(i); endfor ------------------------------------------------------------- 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 -------------------------------------------------------------