[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;
- [lmi-commits] [lmi] master updated (422cd51 -> 5e372c6), Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 36d5a6b 1/9: Remove unnecessary static_cast, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 513e891 4/9: Improve documentation, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master ca32be5 3/9: Find a root of the zero polynomial,
Greg Chicares <=
- [lmi-commits] [lmi] master 3781a93 5/9: Refactor for rearrangeability, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 0ae54b4 2/9: Refactor for terseness, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master b710396 8/9: Don't assume--assert, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 3f1dd88 7/9: Consolidate and improve documentation, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 060aecf 6/9: Rearrange for comprehensibility, Greg Chicares, 2018/02/17
- [lmi-commits] [lmi] master 5e372c6 9/9: Perform ledger IRR initialization in one place only, Greg Chicares, 2018/02/17