]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Check for symmetry
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Aug 2000 20:32:59 +0000 (20:32 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 Aug 2000 20:32:59 +0000 (20:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@3282 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/full_matrix.h
deal.II/lac/include/lac/full_matrix.templates.h

index dd9813f903ae1be8dcc05f5b21ebc0ef267e443e..9fef2dc80f26fe066bcddd15476a1fd52e3072f2 100644 (file)
@@ -355,7 +355,7 @@ class FullMatrix : public Subscriptor
                                      * Compute the quadratic matrix norm.
                                      * Return value is the root of the square
                                      * sum of all matrix entries. Also called
-                                     * Frobenius Norm.
+                                     * Frobenius norm.
                                      * 
                                      * This norm is compatible with the $l_2$
                                      * vector norm. But it is not a natural
@@ -363,6 +363,21 @@ class FullMatrix : public Subscriptor
                                      * therefore it is not called $l_2$-norm.
                                      */
     number norm2 () const;
+
+                                    /**
+                                     * Compute the relative norm of
+                                     * the skew-symmetric part. The
+                                     * return value is the Frobenius
+                                     * norm of the skew-symmetric
+                                     * part of the matrix divided by
+                                     * that of the matrix.
+                                     *
+                                     * Main purpose of this function
+                                     * is to check, if a matrix is
+                                     * symmetric within a certain
+                                     * accuracy, or not.
+                                     */
+    number relative_symmetry_norm2 () const;
     
                                     /**
                                      * A=Inverse(A). Inversion of
index d423afa1c3c58de26de9a6c3b3746c5dc7c55019..1843378d29e0516135c647fe32c80900b9c4d3c7 100644 (file)
@@ -1111,7 +1111,27 @@ FullMatrix<number>::norm2 () const
   number s = 0.;
   for (unsigned int i=0;i<dim_image*dim_range;++i)
     s += val[i]*val[i];
-  return s;
+  return sqrt(s);
+}
+
+
+template <typename number>
+number
+FullMatrix<number>::relative_symmetry_norm2 () const
+{
+  Assert (val != 0, ExcEmptyMatrix());
+  
+  number s = 0.;
+  number a = 0.;
+  for (unsigned int i=0;i<dim_image;++i)
+    for (unsigned int j=0;j<dim_range;++j)
+      {
+       a += ((*this)(i,j)-(*this)(j,i))*((*this)(i,j)-(*this)(j,i));
+       s += (*this)(i,j)*(*this)(i,j);
+      }
+  if (s!=0.)
+    return sqrt(a)/sqrt(s);
+  return 0;
 }
 
 

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.