From 1df77bef298252849a7ff9160f1059322ab1bc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCthing?= <muething@dune-project.org> Date: Wed, 27 Nov 2013 12:13:28 +0100 Subject: [PATCH] [Bugfix][BCRSMatrix] Use number of rows from source matrix as iteration bound in copy constructor After the recent changes to BCRSMatrix, row and column sizes are now only set by allocate() because several places assume a correlation between the set number and rows and the allocation state. Thus the copy constructor and the assignment operator don't directly copy those values over, but initialize them to 0. The correct values are then set by allocate. The row-wise build mode is a special case that requires iterating over the source matrix rows before allocating memory. Unfortunately, the copy constructor tried to use the (0-initialized) row count of itself as iteration bound instead of the source matrix's one. Fixed by doing the same thing as the assignment operator: Just use the number from the source matrix. Fixes FS #1394. --- dune/istl/bcrsmatrix.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dune/istl/bcrsmatrix.hh b/dune/istl/bcrsmatrix.hh index 5304f18d..baff3c9e 100644 --- a/dune/istl/bcrsmatrix.hh +++ b/dune/istl/bcrsmatrix.hh @@ -768,7 +768,7 @@ namespace Dune { if (_nnz<=0) { _nnz = 0; - for (size_type i=0; i<n; i++) + for (size_type i=0; i<Mat.n; i++) _nnz += Mat.r[i].getsize(); } -- GitLab