From 230d2f7d9dbad82dda9778f50c2866ce7729a768 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 7 Dec 2010 03:39:58 +0000 Subject: [PATCH] Be less conservative when comparing sparsity patterns. git-svn-id: https://svn.dealii.org/trunk@22932 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/lac/sparsity_pattern.h | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/deal.II/include/deal.II/lac/sparsity_pattern.h b/deal.II/include/deal.II/lac/sparsity_pattern.h index f5c5f5b190..9f4b21f9fe 100644 --- a/deal.II/include/deal.II/lac/sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/sparsity_pattern.h @@ -2086,16 +2086,26 @@ inline bool SparsityPattern::operator == (const SparsityPattern& sp2) const { - if (max_dim != sp2.max_dim || rows != sp2.rows || cols != sp2.cols || - max_vec_len != sp2.max_vec_len || max_row_length != sp2.max_row_length || - compressed != sp2.compressed || diagonal_optimized != sp2.diagonal_optimized) + // it isn't quite necessary to + // compare *all* member + // variables. by only comparing the + // essential ones, we can say that + // two sparsity patterns are equal + // even if one is compressed and + // the other is not (in which case + // some of the member variables are + // not yet set correctly) + if (rows != sp2.rows || + cols != sp2.cols || + compressed != sp2.compressed || + diagonal_optimized != sp2.diagonal_optimized) return false; - for (unsigned int i = 0; i < max_dim+1; ++i) + for (unsigned int i = 0; i < rows+1; ++i) if (rowstart[i] != sp2.rowstart[i]) return false; - for (unsigned int i = 0; i < max_vec_len; ++i) + for (unsigned int i = 0; i < rowstart[rows]; ++i) if (colnums[i] != sp2.colnums[i]) return false; -- 2.39.5