From: kanschat Date: Tue, 3 Apr 2012 20:24:22 +0000 (+0000) Subject: add some statistics X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cae93c65929e88e8302073b04d1e84795c63a11;p=dealii-svn.git add some statistics git-svn-id: https://svn.dealii.org/trunk@25378 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/precondition_block.h b/deal.II/include/deal.II/lac/precondition_block.h index f4816b6c3d..082228dfd4 100644 --- a/deal.II/include/deal.II/lac/precondition_block.h +++ b/deal.II/include/deal.II/lac/precondition_block.h @@ -613,6 +613,7 @@ class PreconditionBlockJacobi : public virtual Subscriptor, using PreconditionBlockBase::inverse; using PreconditionBlockBase::inverse_householder; using PreconditionBlockBase::inverse_svd; + using PreconditionBlockBase::log_statistics; /** * @deprecated Use size() instead */ @@ -784,6 +785,7 @@ class PreconditionBlockSOR : public virtual Subscriptor, using PreconditionBlock::set_same_diagonal; using PreconditionBlock::invert_diagblocks; using PreconditionBlock::set_permutation; + using PreconditionBlockBase::log_statistics; /** * Execute block SOR @@ -973,6 +975,7 @@ class PreconditionBlockSSOR : public virtual Subscriptor, using PreconditionBlockBase::inverse; using PreconditionBlockBase::inverse_householder; using PreconditionBlockBase::inverse_svd; + using PreconditionBlockBase::log_statistics; using PreconditionBlockSOR::set_permutation; using PreconditionBlockSOR::empty; using PreconditionBlockSOR::el; diff --git a/deal.II/include/deal.II/lac/precondition_block_base.h b/deal.II/include/deal.II/lac/precondition_block_base.h index 3b0633731d..097256c164 100644 --- a/deal.II/include/deal.II/lac/precondition_block_base.h +++ b/deal.II/include/deal.II/lac/precondition_block_base.h @@ -228,11 +228,22 @@ class PreconditionBlockBase */ const FullMatrix& 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::inverses_ready() const } +template +inline void +PreconditionBlockBase::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& 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 inline std::size_t diff --git a/deal.II/include/deal.II/lac/relaxation_block.h b/deal.II/include/deal.II/lac/relaxation_block.h index 81f53e400d..7c1cb3fa27 100644 --- a/deal.II/include/deal.II/lac/relaxation_block.h +++ b/deal.II/include/deal.II/lac/relaxation_block.h @@ -342,7 +342,8 @@ class RelaxationBlockJacobi : public virtual Subscriptor, * Make function of base class public again. */ using RelaxationBlock::inverse_svd; - /** + using PreconditionBlockBase::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::inverse_svd; + using PreconditionBlockBase::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::inverse_svd; + using PreconditionBlockBase::log_statistics; /** * Perform one step of the SOR * iteration.