]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Specialize precondition_Jacobi for the case that the factor is equal
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Nov 2003 22:17:58 +0000 (22:17 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Nov 2003 22:17:58 +0000 (22:17 +0000)
to 1.0.

git-svn-id: https://svn.dealii.org/trunk@8180 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 256bfa04201932d58b23fc3c9a20a2082568678b..8dc4ed8f59d3cdb5d79002a25d2bfae1530d34f0 100644 (file)
@@ -844,13 +844,24 @@ SparseMatrix<number>::precondition_Jacobi (Vector<somenumber>       &dst,
   somenumber              *dst_ptr = dst.begin();
   const somenumber        *src_ptr = src.begin();
   const unsigned int *rowstart_ptr = &cols->rowstart[0];
-  
-  for (unsigned int i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
-                                    // note that for square matrices,
-                                    // the diagonal entry is the first
-                                    // in each row, i.e. at index
-                                    // rowstart[i]
-    *dst_ptr = om * *src_ptr / val[*rowstart_ptr];
+
+                                  // optimize the following loop for
+                                  // the case that the relaxation
+                                  // factor is one. In that case, we
+                                  // can save one FP multiplication
+                                  // per row
+                                  //
+                                  // note that for square matrices,
+                                  // the diagonal entry is the first
+                                  // in each row, i.e. at index
+                                  // rowstart[i]. and we do have a
+                                  // square matrix by above assertion
+  if (om != 1.)
+    for (unsigned int i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
+      *dst_ptr = om * *src_ptr / val[*rowstart_ptr];
+  else
+    for (unsigned int i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
+      *dst_ptr = *src_ptr / val[*rowstart_ptr];
 }
 
 

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.