[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 4500338 22/23: Simplify
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 4500338 22/23: Simplify |
Date: |
Tue, 27 Jul 2021 21:59:55 -0400 (EDT) |
branch: master
commit 4500338b9e264ed3c3de734a2da88daa27747fc2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Simplify
std::numeric_limits is better for templated types, but where the type is
always 'double', DBL_EPSILON is terse and pellucid.
---
zero.hpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/zero.hpp b/zero.hpp
index 1b89b0f..d42690f 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -355,8 +355,6 @@ root_type lmi_root
,root_bias bias = bias_none
)
{
- constexpr double epsilon {std::numeric_limits<double>::epsilon()};
-
int n_iter {0};
int n_eval {0};
root_impetus impetus {evaluate_bounds};
@@ -466,7 +464,7 @@ root_type lmi_root
impetus = force_b_to_be_best_approximation;
expatiate();
}
- double tol = 2.0 * epsilon * std::fabs(b) + t;
+ double tol = 2.0 * DBL_EPSILON * std::fabs(b) + t;
double m = 0.5 * (c - b);
double n = std::midpoint(b, c); // "next" iterate
if(0.0 == fb || std::fabs(m) <= tol) // Note 2.
@@ -481,7 +479,7 @@ root_type lmi_root
os_trace << " return value: " << b << " = b" << std::endl;
return {b, root_is_valid, n_iter, n_eval};
}
- else if(std::fabs(m) <= 2.0 * epsilon * std::fabs(c) + t)
+ else if(std::fabs(m) <= 2.0 * DBL_EPSILON * std::fabs(c) + t)
{
recapitulate();
os_trace << " return value: " << c << " = c" << std::endl;
- [lmi-commits] [lmi] master a259cb6 05/23: Calculate maximum possible number of iterations, (continued)
- [lmi-commits] [lmi] master a259cb6 05/23: Calculate maximum possible number of iterations, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master d0a65c2 04/23: Demonstrate that Brent's δ can be almost arbitrarily small, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 548f9ab 06/23: Document known shortcomings of a unit-testing helper, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 19a4a3a 03/23: For now at least, trace solves in regression test, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 04c58eb 09/23: Count iterations and evaluations separately, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master bbf2517 10/23: Use signum() where a signum function is wanted, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master e08be34 12/23: Improve a unit test, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 02dde17 13/23: Avoid catastrophic cancellation, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master d2dcbf8 15/23: Reduce complexity, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master e93ca8f 17/23: Demonstration, for immediate reversion, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 4500338 22/23: Simplify,
Greg Chicares <=
- [lmi-commits] [lmi] master 2ad4944 20/23: Record some more observations--no files changed, Greg Chicares, 2021/07/27
- [lmi-commits] [lmi] master 028b454 23/23: Find any root with only 64 function evaluations, Greg Chicares, 2021/07/27