[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1c448d8 20/22: Augment decimal_root()'s retur
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1c448d8 20/22: Augment decimal_root()'s return type |
Date: |
Sun, 6 Jun 2021 21:38:03 -0400 (EDT) |
branch: master
commit 1c448d839d5bfe2a97385610ea5f6ef840075dcd
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Augment decimal_root()'s return type
The number of iterations doesn't matter for production, but is important
for validation.
---
zero.hpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/zero.hpp b/zero.hpp
index be1e7c6..4ff1dd4 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -56,6 +56,7 @@ struct root_type
{
double root {0.0};
root_validity validity {improper_bounds};
+ int n_iter {0};
};
namespace detail
@@ -277,27 +278,27 @@ root_type decimal_root
if(a == b)
{
- return {a, improper_bounds};
+ return {a, improper_bounds, n_iter};
}
double fa = static_cast<double>(f(a));
detail::expatiate(os_trace, n_iter++, technique, a, fa);
if(0.0 == fa) // Note 0.
{
- return {a, root_is_valid};
+ return {a, root_is_valid, n_iter};
}
double fb = static_cast<double>(f(b));
detail::expatiate(os_trace, n_iter++, technique, b, fb);
if(0.0 == fb) // Note 0 [bis].
{
- return {b, root_is_valid};
+ return {b, root_is_valid, n_iter};
}
// f(a) and f(b) must have different signs.
if((0.0 < fa) == (0.0 < fb))
{
- return {0.0, root_not_bracketed};
+ return {0.0, root_not_bracketed, n_iter};
}
double fc = fb; // Note 1.
@@ -328,11 +329,11 @@ root_type decimal_root
|| bias_higher == bias && 0.0 <= fb
)
{
- return {b, root_is_valid};
+ return {b, root_is_valid, n_iter};
}
else if(std::fabs(m) <= 2.0 * epsilon * std::fabs(c) + t)
{
- return {c, root_is_valid};
+ return {c, root_is_valid, n_iter};
}
else
{
- [lmi-commits] [lmi] master updated (f0526be -> 86661b6), Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 7bd1245 01/22: Add a unit test: root of another unfriendly function, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master c01b9b0 02/22: Improve concinnity, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 012967c 08/22: Diagnose any attempt to find a root in a zero-measure interval, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 83eb025 05/22: Rename a local variable, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master ec0a308 06/22: Refactor, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 99aebcc 07/22: Treat decimal_root return value more flexibly, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 5c31ab3 09/22: Fix latent unit-test errors, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 2391573 11/22: Rename a variable, for terseness, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master b14e318 18/22: Adjust tolerance for a particular unit-test function, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 1c448d8 20/22: Augment decimal_root()'s return type,
Greg Chicares <=
- [lmi-commits] [lmi] master 53c3513 21/22: Reorder unit tests, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 5cf534c 04/22: Constify, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 3865416 10/22: Rearrange certain unit tests, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 1f8316c 16/22: Test actual return value, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 3d4adb3 17/22: Clarify, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 200e756 03/22: Clarify documentation, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 1b0ed06 12/22: Change argument order, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 86661b6 22/22: Validate number of iterations, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master 9027fef 13/22: Refactor, Greg Chicares, 2021/06/06
- [lmi-commits] [lmi] master c1a020a 14/22: Include appropriate headers, and say why they're included, Greg Chicares, 2021/06/06