From 0fec52519d115a35694fe62d72587a93c20dabb1 Mon Sep 17 00:00:00 2001 From: Christoph Goering Date: Fri, 22 Dec 2017 23:01:27 +0100 Subject: [PATCH] improved readability inside SparseMatrix::mmult(..) with DynamicSparsityPattern::compute_mmult_pattern(..) --- include/deal.II/lac/sparse_matrix.templates.h | 33 ++----------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/include/deal.II/lac/sparse_matrix.templates.h b/include/deal.II/lac/sparse_matrix.templates.h index f3969d8d7d..53cfc44520 100644 --- a/include/deal.II/lac/sparse_matrix.templates.h +++ b/include/deal.II/lac/sparse_matrix.templates.h @@ -1008,37 +1008,10 @@ SparseMatrix::mmult (SparseMatrix &C, C.clear(); sp_C.reinit (0,0,0); - // create a sparsity pattern for the matrix. we will go through all the - // rows in the matrix A, and for each column in a row we add the whole - // row of matrix B with that row number. This means that we will insert - // a lot of entries to each row, which is best handled by the - // DynamicSparsityPattern class. + // create a sparsity pattern for the matrix C. { - DynamicSparsityPattern dsp (m(), B.n()); - for (size_type i = 0; i < dsp.n_rows(); ++i) - { - const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]]; - const size_type *const end_rows = - &sp_A.colnums[sp_A.rowstart[i+1]]; - for (; rows != end_rows; ++rows) - { - const size_type col = *rows; - size_type *new_cols = const_cast - (&sp_B.colnums[sp_B.rowstart[col]]); - size_type *end_new_cols = const_cast - (&sp_B.colnums[sp_B.rowstart[col+1]]); - - // if B has a diagonal, need to add that manually. this way, - // we maintain sortedness. - if (sp_B.n_rows() == sp_B.n_cols()) - { - ++new_cols; - dsp.add(i, col); - } - - dsp.add_entries (i, new_cols, end_new_cols, true); - } - } + DynamicSparsityPattern dsp ; + dsp.compute_mmult_pattern(sp_A,sp_B); sp_C.copy_from (dsp); } -- 2.39.5