lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/brent 37cf014 08/11: Define a macro to choose IQ


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/brent 37cf014 08/11: Define a macro to choose IQI criterion
Date: Tue, 22 Jun 2021 16:54:05 -0400 (EDT)

branch: odd/brent
commit 37cf0142597081b8e7227bfe34deb573e5b65099
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Define a macro to choose IQI criterion
---
 zero.hpp | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/zero.hpp b/zero.hpp
index bf8c423..e34034e 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -33,6 +33,8 @@
 #include <limits>
 #include <ostream>
 
+//#define USE_CHANDRUPATLA_IQI_CRITERION
+
 template<typename T>
 inline T signum(T t)
 {
@@ -413,11 +415,11 @@ root_type decimal_root
             cond_0 =  p < std::fabs(0.5 * s * q);
             if
                 (  p < std::fabs(0.5 * s * q)
-#if 1
-                && p < 1.5 * m * q - std::fabs(tol * q)
-#else
+#if defined USE_CHANDRUPATLA_IQI_CRITERION
                 && (interpolate_inverse_quadratic != technique || cond_c)
-#endif // 1
+#else  // !defined USE_CHANDRUPATLA_IQI_CRITERION
+                && p < 1.5 * m * q - std::fabs(tol * q)
+#endif // !defined USE_CHANDRUPATLA_IQI_CRITERION
                 )
                 {
                 d = p / q;
@@ -451,9 +453,6 @@ root_type decimal_root
                         << "  " << (((1.0 - phi) * (1.0 - phi)) < (1.0 - xi)) 
<< " ((1.0 - phi) * (1.0 - phi)) < (1.0 - xi)\n"
                         << std::flush;
 #endif // 1
-// accept Chandrupatla's rejection:
-//                  technique = interpolate_bisection1;
-//                  d = e = m;
                     }
                 }
             else
@@ -580,20 +579,17 @@ int j = 0;
                    (phi * phi) < xi
                 && ((1.0 - phi) * (1.0 - phi)) < (1.0 - xi)
                 ;
+            (void)&cond_c; // Avoid "not used" warning.
             if
-                (   p < 1.5 * m * q - std::fabs(tol * q)
-                &&  p < std::fabs(0.5 * s * q)
+                (  p < std::fabs(0.5 * s * q)
+#if defined USE_CHANDRUPATLA_IQI_CRITERION
+                && (interpolate_inverse_quadratic != technique || cond_c)
+#else  // !defined USE_CHANDRUPATLA_IQI_CRITERION
+                && p < 1.5 * m * q - std::fabs(tol * q)
+#endif // !defined USE_CHANDRUPATLA_IQI_CRITERION
                 )
                 {
-                if(interpolate_inverse_quadratic == technique && !cond_c)
-                    {
-                    technique = interpolate_bisection1;
-                    d = e = m;
-                    }
-                else
-                    {
-                    d = p / q;
-                    }
+                d = p / q;
 #if 0 // for demonstration only--not a good general idea
                 if(interpolate_linear == technique) // Suppress secant 
technique
                     {



reply via email to

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