[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 3ff6e18 13/14: Add and use trivial const acce
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 3ff6e18 13/14: Add and use trivial const accessors |
Date: |
Sun, 6 Sep 2020 07:50:39 -0400 (EDT) |
branch: master
commit 3ff6e1858949d33c7e2cc9ee4116e66fa3f69f88
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Add and use trivial const accessors
---
account_value.hpp | 10 +++++++---
ihs_acctval.cpp | 30 +++++++++++++++---------------
ihs_avdebug.cpp | 2 +-
3 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/account_value.hpp b/account_value.hpp
index 638f3e0..525378c 100644
--- a/account_value.hpp
+++ b/account_value.hpp
@@ -91,6 +91,10 @@ class LMI_SO AccountValue final
std::shared_ptr<Ledger const> ledger_from_av() const;
+ auto const& partial_mortality_qx () const {return partial_mortality_qx_ ;}
+ auto const& partial_mortality_tpx() const {return partial_mortality_tpx_;}
+ auto const& partial_mortality_lx () const {return partial_mortality_lx_ ;}
+
private:
AccountValue(AccountValue const&) = delete;
AccountValue& operator=(AccountValue const&) = delete;
@@ -584,9 +588,9 @@ class LMI_SO AccountValue final
double YearsTotalSpecAmtLoad;
double YearsTotalSepAcctLoad;
- std::vector<double> partial_mortality_qx;
- std::vector<double> partial_mortality_tpx;
- std::vector<double> partial_mortality_lx;
+ std::vector<double> partial_mortality_qx_;
+ std::vector<double> partial_mortality_tpx_;
+ std::vector<double> partial_mortality_lx_;
// For experience rating.
double CoiRetentionRate;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 7870191..0834349 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -107,7 +107,7 @@ AccountValue::AccountValue(Input const& input)
InvariantValues().Init(this);
set_partial_mortality();
- InvariantValues().InforceLives = partial_mortality_lx;
+ InvariantValues().InforceLives = partial_mortality_lx();
// Explicitly initialize antediluvian members. It's generally
// better to do this in the initializer-list, but here they can
@@ -1063,9 +1063,9 @@ void AccountValue::SetClaims()
TxSetDeathBft();
TxSetTermAmt();
- YearsGrossClaims = partial_mortality_qx[Year] * DBReflectingCorr;
- YearsAVRelOnDeath = partial_mortality_qx[Year] * TotalAccountValue();
- YearsLoanRepaidOnDeath = partial_mortality_qx[Year] * (RegLnBal +
PrfLnBal);
+ YearsGrossClaims = partial_mortality_qx()[Year] * DBReflectingCorr;
+ YearsAVRelOnDeath = partial_mortality_qx()[Year] *
TotalAccountValue();
+ YearsLoanRepaidOnDeath = partial_mortality_qx()[Year] * (RegLnBal +
PrfLnBal);
YearsDeathProceeds = material_difference
(YearsGrossClaims
,YearsLoanRepaidOnDeath
@@ -1454,18 +1454,18 @@ void AccountValue::SetAnnualInvariants()
void AccountValue::set_partial_mortality()
{
double const inforce_lives = yare_input_.NumberOfIdenticalLives;
- partial_mortality_qx .resize( BasicValues::GetLength());
- partial_mortality_tpx.resize(1 + BasicValues::GetLength(), 1.0);
- partial_mortality_lx .resize(1 + BasicValues::GetLength(), inforce_lives);
+ partial_mortality_qx_ .resize( BasicValues::GetLength());
+ partial_mortality_tpx_.resize(1 + BasicValues::GetLength(), 1.0);
+ partial_mortality_lx_ .resize(1 + BasicValues::GetLength(), inforce_lives);
if(yare_input_.UsePartialMortality)
{
// The first elements of lx and tpx were set above.
for(int j = 0; j < BasicValues::GetLength(); ++j)
{
- partial_mortality_qx[j] = GetPartMortQ(j);
- double const px = 1.0 - partial_mortality_qx[j];
- partial_mortality_tpx[1 + j] = px * partial_mortality_tpx[j];
- partial_mortality_lx [1 + j] = px * partial_mortality_lx [j];
+ partial_mortality_qx_[j] = GetPartMortQ(j);
+ double const px = 1.0 - partial_mortality_qx_[j];
+ partial_mortality_tpx_[1 + j] = px * partial_mortality_tpx_[j];
+ partial_mortality_lx_ [1 + j] = px * partial_mortality_lx_ [j];
}
}
}
@@ -1501,7 +1501,7 @@ double AccountValue::GetSepAcctAssetsInforce() const
return 0.0;
}
- return SepAcctValueAfterDeduction * partial_mortality_lx[Year];
+ return SepAcctValueAfterDeduction * partial_mortality_lx()[Year];
}
//============================================================================
@@ -1537,7 +1537,7 @@ double AccountValue::GetCurtateNetClaimsInforce() const
}
LMI_ASSERT(11 == Month);
- return YearsNetClaims * partial_mortality_lx[Year];
+ return YearsNetClaims * partial_mortality_lx()[Year];
}
//============================================================================
@@ -1606,7 +1606,7 @@ double AccountValue::ApportionNetMortalityReserve
double AccountValue::InforceLivesBoy() const
{
bool const b {ItLapsed || BasicValues::GetLength() <= Year};
- return b ? 0.0 : partial_mortality_lx.at(Year);
+ return b ? 0.0 : partial_mortality_lx().at(Year);
}
/// End of year inforce lives, reflecting lapses and survivorship.
@@ -1614,7 +1614,7 @@ double AccountValue::InforceLivesBoy() const
double AccountValue::InforceLivesEoy() const
{
bool const b {ItLapsed || BasicValues::GetLength() <= Year};
- return b ? 0.0 : partial_mortality_lx.at(1 + Year);
+ return b ? 0.0 : partial_mortality_lx().at(1 + Year);
}
//============================================================================
diff --git a/ihs_avdebug.cpp b/ihs_avdebug.cpp
index 6e802c8..8893f04 100644
--- a/ihs_avdebug.cpp
+++ b/ihs_avdebug.cpp
@@ -433,7 +433,7 @@ void AccountValue::DebugPrint()
LMI_ASSERT(0 != yare_input_.NumberOfIdenticalLives);
SetMonthlyDetail
(eInforceFactor
- ,ItLapsed ? 0.0 : partial_mortality_tpx[Year]
+ ,ItLapsed ? 0.0 : partial_mortality_tpx()[Year]
);
// TODO ?? Claims appear as zero because SetClaims() is called not
- [lmi-commits] [lmi] master 123b572 01/14: Avoid reading back from ledger in class AccountValue, (continued)
- [lmi-commits] [lmi] master 123b572 01/14: Avoid reading back from ledger in class AccountValue, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master b4eb422 02/14: Rename a variable, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 14c2920 07/14: Factor out partial-mortality calculations, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 338d589 10/14: Call set_partial_mortality() OAOO, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 915e4ef 03/14: Avoid reading back from ledger in class AccountValue, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 540e3ca 04/14: Simplify, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 73d5f2b 06/14: Refactor for terseness, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 2bcf8d3 08/14: Move commentary outside function body, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 7b9b0cf 11/14: Resolve a marked defect [339], Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3cbd888 12/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 3ff6e18 13/14: Add and use trivial const accessors,
Greg Chicares <=
- [lmi-commits] [lmi] master 1f2d652 05/14: Calculate and store partial-mortality tpx along with lx, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master a1d6c16 09/14: Improve documentation, Greg Chicares, 2020/09/06
- [lmi-commits] [lmi] master 59860e3 14/14: Move partial mortality into base class, Greg Chicares, 2020/09/06