[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0d9b36b 05/11: Make enumerators print a usefu
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0d9b36b 05/11: Make enumerators print a useful value directly |
Date: |
Thu, 15 Jul 2021 14:57:11 -0400 (EDT) |
branch: master
commit 0d9b36b4187c5b46c2e040c9b11ecfd8267663d2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Make enumerators print a useful value directly
---
zero.hpp | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/zero.hpp b/zero.hpp
index 8b78fd4..bcc03c0 100644
--- a/zero.hpp
+++ b/zero.hpp
@@ -41,12 +41,24 @@ enum root_bias
,bias_higher // Require 0.0 <= f(z).
};
-enum root_impetus
- {interpolate_initialization
- ,interpolate_bisection0
- ,interpolate_linear
- ,interpolate_inverse_quadratic
- ,interpolate_bisection1 // bisection when quadratic rejected
+/// Reason for having been dispatched to a particular "activity".
+///
+/// This is deliberately defined with enum-key 'enum' rather than
+/// 'enum class' or 'enum struct'. It's the same as an 'enum class'
+/// except that its enumerators usefully decay to char for printing.
+/// Feature comparison:
+///
+/// this enum enum class desirable properties
+/// --------- ---------- --------------------
+/// yes yes specifies underlying type
+/// yes no implicitly converts to char
+
+enum root_impetus : char
+ {interpolate_initialization = 'I'
+ ,interpolate_bisection0 = 'B'
+ ,interpolate_linear = 'L'
+ ,interpolate_inverse_quadratic = 'Q'
+ ,interpolate_bisection1 = 'b' // bisection when quadratic rejected
};
enum root_validity
@@ -285,7 +297,7 @@ root_type lmi_root
{
os_trace
<< std::setw(3) << n_iter
- << ' ' << "IBLQb"[impetus]
+ << ' ' << 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
@@ -536,7 +548,7 @@ double brent_zero
{
os_trace
<< std::setw(3) << n_iter
- << ' ' << "IBLQb"[impetus]
+ << ' ' << 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
- [lmi-commits] [lmi] master updated (debc275 -> a277ed6), Greg Chicares, 2021/07/15
- [lmi-commits] [lmi] master 0090739 03/11: Rename an enumeration, Greg Chicares, 2021/07/15
- [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 <=
- [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