# HG changeset patch # User jwe # Date 1161819916 0 # Node ID 30beea6739da852238249746294e2ce6a0c01fff # Parent 96a11041f52b1fb3e1e495061dff4770b8b7b5e3 [project @ 2006-10-25 23:45:16 by jwe] diff -r 96a11041f52b -r 30beea6739da liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Oct 25 21:25:04 2006 +0000 +++ b/liboctave/ChangeLog Wed Oct 25 23:45:16 2006 +0000 @@ -1,3 +1,12 @@ +2006-10-25 John W. Eaton + + * Sparse.cc (assign): Clear lhs index after error. + +2006-10-24 David Bateman + + * Sparse.cc (assign (Sparse&, const Sparse&)): + Fix previous patch so it works. + 2006-10-25 Michael Goffioul * Makefile.in (XTRA_CDEFS, XTRA_CXXDEFS): Substitute here. diff -r 96a11041f52b -r 30beea6739da liboctave/Sparse.cc --- a/liboctave/Sparse.cc Wed Oct 25 21:25:04 2006 +0000 +++ b/liboctave/Sparse.cc Wed Oct 25 23:45:16 2006 +0000 @@ -2387,6 +2387,8 @@ { (*current_liboctave_error_handler) ("A(I, J) = X: can only have 1 or 2 indexes for sparse matrices"); + + lhs.clear_index (); return 0; } @@ -2471,11 +2473,6 @@ Sparse stmp (new_nr, new_nc, new_nzmx); - // Started with an empty matrix. Now that we know - // the assignment will succeed, resize lhs - if (lhs_nr <= 0 || lhs_nc <= 0) - lhs = Sparse(n, m); - octave_idx_type jji = 0; octave_idx_type jj = idx_j.elem (jji); octave_idx_type kk = 0; @@ -2487,8 +2484,9 @@ octave_idx_type iii = 0; octave_idx_type ii = idx_i.elem (iii); octave_idx_type ppp = 0; - octave_idx_type ppi = lhs.cidx(j+1) - - lhs.cidx(j); + octave_idx_type ppi = (j >= lhs_nc ? 0 : + lhs.cidx(j+1) - + lhs.cidx(j)); octave_idx_type pp = (ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr); @@ -2628,11 +2626,6 @@ Sparse stmp (new_nr, new_nc, new_nzmx); - // Started with an empty matrix. Now that we know - // the assignment will succeed, resize lhs - if (lhs_nr <= 0 || lhs_nc <= 0) - lhs = Sparse(n, m); - octave_idx_type jji = 0; octave_idx_type jj = idx_j.elem (jji); octave_idx_type kk = 0; @@ -2644,8 +2637,9 @@ octave_idx_type iii = 0; octave_idx_type ii = idx_i.elem (iii); octave_idx_type ppp = 0; - octave_idx_type ppi = lhs.cidx(j+1) - - lhs.cidx(j); + octave_idx_type ppi = (j >= lhs_nc ? 0 : + lhs.cidx(j+1) - + lhs.cidx(j)); octave_idx_type pp = (ppp < ppi ? lhs.ridx(lhs.cidx(j)+ppp) : new_nr);