From bug-octave-request at bevo dot che dot wisc dot edu Tue Jan 28 21:04:17 2003 Subject: Re: Floating point exception in cell array assignment From: Quentin Spencer To: "John W. Eaton" CC: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 28 Jan 2003 19:59:48 -0700 The patch fixed the problem. Thanks. Quentin Spencer John W. Eaton wrote: >On 23-Jan-2003, Quentin Spencer wrote: > >| Bug report for Octave 2.1.43 configured for i686-pc-linux-gnu >| >| Description: >| ----------- >| >| Assignments of the form XXXX{i}(j,k)=val, where i,j and k are integer >| index values and val is any numerical value, result in a floating >| point exception and core dump whenever XXXX{i} does not already exist. >| This assignment works correctly when XXXX{i} exists (see example >| below). >| >| Repeat-By: >| --------- >| >| octave 1> a{1}=[0,1]; >| octave 2> a{1}(1,1)=1; >| octave 3> clear >| octave 4> a{1}(1,1)=1; >| panic: Floating point exception -- stopping myself... >| attempting to save variables to `octave-core'... >| save to `octave-core' complete >| Floating point exception > >Please try the following patch. > >Thanks, > >jwe > > >2003-01-23 John W. Eaton > > * Array2-idx.h (Array2::index): Fix off-by-one error. > > >Index: liboctave/Array2-idx.h >=================================================================== >RCS file: /usr/local/cvsroot/octave/liboctave/Array2-idx.h,v >retrieving revision 1.38 >diff -u -r1.38 Array2-idx.h >--- liboctave/Array2-idx.h 3 Jan 2003 18:55:11 -0000 1.38 >+++ liboctave/Array2-idx.h 24 Jan 2003 04:18:41 -0000 > at @ -128,15 +128,13 @@ > > retval.resize (result_nr, result_nc); > >- >- > int k = 0; > for (int j = 0; j < result_nc; j++) > { > for (int i = 0; i < result_nr; i++) > { > int ii = idx_arg.elem (k++); >- if (ii > orig_len) >+ if (ii >= orig_len) > retval.elem (i, j) = resize_fill_value; > else > { > at @ -189,7 +187,7 @@ > for (int i = 0; i < n; i++) > { > int ii = idx_i.elem (i); >- if (ii > nr || jj > nc) >+ if (ii >= nr || jj >= nc) > retval.elem (i, j) = resize_fill_value; > else > retval.elem (i, j) = elem (ii, jj); > > > ------------------------------------------------------------- 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 -------------------------------------------------------------