From 42edc1800894e825c8c57be8e00461c91a2a9796 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 17 Jan 2000 14:37:24 +0000 Subject: [PATCH] Optimize memory allocation. git-svn-id: https://svn.dealii.org/trunk@2235 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/sparse_vanka.templates.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_vanka.templates.h b/deal.II/lac/include/lac/sparse_vanka.templates.h index d6f538c474..d5d40300e3 100644 --- a/deal.II/lac/include/lac/sparse_vanka.templates.h +++ b/deal.II/lac/include/lac/sparse_vanka.templates.h @@ -51,10 +51,17 @@ SparseVanka::operator ()(Vector &dst, // will be used quite often const SparseMatrixStruct &structure = matrix->get_sparsity_pattern(); - // space to be used for local systems - FullMatrix local_matrix; - Vector b; - Vector x; + + // space to be used for local + // systems. allocate as much memory + // as is the maximum. this + // eliminates the need to + // re-allocate memory inside the + // loop. + FullMatrix local_matrix (structure.max_row_length(), + structure.max_row_length()); + Vector b (structure.max_row_length()); + Vector x (structure.max_row_length()); // traverse all rows of the matrix for (unsigned int row=0; row< matrix->m() ; ++row) -- 2.39.5