From b15b36a7bd2b79ae06cd1c2fa8bb3a81b9b0fcae Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 30 Mar 2004 14:33:04 +0000 Subject: [PATCH] Make sure begin() doesn't return an iterator into an empty row. git-svn-id: https://svn.dealii.org/trunk@8915 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_matrix.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 329fbc98ed..8e85d86884 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -2020,7 +2020,16 @@ inline typename SparseMatrix::const_iterator SparseMatrix::begin () const { - return const_iterator(this, 0, 0); + // 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); + + // alright, this matrix is completely + // empty. that's strange but ok. simply + // return the end() iterator + return end(); } @@ -2038,7 +2047,16 @@ inline typename SparseMatrix::iterator SparseMatrix::begin () { - return iterator(this, 0, 0); + // 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); + + // alright, this matrix is completely + // empty. that's strange but ok. simply + // return the end() iterator + return end(); } -- 2.39.5