]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add some statistics
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Apr 2012 20:24:22 +0000 (20:24 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Apr 2012 20:24:22 +0000 (20:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@25378 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/precondition_block.h
deal.II/include/deal.II/lac/precondition_block_base.h
deal.II/include/deal.II/lac/relaxation_block.h

index f4816b6c3d1ac1b5a4bc654e0a8681e7a28cbfde..082228dfd4708e5e86301d9eb5d686c3aa8f9b33 100644 (file)
@@ -613,6 +613,7 @@ class PreconditionBlockJacobi : public virtual Subscriptor,
     using PreconditionBlockBase<inverse_type>::inverse;
     using PreconditionBlockBase<inverse_type>::inverse_householder;
     using PreconditionBlockBase<inverse_type>::inverse_svd;
+    using PreconditionBlockBase<inverse_type>::log_statistics;
                                      /**
                                       * @deprecated Use size() instead
                                       */
@@ -784,6 +785,7 @@ class PreconditionBlockSOR : public virtual Subscriptor,
     using PreconditionBlock<MATRIX, inverse_type>::set_same_diagonal;
     using PreconditionBlock<MATRIX, inverse_type>::invert_diagblocks;
     using PreconditionBlock<MATRIX, inverse_type>::set_permutation;
+    using PreconditionBlockBase<inverse_type>::log_statistics;
 
                                      /**
                                       * Execute block SOR
@@ -973,6 +975,7 @@ class PreconditionBlockSSOR : public virtual Subscriptor,
     using PreconditionBlockBase<inverse_type>::inverse;
     using PreconditionBlockBase<inverse_type>::inverse_householder;
     using PreconditionBlockBase<inverse_type>::inverse_svd;
+    using PreconditionBlockBase<inverse_type>::log_statistics;
     using PreconditionBlockSOR<MATRIX,inverse_type>::set_permutation;
     using PreconditionBlockSOR<MATRIX, inverse_type>::empty;
     using PreconditionBlockSOR<MATRIX, inverse_type>::el;
index 3b0633731de09257b2e277acbcddd417041c727d..097256c164e08ca6b82c70c55dc125ea0aa4c9e3 100644 (file)
@@ -228,11 +228,22 @@ class PreconditionBlockBase
                                       */
     const FullMatrix<number>& diagonal (unsigned int i) const;
 
-                                     /**
-                                      * Determine an estimate for the
-                                      * memory consumption (in bytes)
-                                      * of this object.
-                                      */
+                                    /**
+                                     * Print some statistics about
+                                     * the inverses to #deallog. Output depends
+                                     * on #Inversion. It is richest
+                                     * for svd, where we obtain
+                                     * statistics on extremal
+                                     * singular values and condition
+                                     * numbers.
+                                     */
+    void log_statistics () const;
+    
+                                    /**
+                                     * Determine an estimate for the
+                                     * memory consumption (in bytes)
+                                     * of this object.
+                                     */
     std::size_t memory_consumption () const;
 
                                      /**
@@ -660,6 +671,53 @@ PreconditionBlockBase<number>::inverses_ready() const
 }
 
 
+template <typename number>
+inline void
+PreconditionBlockBase<number>::log_statistics () const
+{
+  deallog << "PreconditionBlockBase: " << size() << " blocks; ";
+
+  if (inversion == svd)
+    {
+      unsigned int kermin = 100000000, kermax = 0;
+      double sigmin = 1.e300, sigmax= -1.e300;
+      double kappamin = 1.e300, kappamax= -1.e300;
+      
+      for (unsigned int b=0;b<size();++b)
+       {
+         const LAPACKFullMatrix<number>& matrix = inverse_svd(b);
+         unsigned int k=1;
+         while (k <= matrix.n_cols() && matrix.singular_value(matrix.n_cols()-k) == 0)
+           ++k;
+         const double s0 = matrix.singular_value(0);
+         const double sm = matrix.singular_value(matrix.n_cols()-k);
+         const double co = sm/s0;
+         
+         if (kermin > k) kermin = k-1;
+         if (kermax < k) kermax = k-1;
+         if (s0 < sigmin) sigmin = s0;
+         if (sm > sigmax) sigmax = sm;
+         if (co < kappamin) kappamin = co;
+         if (co > kappamax) kappamax = co;         
+       }
+      deallog << "dim ker [" << kermin << ':' << kermax
+             << "] sigma [" << sigmin << ':' << sigmax
+             << "] kappa [" << kappamin << ':' << kappamax << ']' << std::endl;
+      
+    }
+  else if (inversion == householder)
+    {
+    }
+  else if (inversion == gauss_jordan)
+    {
+    }
+  else
+    {
+      Assert(false, ExcNotImplemented());
+    }
+}
+
+
 template <typename number>
 inline
 std::size_t
index 81f53e400d41ea2d8d2b452810c58b3ab5ea7ec9..7c1cb3fa270b7187905de9d53af072c06fd616ed 100644 (file)
@@ -342,7 +342,8 @@ class RelaxationBlockJacobi : public virtual Subscriptor,
                                       * Make function of base class public again.
                                       */
     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
-                                     /**
+    using PreconditionBlockBase<inverse_type>::log_statistics;
+                                    /**
                                       * Perform one step of the Jacobi
                                       * iteration.
                                       */
@@ -424,6 +425,7 @@ class RelaxationBlockSOR : public virtual Subscriptor,
                                       * Make function of base class public again.
                                       */
     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
+    using PreconditionBlockBase<inverse_type>::log_statistics;
                                      /**
                                       * Perform one step of the SOR
                                       * iteration.
@@ -503,6 +505,7 @@ class RelaxationBlockSSOR : public virtual Subscriptor,
                                       * Make function of base class public again.
                                       */
     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
+    using PreconditionBlockBase<inverse_type>::log_statistics;
                                      /**
                                       * Perform one step of the SOR
                                       * iteration.

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.