]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Helper Functions
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Apr 2008 16:18:03 +0000 (16:18 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Apr 2008 16:18:03 +0000 (16:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@16014 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/lac/include/lac/petsc_matrix_base.h
deal.II/lac/source/petsc_matrix_base.cc

index 3b6a97d46b1560f5b4235b0eeeff6fecb6ae6b25..dc6c0d4f2ebb4cdd5c9a02973c1805cfc2e39c2f 100644 (file)
@@ -30,6 +30,16 @@ inconvenience this causes.
 </p>
 
 <ol>
+  <li> <p>Changed: A few simple PETSc wrappers forhelper functions 
+  <code>MatrixBase::transpose</code>, 
+  <code>MatrixBase::is_symmetric</code>, 
+  <code>MatrixBase::is_hermitian</code>, 
+  <code>MatrixBase::is_hermitian</code>, and
+  <code>MatrixBase::write_ascii</code> have been added.
+  <br>
+  (Toby D. Young 2008/04/30)
+  </p>
+
   <li> <p>Removed: The <code>FullMatrix::add_diag</code> 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$
index 608e721d84e4fbc9acc3702d8df9b87ed54430a8..fe9b86d8e2c1f75a71391f66f7fb00cfffffee1e 100644 (file)
@@ -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
                                         */
index 48cca472d8d6591a76287179de78ce330979c487..6c0f3a51c056ae6d93cec3ea2ae20ef42128807b 100644 (file)
@@ -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

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.