lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master ca32be5 3/9: Find a root of the zero polynomi


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ca32be5 3/9: Find a root of the zero polynomial
Date: Sat, 17 Feb 2018 11:13:05 -0500 (EST)

branch: master
commit ca32be5b2eb918b0431853a4ba698cf27f6bce4f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Find a root of the zero polynomial
    
    Do I contradict myself?
    Very well then I contradict myself,
    (I am large, I contain multitudes.)
---
 financial_test.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/financial_test.cpp b/financial_test.cpp
index 14df4d2..d5f7f25 100644
--- a/financial_test.cpp
+++ b/financial_test.cpp
@@ -169,6 +169,23 @@ int test_main(int, char*[])
     BOOST_TEST(std::fabs(-1.00000 - results[ 9]) <= tolerance);
     BOOST_TEST(std::fabs(-1.00000 - results[99]) <= tolerance);
 
+    // Test nonempty cashflow streams consisting only of zeros.
+
+    std::vector<double> p0(7);       // Payments.
+    std::vector<double> b0(7);       // Benefits.
+    std::vector<double> r0(7, 3.14); // Results.
+
+    // This version leaves 'results' unchanged. Test it to make
+    // sure it doesn't segfault.
+    irr(p0.begin(), p0.begin(), b0.begin(), r0.begin(), decimals);
+    BOOST_TEST_EQUAL(r0[3], 3.14);
+
+    // SOMEDAY !! The zero polynomial has an infinitude of roots,
+    // but, given that we must return only one, wouldn't some
+    // value like 0% or -100% be more suitable?
+    irr(p0, b0, r0, p0.size(), p0.size(), decimals);
+    BOOST_TEST_EQUAL(r0[3], 1000);
+
     // Test fv().
 
     static long double const i = .05L;



reply via email to

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