]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Be less conservative when comparing sparsity patterns.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Dec 2010 03:39:58 +0000 (03:39 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Dec 2010 03:39:58 +0000 (03:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@22932 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/sparsity_pattern.h

index f5c5f5b19084338f7b18aa464971812752517db4..9f4b21f9fed99ad2cbde3bd23087f1746574c8df 100644 (file)
@@ -2086,16 +2086,26 @@ inline
 bool 
 SparsityPattern::operator == (const SparsityPattern& sp2)  const
 {
-  if (max_dim != sp2.max_dim || rows != sp2.rows || cols != sp2.cols ||
-      max_vec_len != sp2.max_vec_len || max_row_length != sp2.max_row_length ||
-      compressed != sp2.compressed || diagonal_optimized != sp2.diagonal_optimized)
+                                  // it isn't quite necessary to
+                                  // compare *all* member
+                                  // variables. by only comparing the
+                                  // essential ones, we can say that
+                                  // two sparsity patterns are equal
+                                  // even if one is compressed and
+                                  // the other is not (in which case
+                                  // some of the member variables are
+                                  // not yet set correctly)
+  if (rows != sp2.rows ||
+      cols != sp2.cols ||
+      compressed != sp2.compressed ||
+      diagonal_optimized != sp2.diagonal_optimized)
     return false;
   
-  for (unsigned int i = 0; i < max_dim+1; ++i)
+  for (unsigned int i = 0; i < rows+1; ++i)
     if (rowstart[i] != sp2.rowstart[i])
       return false;
   
-  for (unsigned int i = 0; i < max_vec_len; ++i)
+  for (unsigned int i = 0; i < rowstart[rows]; ++i)
     if (colnums[i] != sp2.colnums[i])
       return false;
       

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.