From b1b9c7dc1de682f10a4af0a3135521cb751c8a5b Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 30 Mar 2004 14:40:41 +0000 Subject: [PATCH] Fix a typo. Fix a bug where we did not skip empty lines as should have been the case. git-svn-id: https://svn.dealii.org/trunk@8917 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.h | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 8e85d86884..85aedb4877 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -1925,14 +1925,25 @@ namespace internals Iterator::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::begin () const { // search for the first line with a nonzero // number of entries - for (unsigned int r=0; rrow_length(r) > 0) return const_iterator(this, r, 0); @@ -2049,7 +2070,7 @@ SparseMatrix::begin () { // search for the first line with a nonzero // number of entries - for (unsigned int r=0; rrow_length(r) > 0) return iterator(this, r, 0); -- 2.39.5