[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 540e3ca 04/14: Simplify
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 540e3ca 04/14: Simplify |
Date: |
Sun, 6 Sep 2020 07:50:37 -0400 (EDT) |
branch: master
commit 540e3ca9e65ffdef6ad273b6f9b67e856c00a616
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Simplify
Removed a useless assertion. Copy assignment works even if the target
vector did not already have the intended length.
Obviated an 'else' clause by initializing 'partial_mortality_lx' to the
value it would have assigned. The 'if' clause is rarely executed, so
the extra work (if any) is rarely wasted.
Hoisted the initialization of 'inforce_lives' out of the conditional,
and used its value in the initialization of 'partial_mortality_lx'.
Removed a now-redundant assignment to the first 'partial_mortality_lx'
element.
---
ihs_acctval.cpp | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 7e2b68b..3f9b4a4 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -420,12 +420,9 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
// composite values are multiplied by the number of lives inforce.
// Of course, a contract is not normally in force after maturity.
- LMI_ASSERT
- ( lmi::ssize(InvariantValues().InforceLives)
- == 1 + BasicValues::GetLength()
- );
+ double inforce_lives = yare_input_.NumberOfIdenticalLives;
partial_mortality_qx.resize( BasicValues::GetLength());
- partial_mortality_lx.resize(1 + BasicValues::GetLength());
+ partial_mortality_lx.resize(1 + BasicValues::GetLength(), inforce_lives);
// TODO ?? 'InvariantValues().InforceLives' may be thought of as
// counting potential inforce lives: it does not reflect lapses.
// It should either reflect lapses or be renamed. Meanwhile,
@@ -433,8 +430,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
// lapses should be taken into account.
if(yare_input_.UsePartialMortality)
{
- double inforce_lives = yare_input_.NumberOfIdenticalLives;
- partial_mortality_lx[0] = inforce_lives;
+ // partial_mortality_lx[0] was set above.
for(int j = 0; j < BasicValues::GetLength(); ++j)
{
partial_mortality_qx[j] = GetPartMortQ(j);
@@ -442,13 +438,6 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
partial_mortality_lx[1 + j] = inforce_lives;
}
}
- else
- {
- partial_mortality_lx.assign
- (partial_mortality_lx.size()
- ,yare_input_.NumberOfIdenticalLives
- );
- }
InvariantValues().InforceLives = partial_mortality_lx;
// It is at best superfluous to do this for every basis.
- [lmi-commits] [lmi] master updated (c4f84b4 -> 59860e3), Greg Chicares, 2020/09/06
- [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 <=
- [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, 2020/09/06
- [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