]> https://gitweb.dealii.org/ - dealii.git/commitdiff
In DynamicSparsityPattern iterators, also store a pointer to the end of the line... 861/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 22 Apr 2015 19:01:01 +0000 (14:01 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 22 Apr 2015 19:01:01 +0000 (14:01 -0500)
include/deal.II/lac/dynamic_sparsity_pattern.h

index a7b76e846c887ba974e8e9908843ffc6dac486cc..21400616d0298dc06ca2402096060bb7decfc597 100644 (file)
@@ -124,6 +124,15 @@ namespace DynamicSparsityPatternIterators
      */
     std::vector<size_type>::const_iterator current_entry;
 
+    /**
+     * A pointer to the end of the current row. We store this
+     * to make comparison against the end of line iterator
+     * cheaper as it otherwise needs to do the IndexSet translation
+     * from row index to the index within the 'lines' array
+     * of DynamicSparsityPattern.
+     */
+    std::vector<size_type>::const_iterator end_of_row;
+
     /**
      * Move the accessor to the next nonzero entry in the matrix.
      */
@@ -658,7 +667,12 @@ namespace DynamicSparsityPatternIterators
                    :
                    sparsity_pattern->lines[sparsity_pattern->rowset.index_within_set(current_row)].entries.begin())
                   +
-                  index_within_row)
+                  index_within_row),
+    end_of_row((sparsity_pattern->rowset.size()==0)
+               ?
+               sparsity_pattern->lines[current_row].entries.end()
+               :
+               sparsity_pattern->lines[sparsity_pattern->rowset.index_within_set(current_row)].entries.end())
   {
     Assert (current_row < sparsity_pattern->n_rows(),
             ExcIndexRange (row, 0, sparsity_pattern->n_rows()));
@@ -690,7 +704,8 @@ namespace DynamicSparsityPatternIterators
     :
     sparsity_pattern(sparsity_pattern),
     current_row(numbers::invalid_unsigned_int),
-    current_entry()
+    current_entry(),
+    end_of_row()
   {}
 
 
@@ -778,12 +793,7 @@ namespace DynamicSparsityPatternIterators
     // the sparsity pattern. consequently, rather than trying to
     // duplicate code here, just call the begin() function of the
     // sparsity pattern itself
-    if (current_entry ==
-        ((sparsity_pattern->rowset.size()==0)
-         ?
-         sparsity_pattern->lines[current_row].entries.end()
-         :
-         sparsity_pattern->lines[sparsity_pattern->rowset.index_within_set(current_row)].entries.end()))
+    if (current_entry == end_of_row)
       {
         if (current_row+1 < sparsity_pattern->n_rows())
           *this = *sparsity_pattern->begin(current_row+1);

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.