]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clarifications in commentary in various places. 15047/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Apr 2023 18:11:41 +0000 (12:11 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Apr 2023 18:11:41 +0000 (12:11 -0600)
include/deal.II/lac/affine_constraints.templates.h
include/deal.II/lac/sparse_matrix.h
include/deal.II/lac/sparse_matrix.templates.h

index f1d018c4900b02fbd67d50a7e5ef703d5b9d0169..8ddc7c6bf74c1daca03c3d99a2685656d12483e7 100644 (file)
@@ -3984,8 +3984,12 @@ AffineConstraints<number>::distribute_local_to_global(
                                                           val_ptr);
           const size_type n_values = col_ptr - cols.data();
           if (n_values > 0)
-            global_matrix.add(
-              row, n_values, cols.data(), vals.data(), false, true);
+            global_matrix.add(row,
+                              n_values,
+                              cols.data(),
+                              vals.data(),
+                              /* elide zero additions */ false,
+                              /* sorted by column index */ true);
         }
       else
         internal::AffineConstraints::resolve_matrix_row(
index 3277bf85365139cf446941714b42d4ee30fd338c..72b30d2e8c1520c74efc192f029418fc203e27da 100644 (file)
@@ -906,8 +906,8 @@ public:
       const bool                    elide_zero_values = true);
 
   /**
-   * Set several elements in the specified row of the matrix with column
-   * indices as given by <tt>col_indices</tt> to the respective value.
+   * Add the provided values to several elements in the specified row of the
+   * matrix with column indices as given by <tt>col_indices</tt>.
    *
    * The optional parameter <tt>elide_zero_values</tt> can be used to specify
    * whether zero values should be added anyway or these should be filtered
index dc9fb42d50a5e8493483c9a954b2cf8f674daffa..da52a6515b056ddb121816cdcc95b0d58264fa14 100644 (file)
@@ -574,7 +574,12 @@ SparseMatrix<number>::add(const size_type  row,
               ++post_diag;
             }
 
-          // add indices before diagonal
+          // Add indices before diagonal. Because the input array
+          // is sorted, and because the entries in this matrix row
+          // are sorted, we can just linearly walk the colnums array
+          // and the input array in parallel, stopping whenever the
+          // former matches the column index of the next index in
+          // the input array:
           size_type counter = 1;
           for (size_type i = 0; i < diag; ++i)
             {
@@ -589,7 +594,7 @@ SparseMatrix<number>::add(const size_type  row,
               val_ptr[counter] += values[i];
             }
 
-          // add indices after diagonal
+          // Then do the same to add indices after the diagonal:
           for (size_type i = post_diag; i < n_cols; ++i)
             {
               while (this_cols[counter] < col_indices[i] &&
@@ -609,6 +614,9 @@ SparseMatrix<number>::add(const size_type  row,
         }
       else
         {
+          // Use the same algorithm as above, but because the matrix is
+          // not square, we can now do without the split for diagonal/
+          // entries before the diagional/entries are the diagonal.
           size_type counter = 0;
           for (size_type i = 0; i < n_cols; ++i)
             {

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.