]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix comparison of objects.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Jan 2022 07:19:23 +0000 (00:19 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Jan 2022 07:19:23 +0000 (00:19 -0700)
include/deal.II/lac/sparsity_pattern.h

index fa3d9b65df70419891053da0b8d8e51e7f44e405..011acc1acbabc5b56326f6f184db70487c06eb47 100644 (file)
@@ -1644,13 +1644,15 @@ SparsityPatternBase::operator==(const SparsityPatternBase &sp2) const
   if (rows != sp2.rows || cols != sp2.cols || compressed != sp2.compressed)
     return false;
 
-  for (size_type i = 0; i < rows + 1; ++i)
-    if (rowstart[i] != sp2.rowstart[i])
-      return false;
-
-  for (size_type i = 0; i < rowstart[rows]; ++i)
-    if (colnums[i] != sp2.colnums[i])
-      return false;
+  if (rows > 0)
+    for (size_type i = 0; i < rows + 1; ++i)
+      if (rowstart[i] != sp2.rowstart[i])
+        return false;
+
+  if (rows > 0)
+    for (size_type i = 0; i < rowstart[rows]; ++i)
+      if (colnums[i] != sp2.colnums[i])
+        return false;
 
   return true;
 }

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.