]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Actually check for symmetry of matrices.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Jul 2004 13:57:24 +0000 (13:57 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Jul 2004 13:57:24 +0000 (13:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@9505 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_direct.h
deal.II/lac/source/sparse_direct.cc

index 3cbf8170dfe7f1cc2c6e0835dd55ea769c2aa359..dcd119d01d54762b34984778adf1a60b0a0f91b9 100644 (file)
@@ -366,6 +366,10 @@ class SparseDirectMA27 : public Subscriptor
                     << "Error while reading in detached mode. Return value "
                     << "for 'read' was " << arg1
                     << ", errno has value " << arg2);
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcMatrixNotSymmetric);
     
   private:
                                      /**
@@ -813,6 +817,10 @@ class SparseDirectMA47 : public Subscriptor
                                      * Exception
                                      */
     DeclException0 (ExcDifferentMatrices);
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcMatrixNotSymmetric);
     
   private:
                                      /**
index d19e9a85deab0ce673b4775a6fdc154196c6c1d6..167a5d2c493ff726f6d329cbf85677fbdb47506d 100644 (file)
@@ -950,8 +950,23 @@ SparseDirectMA27::fill_A (const SparseMatrix<number> &matrix)
          
          A[global_index] = matrix(row,*col);
          ++global_index;
-       };
-//TODO[WB]: make sure that the matrix really _is_ symmetric. would have saved me a lot of work previously. also, discard zeros, just as in MA47
+
+                                           // make sure that the symmetric
+                                           // entry exists and has the same
+                                           // value, unless this one is zero
+          Assert ((matrix(row,*col) == 0)
+                  ||
+                  (matrix(row,*col) == matrix(*col,row)),
+                  ExcMatrixNotSymmetric());
+       }
+      else
+                                         // lower left part. just check
+                                         // symmetry
+        Assert ((matrix(row,*col) == 0)
+                ||
+                (matrix(row,*col) == matrix(*col,row)),
+                ExcMatrixNotSymmetric());
+        
   Assert (global_index == n_nonzero_elements, ExcInternalError());  
 }
 
@@ -1450,8 +1465,22 @@ SparseDirectMA47::fill_A (const SparseMatrix<double> &matrix)
          
          A[global_index] = matrix(row,*col);
          ++global_index;
-       };
-//TODO[WB]: make sure that the matrix really _is_ symmetric. would have saved me a lot of work previously
+
+                                           // make sure that the symmetric
+                                           // entry exists and has the same
+                                           // value, unless this one is zero
+          Assert ((matrix(row,*col) == 0)
+                  ||
+                  (matrix(row,*col) == matrix(*col,row)),
+                  ExcMatrixNotSymmetric());
+       }
+      else
+                                         // lower left part. just check
+                                         // symmetry
+        Assert ((matrix(row,*col) == 0)
+                ||
+                (matrix(row,*col) == matrix(*col,row)),
+                ExcMatrixNotSymmetric());
   
   Assert (global_index == n_nonzero_elements, ExcInternalError());  
 }

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.