From e4b5322c8fb33e007001b3d151d5ac0f7f0c8002 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 1 Nov 2018 08:22:40 -0600 Subject: [PATCH] Fix (Dynamic)?SparsityPattern::begin() for empty sparsity patterns. --- include/deal.II/lac/dynamic_sparsity_pattern.h | 5 ++++- include/deal.II/lac/sparsity_pattern.h | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/deal.II/lac/dynamic_sparsity_pattern.h b/include/deal.II/lac/dynamic_sparsity_pattern.h index 4e21e2a9e4..d05dac7efa 100644 --- a/include/deal.II/lac/dynamic_sparsity_pattern.h +++ b/include/deal.II/lac/dynamic_sparsity_pattern.h @@ -1037,7 +1037,10 @@ DynamicSparsityPattern::column_number(const size_type row, inline DynamicSparsityPattern::iterator DynamicSparsityPattern::begin() const { - return begin(0); + if (n_rows() > 0) + return begin(0); + else + return end(); } diff --git a/include/deal.II/lac/sparsity_pattern.h b/include/deal.II/lac/sparsity_pattern.h index 3caaa9d4a7..12c729bc7c 100644 --- a/include/deal.II/lac/sparsity_pattern.h +++ b/include/deal.II/lac/sparsity_pattern.h @@ -1254,7 +1254,10 @@ namespace SparsityPatternIterators inline SparsityPattern::iterator SparsityPattern::begin() const { - return iterator(this, rowstart[0]); + if (n_rows() > 0) + return iterator(this, rowstart[0]); + else + return end(); } @@ -1262,7 +1265,10 @@ SparsityPattern::begin() const inline SparsityPattern::iterator SparsityPattern::end() const { - return iterator(this, rowstart[rows]); + if (n_rows() > 0) + return iterator(this, rowstart[rows]); + else + return iterator(nullptr, 0); } -- 2.39.5