lmi-commits
[Top][All Lists]
Advanced

[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.



reply via email to

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