]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a typo. Fix a bug where we did not skip empty lines as should have been
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Mar 2004 14:40:41 +0000 (14:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 30 Mar 2004 14:40:41 +0000 (14:40 +0000)
the case.

git-svn-id: https://svn.dealii.org/trunk@8917 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_matrix.h

index 8e85d868844bca07684468b1a352c08b9f72dd07..85aedb487708b4e58b39853e5dacadb9e8989a6c 100644 (file)
@@ -1925,14 +1925,25 @@ namespace internals
     Iterator<number,Constness>::operator++ ()
     {
       Assert (accessor.a_row < accessor.matrix->m(), ExcIteratorPastEnd());
-  
+
+                                       // move to next element
       ++accessor.a_index;
-      if (accessor.a_index >=
-          accessor.matrix->get_sparsity_pattern().row_length(accessor.a_row))
+
+                                       // if at end of line: cycle until we
+                                       // find a row with a nonzero number of
+                                       // entries
+      while (accessor.a_index >=
+             accessor.matrix->get_sparsity_pattern().row_length(accessor.a_row))
         {
           accessor.a_index = 0;
-          accessor.a_row++;
+          ++accessor.a_row;
+
+                                           // if we happened to find the end
+                                           // of the matrix, then stop here
+          if (accessor.a_row == accessor.matrix->m())
+            return *this;
         }
+      
       return *this;
     }
 
@@ -1947,12 +1958,22 @@ namespace internals
       const Iterator iter=*this;
   
       ++accessor.a_index;
-      if (accessor.a_index >=
-          accessor.matrix->get_sparsity_pattern().row_length(accessor.a_row))
+
+                                       // if at end of line: cycle until we
+                                       // find a row with a nonzero number of
+                                       // entries
+      while (accessor.a_index >=
+             accessor.matrix->get_sparsity_pattern().row_length(accessor.a_row))
         {
           accessor.a_index = 0;
-          accessor.a_row++;
+          ++accessor.a_row;
+
+                                           // if we happened to find the end
+                                           // of the matrix, then stop here
+          if (accessor.a_row == accessor.matrix->m())
+            return iter;
         }
+
       return iter;
     }
 
@@ -2022,7 +2043,7 @@ SparseMatrix<number>::begin () const
 {
                                    // search for the first line with a nonzero
                                    // number of entries
-  for (unsigned int r=0; r<n(); ++r)
+  for (unsigned int r=0; r<m(); ++r)
     if (cols->row_length(r) > 0)
       return const_iterator(this, r, 0);
 
@@ -2049,7 +2070,7 @@ SparseMatrix<number>::begin ()
 {
                                    // search for the first line with a nonzero
                                    // number of entries
-  for (unsigned int r=0; r<n(); ++r)
+  for (unsigned int r=0; r<m(); ++r)
     if (cols->row_length(r) > 0)
       return iterator(this, r, 0);
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.