lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] odd/eraseme_error 95690a5 5/9: Remove a confusing ov


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/eraseme_error 95690a5 5/9: Remove a confusing overload
Date: Thu, 8 Jul 2021 16:26:47 -0400 (EDT)

branch: odd/eraseme_error
commit 95690a558bbce467dcf68d91ffc64d456f9847cf
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Remove a confusing overload
    
    This will be elucidated on 'master'.
---
 financial.hpp      |  2 ++
 financial_test.cpp | 12 +++---------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/financial.hpp b/financial.hpp
index ada1e9a..a69fddb 100644
--- a/financial.hpp
+++ b/financial.hpp
@@ -160,6 +160,7 @@ long double irr
     return irr_helper<InputIterator>(first, last, x, decimals)();
 }
 
+#if 0
 template<typename InputIterator>
 long double irr
     (InputIterator first
@@ -169,6 +170,7 @@ long double irr
 {
     return irr_helper<InputIterator>(first, last - 1, -*(last - 1), 
decimals)();
 }
+#endif // 0
 
 template
     <typename InputIterator0
diff --git a/financial_test.cpp b/financial_test.cpp
index e9758e9..5143b38 100644
--- a/financial_test.cpp
+++ b/financial_test.cpp
@@ -59,7 +59,7 @@ int test_main(int, char*[])
 
     // Test with arrays.
     double cash_flows[4] = {pmts[0], pmts[1], pmts[2], -bfts[2]};
-    LMI_TEST_EQUAL(2.0, irr(cash_flows, 4 + cash_flows, 5));
+    LMI_TEST_EQUAL(2.0, irr(pmts, 3 + pmts, bfts[2], 5));
 
     LMI_TEST_EQUAL(  882.8125, fv(cash_flows + 0, cash_flows + 3,  0.25));
     LMI_TEST_EQUAL( 2200.0   , fv(cash_flows + 0, cash_flows + 3,  1.0 ));
@@ -72,14 +72,8 @@ int test_main(int, char*[])
     LMI_TEST_EQUAL(-6400.0   , fv(cash_flows + 0, cash_flows + 4,  1.0 ));
 
     // Test with vectors.
-    std::vector<double> v(cash_flows, 4 + cash_flows);
-    // The next test is begging to fail. It was designed so that 200%
-    // is a root; but appending a zero at the end of the stream makes
-    // -100% a root, and arguably a preferable one. Reason: any stream
-    // of payments accumulates to a future value of zero at a rate of
-    // -100%.
-    LMI_TEST_EQUAL(-1.0, irr(v.begin(), v.end(), 0.0, 5));
-    LMI_TEST_EQUAL(2.0, irr(v.begin(), v.end(), 5));
+    std::vector<double> v(pmts, 3 + pmts);
+    LMI_TEST_EQUAL(2.0, irr(v.begin(), v.end(), bfts[2], 5));
 
     std::vector<double> p; // Payments.
     std::vector<double> b; // Benefits.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]