[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 7b18d1d 2/7: Hard-code 7702 i for a unit test
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 7b18d1d 2/7: Hard-code 7702 i for a unit test |
Date: |
Mon, 22 Feb 2021 07:46:30 -0500 (EST) |
branch: master
commit 7b18d1dfe46a2b036acf73283dfcdc96136d1858
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Hard-code 7702 i for a unit test
Class irc7702_tables gets its 7702 parameters from ctor arguments,
so it cannot independently know what interest rate to use.
The 7702 operative interest rate is now a vector parameter for both
UL and OL calculations.
Incidentally, Eckley's "simple case" (ic = ig = i) always obtains
for 7702 UL commutation functions--a fact deducible from '7702.html',
though not yet documented there.
---
Makefile.am | 1 -
irc7702_tables.cpp | 30 +++++++++---------------------
irc7702_tables.hpp | 3 ++-
irc7702_tables_test.cpp | 7 ++-----
objects.make | 1 -
5 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index a9d0845..3941183 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -872,7 +872,6 @@ test_irc7702_tables_SOURCES = \
commutation_functions.cpp \
cso_table.cpp \
global_settings.cpp \
- irc7702_interest.cpp \
irc7702_tables.cpp \
irc7702_tables_test.cpp \
miscellany.cpp \
diff --git a/irc7702_tables.cpp b/irc7702_tables.cpp
index 582fd47..5195955 100644
--- a/irc7702_tables.cpp
+++ b/irc7702_tables.cpp
@@ -27,24 +27,22 @@
#include "commutation_functions.hpp"
#include "cso_table.hpp"
#include "et_vector.hpp"
-#include "irc7702_interest.hpp" // iglp()
#include "math_functions.hpp"
#include "ssize_lmi.hpp"
-#include <cmath> // log()
-
irc7702_tables::irc7702_tables
(mcenum_cso_era cso_era
,oenum_autopisty autopisty
,oenum_alb_or_anb alb_or_anb
,mcenum_gender gender
,mcenum_smoking smoking
- ,std::vector<double> const& naar_discount
+ ,std::vector<double> const& operative_i
,double max_coi_rate
,int min_age
,int max_age
)
:q_ {cso_table(cso_era, autopisty, alb_or_anb, gender, smoking,
min_age, max_age)}
+ ,i_ {operative_i}
,length_ {lmi::ssize(q_)}
// Initialize to proper length to support PETE usage below:
,ul_corr_ (length_)
@@ -53,22 +51,12 @@ irc7702_tables::irc7702_tables
,ol_7pp_ (length_)
{
std::vector<double> q12(length_);
- assign(q12, apply_binary(coi_rate_from_q<double>(), q_, max_coi_rate));
-
- // ic: iglp() is the statutory rate.
- // ig: Argument 'naar_discount' corresponds to DB_NaarDiscount,
- // which is assumed to be rounded appropriately if at all.
- std::vector<double> const ic
- (length_
- ,i_upper_12_over_12_from_i<double>()(iglp())
- );
- std::vector<double> const& ig(naar_discount);
+ q12 += apply_binary(coi_rate_from_q<double>(), q_, max_coi_rate);
- LMI_ASSERT(lmi::ssize(q12) == length_);
- LMI_ASSERT(lmi::ssize(ic ) == length_);
- LMI_ASSERT(lmi::ssize(ig ) == length_);
+ std::vector<double> i12(length_);
+ i12 += apply_unary(i_upper_12_over_12_from_i<double>(), i_);
- ULCommFns const ulcf(q12, ic, ig, mce_option1_for_7702, mce_monthly);
+ ULCommFns const ulcf(q12, i12, i12, mce_option1_for_7702, mce_monthly);
ul_corr_ += ulcf.aD() / (ulcf.aDomega() + ulcf.kM());
@@ -78,9 +66,9 @@ irc7702_tables::irc7702_tables
E7aN.erase(E7aN.begin(), 7 + E7aN.begin());
ul_7pp_ += (ulcf.aDomega() + ulcf.kM()) / (ulcf.aN() - E7aN);
- double const i_over_delta = iglp() / std::log(1 + iglp());
- std::vector<double> const i(length_, iglp());
- OLCommFns const olcf(q_, i);
+ std::vector<double> i_over_delta(length_);
+ i_over_delta += i_ / log(1 + i_); // PETE's log(), not std::log()
+ OLCommFns const olcf(q_, i_);
// Alternative calculations that may be useful someday are given
// in comments.
diff --git a/irc7702_tables.hpp b/irc7702_tables.hpp
index cb44639..171886f 100644
--- a/irc7702_tables.hpp
+++ b/irc7702_tables.hpp
@@ -41,7 +41,7 @@ class LMI_SO irc7702_tables final
,oenum_alb_or_anb
,mcenum_gender
,mcenum_smoking
- ,std::vector<double> const& naar_discount
+ ,std::vector<double> const& operative_i
,double max_coi_rate
// Potentially defaultable.
,int min_age
@@ -54,6 +54,7 @@ class LMI_SO irc7702_tables final
private:
std::vector<double> const q_ {};
+ std::vector<double> const i_ {};
int const length_ {};
std::vector<double> ul_corr_ {};
std::vector<double> ul_7pp_ {};
diff --git a/irc7702_tables_test.cpp b/irc7702_tables_test.cpp
index da8175e..3b4f6ec 100644
--- a/irc7702_tables_test.cpp
+++ b/irc7702_tables_test.cpp
@@ -456,17 +456,14 @@ static double const ss_ol_7pp[100] =
void Test_Corridor_and_7PP()
{
double constexpr iglp = 0.04;
- std::vector<double> const naar_discount
- (100
- ,i_upper_12_over_12_from_i<double>()(iglp)
- );
+ std::vector<double> const operative_i(100, iglp);
irc7702_tables z
(mce_2001cso
,oe_orthodox
,oe_age_last_birthday
,mce_unisex
,mce_unismoke
- ,naar_discount
+ ,operative_i
,1.0 / 12.0
,0
,100
diff --git a/objects.make b/objects.make
index b505327..497ae71 100644
--- a/objects.make
+++ b/objects.make
@@ -751,7 +751,6 @@ irc7702_tables_test$(EXEEXT): \
commutation_functions.o \
cso_table.o \
global_settings.o \
- irc7702_interest.o \
irc7702_tables.o \
irc7702_tables_test.o \
miscellany.o \
- [lmi-commits] [lmi] master updated (dc99d2e -> a62fbec), Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master d162b18 1/7: Improve documentation, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master e143602 3/7: Hard-code 7702 i for another unit test, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master 6c4deff 4/7: Use 7702 statutory i from database, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master 7b18d1d 2/7: Hard-code 7702 i for a unit test,
Greg Chicares <=
- [lmi-commits] [lmi] master b7b20c4 5/7: Resurrect ancient code for 7702 (loan) interest, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master 1a3d3e6 6/7: Fix defect introduced 20050114T1947Z: used the wrong variable [301], Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master a62fbec 7/7: Loan rate affects 7702 if loans allowed, not only if elected, Greg Chicares, 2021/02/22