[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master ad14033 6/8: Improve and test translation fro
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master ad14033 6/8: Improve and test translation from ALGOL 60 |
Date: |
Wed, 2 Jun 2021 15:37:07 -0400 (EDT) |
branch: master
commit ad14033fbe251056fa6d032a960ab059a540cc24
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Improve and test translation from ALGOL 60
gcc warned that some variables might have been used uninitialized;
fixed by initializing them as in decimal_root().
---
zero.hpp | 4 +++-
zero_test.cpp | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/zero.hpp b/zero.hpp
index 46f31e3..8b69e4c 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -427,10 +427,12 @@ double brent_zero
double fa = f(a);
double fb = f(b);
double fc = fb;
+ double c = b;
+ double d = b - a;
+ double e = d;
for(;;)
{
- double c, d, e;
if((0.0 < fb) == (0.0 < fc))
{
c = a;
diff --git a/zero_test.cpp b/zero_test.cpp
index 76eb79e..23f1797 100644
--- a/zero_test.cpp
+++ b/zero_test.cpp
@@ -193,6 +193,9 @@ int test_main(int, char*[])
LMI_TEST(root_is_valid == r.second);
LMI_TEST(std::fabs(r.first) <= epsilon);
+ double d = brent_zero(-1.0, 4.0, 1.0e-20, e_19);
+ LMI_TEST(std::fabs(d) <= epsilon);
+
test_zero(-1.0, 4.0, -100, e_19, std::exp(1.0));
test_zero(-1.0, 4.0, 0, e_19, std::exp(1.0));
test_zero(-1.0, 4.0, 100, e_19, std::exp(1.0));
- [lmi-commits] [lmi] master updated (f9276c0 -> f0526be), Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master ad14033 6/8: Improve and test translation from ALGOL 60,
Greg Chicares <=
- [lmi-commits] [lmi] master f0526be 8/8: Designate release candidate 20210602T1807Z, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master 6b65f7f 3/8: Rename certain arguments and variables, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master e41a14f 4/8: Improve instrumentation, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master 7a75531 2/8: Write non-const reference arguments first, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master d0e0746 1/8: Improve documentation, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master d35e677 7/8: Add a unit test: root of an unfriendly function, Greg Chicares, 2021/06/02
- [lmi-commits] [lmi] master 9292445 5/8: Fix a unit test, Greg Chicares, 2021/06/02