From: guido Date: Fri, 8 Apr 2005 09:16:43 +0000 (+0000) Subject: add filtering small values to LogStream X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faaaaefc7f859c16812f43096e20e5e6ac34173c;p=dealii-svn.git add filtering small values to LogStream git-svn-id: https://svn.dealii.org/trunk@10425 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/logstream.h b/deal.II/base/include/base/logstream.h index 1675f1a1b8..3faea5d3e9 100644 --- a/deal.II/base/include/base/logstream.h +++ b/deal.II/base/include/base/logstream.h @@ -182,6 +182,15 @@ class LogStream * parameter is returned. */ bool log_time_differences (const bool flag); + + /** + * Set a threshold for the + * minimal absolute value of + * double values. All numbers + * with a smaller absolute value + * will be printed as zero. + */ + void threshold_double(const double t); /** * Output a constant something @@ -190,6 +199,18 @@ class LogStream template LogStream & operator << (const T &t); + /** + * Output double precision + * numbers through this + * stream. This function + * eliminates floating point + * numbers smaller than + * #double_threshold, which can + * be changed using + * threshold_double(). + */ + LogStream & operator << (const double t); + /** * Treat ostream * manipulators. This passes on @@ -314,6 +335,12 @@ class LogStream */ double last_time; + /** + * Threshold for printing double + * values. + */ + double double_threshold; + /** * Original buffer of * std::cerr. We store @@ -361,6 +388,22 @@ LogStream::operator<< (const T& t) +inline +LogStream & +LogStream::operator<< (const double t) +{ + // do the work that is common to + // the two operator<< functions + if (std::fabs(t) > double_threshold) + print (t); + else + print('0'); + + return *this; +} + + + inline LogStream & LogStream::operator<< (std::ostream& (*p) (std::ostream&)) diff --git a/deal.II/base/source/log.cc b/deal.II/base/source/log.cc index c8b9e9da09..204220f1a0 100644 --- a/deal.II/base/source/log.cc +++ b/deal.II/base/source/log.cc @@ -50,7 +50,7 @@ LogStream::LogStream() std_out(&std::cerr), file(0), was_endl(true), std_depth(10000), file_depth(10000), print_utime(false), diff_utime(false), - last_time (0.), old_cerr(0) + last_time (0.), double_threshold(0.), old_cerr(0) { prefixes.push("DEAL:"); std_out->setf(std::ios::showpoint | std::ios::left); @@ -148,6 +148,13 @@ LogStream::depth_file (const unsigned n) } +void +LogStream::threshold_double (const double t) +{ + double_threshold = t; +} + + bool LogStream::log_execution_time (const bool flag) {