[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 15ef269: Fix more currency-class issues
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 15ef269: Fix more currency-class issues |
Date: |
Tue, 26 Jan 2021 00:24:47 -0500 (EST) |
branch: master
commit 15ef269b8a8eae0698e4630ce4ee05e9e78f2b1a
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Fix more currency-class issues
These changes are minor and obvious, and required for eventual use of
the currency class. Combined with the changes in the last several
commits, they make lmi slower by about five percent (i686) to eight
percent (x86_64), presumably due mostly to the cost of more careful
rounding.
---
Speed_gcc_i686-w64-mingw32 | 12 ++++++------
Speed_gcc_x86_64-pc-linux-gnu | 12 ++++++------
Speed_gcc_x86_64-w64-mingw32 | 12 ++++++------
gpt_specamt.cpp | 2 +-
ihs_acctval.cpp | 12 ++++++------
ihs_avstrtgy.cpp | 4 ++--
ihs_basicval.cpp | 22 +++++++++++++---------
7 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/Speed_gcc_i686-w64-mingw32 b/Speed_gcc_i686-w64-mingw32
index 294d586..78c0496 100644
--- a/Speed_gcc_i686-w64-mingw32
+++ b/Speed_gcc_i686-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 5.176e-02 s mean; 51559 us least of 20 runs
- naic, specamt solve : 9.231e-02 s mean; 92006 us least of 11 runs
- naic, ee prem solve : 8.838e-02 s mean; 84505 us least of 12 runs
- finra, no solve : 2.179e-02 s mean; 21605 us least of 46 runs
- finra, specamt solve: 5.896e-02 s mean; 58739 us least of 17 runs
- finra, ee prem solve: 5.492e-02 s mean; 54687 us least of 19 runs
+ naic, no solve : 5.509e-02 s mean; 53999 us least of 19 runs
+ naic, specamt solve : 1.010e-01 s mean; 97000 us least of 10 runs
+ naic, ee prem solve : 8.984e-02 s mean; 89110 us least of 12 runs
+ finra, no solve : 2.257e-02 s mean; 22016 us least of 45 runs
+ finra, specamt solve: 6.155e-02 s mean; 60858 us least of 17 runs
+ finra, ee prem solve: 5.745e-02 s mean; 56634 us least of 18 runs
diff --git a/Speed_gcc_x86_64-pc-linux-gnu b/Speed_gcc_x86_64-pc-linux-gnu
index 3cda0e3..bf155d4 100644
--- a/Speed_gcc_x86_64-pc-linux-gnu
+++ b/Speed_gcc_x86_64-pc-linux-gnu
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 1.930e-02 s mean; 18877 us least of 52 runs
- naic, specamt solve : 3.380e-02 s mean; 32990 us least of 30 runs
- naic, ee prem solve : 3.104e-02 s mean; 30405 us least of 33 runs
- finra, no solve : 7.782e-03 s mean; 7468 us least of 100 runs
- finra, specamt solve: 2.096e-02 s mean; 20403 us least of 48 runs
- finra, ee prem solve: 1.958e-02 s mean; 18668 us least of 52 runs
+ naic, no solve : 2.059e-02 s mean; 20123 us least of 49 runs
+ naic, specamt solve : 3.542e-02 s mean; 34962 us least of 29 runs
+ naic, ee prem solve : 3.256e-02 s mean; 32208 us least of 31 runs
+ finra, no solve : 8.059e-03 s mean; 7764 us least of 100 runs
+ finra, specamt solve: 2.173e-02 s mean; 21377 us least of 47 runs
+ finra, ee prem solve: 2.028e-02 s mean; 19877 us least of 50 runs
diff --git a/Speed_gcc_x86_64-w64-mingw32 b/Speed_gcc_x86_64-w64-mingw32
index 5eff62d..8178b09 100644
--- a/Speed_gcc_x86_64-w64-mingw32
+++ b/Speed_gcc_x86_64-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 2.688e-02 s mean; 26723 us least of 38 runs
- naic, specamt solve : 4.241e-02 s mean; 42159 us least of 24 runs
- naic, ee prem solve : 3.941e-02 s mean; 39256 us least of 26 runs
- finra, no solve : 1.471e-02 s mean; 14582 us least of 68 runs
- finra, specamt solve: 2.898e-02 s mean; 28827 us least of 35 runs
- finra, ee prem solve: 2.740e-02 s mean; 27285 us least of 37 runs
+ naic, no solve : 2.886e-02 s mean; 28558 us least of 35 runs
+ naic, specamt solve : 4.584e-02 s mean; 45372 us least of 22 runs
+ naic, ee prem solve : 4.259e-02 s mean; 42151 us least of 24 runs
+ finra, no solve : 1.496e-02 s mean; 14718 us least of 67 runs
+ finra, specamt solve: 3.061e-02 s mean; 30245 us least of 33 runs
+ finra, ee prem solve: 2.894e-02 s mean; 28568 us least of 35 runs
diff --git a/gpt_specamt.cpp b/gpt_specamt.cpp
index 50f7202..a9116bd 100644
--- a/gpt_specamt.cpp
+++ b/gpt_specamt.cpp
@@ -98,7 +98,7 @@ class FindSpecAmt
// CURRENCY !! decimal_root() expects this; but see 'ihs_avsolve.cpp'.
double operator()(double a_Trial)
{
- SpecAmt = a_Trial;
+ SpecAmt = Values_.round_min_specamt().c(a_Trial);
return
Irc7702_.CalculatePremium
(EIOBasis_
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index de21079..32b344c 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -1169,9 +1169,9 @@ void AccountValue::FinalizeYear()
{
VariantValues().TotalLoanBalance[Year] = dblize(RegLnBal + PrfLnBal);
- double total_av = TotalAccountValue();
- double surr_chg = SurrChg();
- double csv_net =
+ currency total_av = TotalAccountValue();
+ currency surr_chg = SurrChg();
+ currency csv_net =
total_av
- (RegLnBal + PrfLnBal)
// + ExpRatReserve // This would be added if it existed.
@@ -1208,7 +1208,7 @@ void AccountValue::FinalizeYear()
}
// 7702(f)(2)(A)
- double cv_7702 =
+ currency cv_7702 =
total_av
+ GetRefundableSalesLoad()
// + std::max(0.0, ExpRatReserve) // This would be added if it existed.
@@ -1282,12 +1282,12 @@ void AccountValue::FinalizeYear()
VariantValues().SpecAmtLoad [Year] = dblize(YearsTotalSpecAmtLoad) ;
VariantValues().PremTaxLoad [Year] = PremiumTax_->ytd_load() ;
- double notional_sep_acct_charge =
+ currency notional_sep_acct_charge =
YearsTotalSepAcctLoad
+ YearsTotalGrossIntCredited
- YearsTotalNetIntCredited
;
- VariantValues().SepAcctCharges [Year] = notional_sep_acct_charge ;
+ VariantValues().SepAcctCharges [Year] =
dblize(notional_sep_acct_charge);
// Record dynamic interest rate in ledger object.
//
diff --git a/ihs_avstrtgy.cpp b/ihs_avstrtgy.cpp
index e44a1c3..add1867 100644
--- a/ihs_avstrtgy.cpp
+++ b/ihs_avstrtgy.cpp
@@ -145,7 +145,7 @@ void AccountValue::PerformSpecAmtStrategy()
strategy = mce_sa_input_scalar;
}
currency z = CalculateSpecAmtFromStrategy(j, 0, explicit_value,
strategy);
- DeathBfts_->set_specamt(round_specamt()(std::max(m, z)), j, 1 + j);
+ DeathBfts_->set_specamt(round_specamt().c(std::max(m, z)), j, 1 + j);
if
( j == InforceYear
&& yare_input_.EffectiveDate != yare_input_.InforceAsOfDate
@@ -176,7 +176,7 @@ void AccountValue::PerformSupplAmtStrategy()
currency explicit_value = DeathBfts_->supplamt()[j];
mcenum_sa_strategy strategy =
yare_input_.SupplementalAmountStrategy[j];
currency z = CalculateSpecAmtFromStrategy(j, 0, explicit_value,
strategy);
- DeathBfts_->set_supplamt(round_specamt()(std::max(m, z)), j, 1 + j);
+ DeathBfts_->set_supplamt(round_specamt().c(std::max(m, z)), j, 1 + j);
}
}
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 0e4a256..9636791 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -962,7 +962,7 @@ currency BasicValues::GetModalPremTgtFromTable
return round_max_premium().c
(ldbl_eps_plus_one_times
(
- ( TgtPremMonthlyPolFee * 12
+ ( TgtPremMonthlyPolFee * 12.0
+ (a_specamt * MortalityRates_->TargetPremiumRates()[0])
)
/ a_mode
@@ -1136,7 +1136,11 @@ std::pair<double,double> BasicValues::approx_mly_ded
if(yare_input_.AccidentalDeathBenefit)
{
double const r = MortalityRates_->AdbRates()[year];
- mly_ded += r * std::min(specamt, AdbLimit);
+ // CURRENCY !! Here and elsewhere in this file, consider
+ // letting currency objects assume infinite values--so that
+ // 'AdbLimit' could be of currency type, and dblize() would
+ // not be needed.
+ mly_ded += r * std::min(dblize(specamt), AdbLimit);
}
if(yare_input_.SpouseRider)
@@ -1154,7 +1158,7 @@ std::pair<double,double> BasicValues::approx_mly_ded
if(true) // Written thus for parallelism and to keep 'r' local.
{
double const r = Loads_->specified_amount_load(mce_gen_curr)[year];
- mly_ded += r * std::min(specamt, SpecAmtLoadLimit);
+ mly_ded += r * std::min(dblize(specamt), SpecAmtLoadLimit);
}
mly_ded += dblize(Loads_->monthly_policy_fee(mce_gen_curr)[year]);
@@ -1168,7 +1172,7 @@ std::pair<double,double> BasicValues::approx_mly_ded
{
case oe_waiver_times_specamt:
{
- mly_ded += r * std::min(specamt, WpLimit);
+ mly_ded += r * std::min(dblize(specamt), WpLimit);
}
break;
case oe_waiver_times_deductions:
@@ -1226,7 +1230,7 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
if(yare_input_.AccidentalDeathBenefit)
{
double const r = MortalityRates_->AdbRates()[year];
- er_ded += r * std::min(specamt, AdbLimit);
+ er_ded += r * std::min(dblize(specamt), AdbLimit);
}
// Paid by ee.
@@ -1247,7 +1251,7 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
if(true) // Written thus for parallelism and to keep 'r' local.
{
double const r = Loads_->specified_amount_load(mce_gen_curr)[year];
- er_ded += r * std::min(specamt, SpecAmtLoadLimit);
+ er_ded += r * std::min(dblize(specamt), SpecAmtLoadLimit);
}
// Paid by er.
@@ -1261,7 +1265,7 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
case oe_waiver_times_specamt:
{
// Paid by er. (In this case, WP excludes term.)
- er_ded += r * std::min(specamt, WpLimit);
+ er_ded += r * std::min(dblize(specamt), WpLimit);
}
break;
case oe_waiver_times_deductions:
@@ -1556,11 +1560,11 @@ std::vector<double> const&
BasicValues::GetBandedCoiRates
{
if(UseUnusualCOIBanding && mce_gen_guar != rate_basis)
{
- if(CurrCoiTable0Limit <= a_specamt && a_specamt < CurrCoiTable1Limit)
+ if(CurrCoiTable0Limit <= dblize(a_specamt) && dblize(a_specamt) <
CurrCoiTable1Limit)
{
return MortalityRates_->MonthlyCoiRatesBand1(rate_basis);
}
- else if(CurrCoiTable1Limit <= a_specamt)
+ else if(CurrCoiTable1Limit <= dblize(a_specamt))
{
return MortalityRates_->MonthlyCoiRatesBand2(rate_basis);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [lmi] master 15ef269: Fix more currency-class issues,
Greg Chicares <=