changeset 6092:30beea6739da

[project @ 2006-10-25 23:45:16 by jwe]
author jwe
date Wed, 25 Oct 2006 23:45:16 +0000
parents 96a11041f52b
children 174cfaa0c4af
files liboctave/ChangeLog liboctave/Sparse.cc
diffstat 2 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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  <jwe@octave.org>
+
+	* Sparse.cc (assign): Clear lhs index after error.
+
+2006-10-24  David Bateman  <dbateman@free.fr>
+
+	* Sparse.cc (assign (Sparse<LT>&, const Sparse<RT>&)):
+	Fix previous patch so it works.
+
 2006-10-25  Michael Goffioul  <michael.goffioul@swing.be>
 
 	* Makefile.in (XTRA_CDEFS, XTRA_CXXDEFS): Substitute here.
--- 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<LT> 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<RT>(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<LT> 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<RT>(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);