]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Bound the number of elements per row by the total number of columns.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 May 2000 13:37:04 +0000 (13:37 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 May 2000 13:37:04 +0000 (13:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@2798 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/sparsity_pattern.cc

index f2684096ea960320cbab0fdaf48cee2a4812a85b..49ac236548636ded6badafc4e04fffc01be84731 100644 (file)
@@ -261,11 +261,18 @@ SparsityPattern::reinit (const unsigned int m,
                                   // this number is larger than
                                   // #max_vec_len#, then we will need
                                   // to reallocate memory
-  const unsigned int vec_len = accumulate (row_lengths.begin(),
-                                          row_lengths.end(), 0);
+                                  //
+                                  // note that the number of elements
+                                  // is bounded by the number of
+                                  // columns
+  unsigned int vec_len = 0;
+  for (unsigned int i=0; i<m; ++i)
+    vec_len += min(row_lengths[i], n);
+
   max_row_length = (row_lengths.size() == 0 ?
                    0 :
-                   *max_element(row_lengths.begin(), row_lengths.end()));
+                   min (*max_element(row_lengths.begin(), row_lengths.end()),
+                        n));
 
 
                                   // allocate memory for the rowstart

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.