[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0090739 03/11: Rename an enumeration
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0090739 03/11: Rename an enumeration |
Date: |
Thu, 15 Jul 2021 14:57:10 -0400 (EDT) |
branch: master
commit 009073975dfca935c15b9ff17845403886d540dd
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rename an enumeration
Soon it will contain more enumerators, to trace numerous paths through
the algorithm. These aren't exactly "decisions" or "activities" on a
flowchart, or "transitions" on a state diagram; rather, they record the
reason why control has arrived at a certain point.
It will be seen that the control structure may be understood as
bisect:
COMEFROM dithering_near_root
COMEFROM secant_out_of_bounds
COMEFROM parabola_not_single_valued
COMEFROM guarantee_linear_convergence
[etc.]
but that would seem jocular, whereas recording the impetus that led to
bisection is plainly serious.
---
zero.hpp | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/zero.hpp b/zero.hpp
index 47c3b7d..8b78fd4 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -41,7 +41,7 @@ enum root_bias
,bias_higher // Require 0.0 <= f(z).
};
-enum interpolation_technique
+enum root_impetus
{interpolate_initialization
,interpolate_bisection0
,interpolate_linear
@@ -260,10 +260,10 @@ root_type lmi_root
,detail::RoundT round_dec = lmi_identity()
)
{
- constexpr double epsilon {std::numeric_limits<double>::epsilon()};
+ constexpr double epsilon {std::numeric_limits<double>::epsilon()};
- int n_iter {0};
- interpolation_technique technique {interpolate_initialization};
+ int n_iter {0};
+ root_impetus impetus {interpolate_initialization};
os_trace
<< "#eval"
@@ -285,7 +285,7 @@ root_type lmi_root
{
os_trace
<< std::setw(3) << n_iter
- << ' ' << "IBLQb"[technique]
+ << ' ' << "IBLQb"[impetus]
<< ' ' << std::setw(12) << a << ' ' << std::setw(12) << fa
<< ' ' << std::setw(12) << b << ' ' << std::setw(12) << fb
<< ' ' << std::setw(12) << c << ' ' << std::setw(12) << fc
@@ -367,12 +367,12 @@ root_type lmi_root
}
if(std::fabs(e) < tol)
{
- technique = interpolate_bisection0;
+ impetus = interpolate_bisection0;
d = e = m;
}
else if(std::fabs(fa) <= std::fabs(fb))
{
- technique = interpolate_bisection0;
+ impetus = interpolate_bisection0;
d = e = m;
}
else
@@ -381,13 +381,13 @@ root_type lmi_root
double s = fb / fa; // Note 3.
if(a == c)
{
- technique = interpolate_linear;
+ impetus = interpolate_linear;
p = 2.0 * m * s;
q = 1.0 - s;
}
else
{
- technique = interpolate_inverse_quadratic;
+ impetus = interpolate_inverse_quadratic;
q = fa / fc;
double r = fb / fc;
p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0));
@@ -428,7 +428,7 @@ root_type lmi_root
}
else
{
- technique = interpolate_bisection1;
+ impetus = interpolate_bisection1;
d = e = m;
}
}
@@ -519,8 +519,8 @@ double brent_zero
// machine precision and t is a positive tolerance. Assumes
// that f(a) and f(b) have different signs.
- int n_iter {0};
- interpolation_technique technique {interpolate_initialization};
+ int n_iter {0};
+ root_impetus impetus {interpolate_initialization};
os_trace
<< "#eval"
@@ -536,7 +536,7 @@ double brent_zero
{
os_trace
<< std::setw(3) << n_iter
- << ' ' << "IBLQb"[technique]
+ << ' ' << "IBLQb"[impetus]
<< ' ' << std::setw(12) << a << ' ' << std::setw(12) << fa
<< ' ' << std::setw(12) << b << ' ' << std::setw(12) << fb
<< ' ' << std::setw(12) << c << ' ' << std::setw(12) << fc
@@ -565,12 +565,12 @@ double brent_zero
// See if a bisection is forced.
if(std::fabs(e) < tol)
{
- technique = interpolate_bisection0;
+ impetus = interpolate_bisection0;
d = e = m;
}
else if(std::fabs(fa) <= std::fabs(fb))
{
- technique = interpolate_bisection0;
+ impetus = interpolate_bisection0;
d = e = m;
}
else
@@ -579,14 +579,14 @@ double brent_zero
if(a == c)
{
// Linear interpolation.
- technique = interpolate_linear;
+ impetus = interpolate_linear;
p = 2.0 * m * s;
q = 1.0 - s;
}
else
{
// Inverse quadratic interpolation.
- technique = interpolate_inverse_quadratic;
+ impetus = interpolate_inverse_quadratic;
q = fa / fc;
r = fb / fc;
p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0));
@@ -610,7 +610,7 @@ double brent_zero
}
else
{
- technique = interpolate_bisection1;
+ impetus = interpolate_bisection1;
d = e = m;
}
}
- [lmi-commits] [lmi] master updated (debc275 -> a277ed6), Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 0090739 03/11: Rename an enumeration,
Greg Chicares <=
- [lmi-commits] [lmi] master fb3d854 02/11: Refactor instrumented reference implementation, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 0d9b36b 05/11: Make enumerators print a useful value directly, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 27cdaa7 01/11: Refactor, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master ff2f404 04/11: Use a more informative unit-test macro, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 0b44a84 07/11: Reenumerate root-finding activities, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master dce3edc 08/11: Show variable shifts in optional trace, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 5a3bd1d 10/11: Regularize whitespace, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 70f1126 09/11: Find a root that coincides with an input bound, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master b24bcce 06/11: Improve indentation, Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master a277ed6 11/11: Uniformly test two functions in parallel, Greg Chicares, 2021/07/15