From: young
Changed: A few simple PETSc wrappers forhelper functions
+ MatrixBase::transpose
,
+ MatrixBase::is_symmetric
,
+ MatrixBase::is_hermitian
,
+ MatrixBase::is_hermitian
, and
+ MatrixBase::write_ascii
have been added.
+
+ (Toby D. Young 2008/04/30)
+
Removed: The FullMatrix::add_diag
function was removed. It
offered functionality of questionable use in the first place, and its
implementation was correct only for matrices of size $3 \times 3$, $4 \times 4$
diff --git a/deal.II/lac/include/lac/petsc_matrix_base.h b/deal.II/lac/include/lac/petsc_matrix_base.h
index 608e721d84..fe9b86d8e2 100644
--- a/deal.II/lac/include/lac/petsc_matrix_base.h
+++ b/deal.II/lac/include/lac/petsc_matrix_base.h
@@ -849,6 +849,33 @@ namespace PETScWrappers
*/
operator const Mat () const;
+ /**
+ * Make an in-place transpose of a
+ * matrix.
+ */
+ void transpose ();
+
+ /**
+ * Test whether a matrix is symmetric.
+ * Default tolerance is zero.
+ */
+ PetscTruth is_symmetric (const double tol = 0.0);
+
+ /**
+ * Test whether a matrix is Hermitian,
+ * i.e. it is the complex conjugate
+ * of its transpose.
+ */
+ PetscTruth is_hermitian ();
+
+ /*
+ * Abstract PETSc object that helps view
+ * in ASCII other PETSc objects. Currently
+ * this function simply writes non-zero
+ * elements of a matrix to the terminal.
+ */
+ void write_ascii ();
+
/**
* Exception
*/
diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc
index 48cca472d8..6c0f3a51c0 100644
--- a/deal.II/lac/source/petsc_matrix_base.cc
+++ b/deal.II/lac/source/petsc_matrix_base.cc
@@ -598,6 +598,48 @@ namespace PETScWrappers
{
return matrix;
}
+
+ void
+ MatrixBase::transpose ()
+ {
+ int ierr;
+ ierr = MatTranspose(matrix, PETSC_NULL);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
+
+ PetscTruth
+ MatrixBase::is_symmetric (const double tolerance)
+ {
+ PetscTruth truth;
+ // First flush PETSc caches
+ compress ();
+ MatIsSymmetric (matrix, tolerance, &truth);
+ return truth;
+ }
+
+ PetscTruth
+ MatrixBase::is_hermitian ()
+ {
+ PetscTruth truth;
+ // First flush PETSc caches
+ compress ();
+ MatIsHermitian (matrix, &truth);
+ return truth;
+ }
+
+ void
+ MatrixBase::write_ascii ()
+ {
+ // First flush PETSc caches
+ compress ();
+
+ // Write to screen
+ PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
+ PETSC_VIEWER_ASCII_DEFAULT);
+
+ MatView (matrix,PETSC_VIEWER_STDOUT_WORLD);
+ }
+
}
DEAL_II_NAMESPACE_CLOSE