From: Wolfgang Bangerth Date: Mon, 12 Jul 2004 13:57:24 +0000 (+0000) Subject: Actually check for symmetry of matrices. X-Git-Tag: v8.0.0~14960 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d13258b32b50a893e33de5722ccfd57bc07928d4;p=dealii.git Actually check for symmetry of matrices. git-svn-id: https://svn.dealii.org/trunk@9505 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/sparse_direct.h b/deal.II/lac/include/lac/sparse_direct.h index 3cbf8170df..dcd119d01d 100644 --- a/deal.II/lac/include/lac/sparse_direct.h +++ b/deal.II/lac/include/lac/sparse_direct.h @@ -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: /** diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index d19e9a85de..167a5d2c49 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -950,8 +950,23 @@ SparseDirectMA27::fill_A (const SparseMatrix &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 &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()); }