]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Optimize memory allocation.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Jan 2000 14:37:24 +0000 (14:37 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Jan 2000 14:37:24 +0000 (14:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@2235 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_vanka.templates.h

index d6f538c4740be349a0143c3c29dd997dd4fada62..d5d40300e3de0e79221de35a2f56b06915c53e8a 100644 (file)
@@ -51,10 +51,17 @@ SparseVanka<number>::operator ()(Vector<number2>       &dst,
                                   // will be used quite often
   const SparseMatrixStruct &structure
     = matrix->get_sparsity_pattern();
-                                  // space to be used for local systems
-  FullMatrix<float> local_matrix;
-  Vector<float> b;
-  Vector<float> 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<float> local_matrix (structure.max_row_length(),
+                                 structure.max_row_length());
+  Vector<float> b (structure.max_row_length());
+  Vector<float> x (structure.max_row_length());
   
                                   // traverse all rows of the matrix
   for (unsigned int row=0; row< matrix->m() ; ++row)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.