]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix zero comparison
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 15 Sep 2021 16:56:05 +0000 (12:56 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Wed, 15 Sep 2021 16:56:05 +0000 (12:56 -0400)
source/numerics/matrix_tools.cc

index 8a7d3b60fe4ecfec2b5f924c5aa2879d0032a0bf..4aded6ad240a6d538c964d5d0a589b5527d9f247 100644 (file)
@@ -282,7 +282,7 @@ namespace MatrixTools
       {
         for (unsigned int i = 0; i < matrix.block(diag_block, diag_block).n();
              ++i)
-          if (matrix.block(diag_block, diag_block).diag_element(i) != 0)
+          if (matrix.block(diag_block, diag_block).diag_element(i) != number{})
             {
               first_nonzero_diagonal_entry =
                 matrix.block(diag_block, diag_block).diag_element(i);
@@ -291,12 +291,12 @@ namespace MatrixTools
         // check whether we have found
         // something in the present
         // block
-        if (first_nonzero_diagonal_entry != 0)
+        if (first_nonzero_diagonal_entry != number{})
           break;
       }
     // nothing found on all diagonal
     // blocks? if so, use 1.0 instead
-    if (first_nonzero_diagonal_entry == 0)
+    if (first_nonzero_diagonal_entry == number{})
       first_nonzero_diagonal_entry = 1;
 
 
@@ -361,7 +361,7 @@ namespace MatrixTools
         // the gauss step more efficient
         number new_rhs;
         if (matrix.block(block_index.first, block_index.first)
-              .diag_element(block_index.second) != 0.0)
+              .diag_element(block_index.second) != number{})
           new_rhs =
             dof->second * matrix.block(block_index.first, block_index.first)
                             .diag_element(block_index.second);
@@ -563,15 +563,15 @@ namespace MatrixTools
             // everything remains positive, or
             // by the average diagonal value if
             // zero
-            if (local_matrix(i, i) == 0.)
+            if (local_matrix(i, i) == number{})
               {
                 // if average diagonal hasn't
                 // yet been computed, do so now
-                if (average_diagonal == 0.)
+                if (average_diagonal == number{})
                   {
                     unsigned int nonzero_diagonals = 0;
                     for (unsigned int k = 0; k < n_local_dofs; ++k)
-                      if (local_matrix(k, k) != 0.)
+                      if (local_matrix(k, k) != number{})
                         {
                           average_diagonal += std::fabs(local_matrix(k, k));
                           ++nonzero_diagonals;
@@ -585,7 +585,7 @@ namespace MatrixTools
                 // only if all diagonal entries
                 // are zero, then resort to the
                 // last measure: choose one
-                if (average_diagonal == 0.)
+                if (average_diagonal == number{})
                   average_diagonal = 1.;
 
                 local_matrix(i, i) = average_diagonal;

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.