lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 47d6100 7/7: Suppress all output to null stre


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 47d6100 7/7: Suppress all output to null stream in decimal_root()
Date: Tue, 27 Jun 2017 17:13:48 -0400 (EDT)

branch: master
commit 47d6100934d1c18660d0e0c67f0ecee87810f4fc
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Suppress all output to null stream in decimal_root()
    
    See:
      http://lists.nongnu.org/archive/html/lmi/2017-06/msg00008.html
    This change doubled the recent sevenfold improvement in the speed of
    mete_dob_limit().
---
 zero.hpp | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/zero.hpp b/zero.hpp
index af71c93..9606d3d 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -255,24 +255,30 @@ root_type decimal_root
     double b = round_(bound1);
 
     double fa = static_cast<double>(f(a));
-    iteration_stream
-        << "iteration " << number_of_iterations++
-        << " iterand "  << a
-        << " value "    << fa
-        << std::endl
-        ;
+    if(iteration_stream.good())
+        {
+        iteration_stream
+            << "iteration " << number_of_iterations++
+            << " iterand "  << a
+            << " value "    << fa
+            << std::endl
+            ;
+        }
     if(0.0 == fa)
         {
         return std::make_pair(a, root_is_valid);
         }
 
     double fb = static_cast<double>(f(b));
-    iteration_stream
-        << "iteration " << number_of_iterations++
-        << " iterand "  << b
-        << " value "    << fb
-        << std::endl
-        ;
+    if(iteration_stream.good())
+        {
+        iteration_stream
+            << "iteration " << number_of_iterations++
+            << " iterand "  << b
+            << " value "    << fb
+            << std::endl
+            ;
+        }
     double last_evaluated_iterand = b; // Note 1.
     if(0.0 == fb)
         {
@@ -401,12 +407,15 @@ root_type decimal_root
             {
             fb = static_cast<double>(f(b));
             last_evaluated_iterand = b;
-            iteration_stream
-                << "iteration " << number_of_iterations++
-                << " iterand "  << b
-                << " value "    << fb
-                << std::endl
-                ;
+            if(iteration_stream.good())
+                {
+                iteration_stream
+                    << "iteration " << number_of_iterations++
+                    << " iterand "  << b
+                    << " value "    << fb
+                    << std::endl
+                    ;
+                }
             }
         }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]