lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master e361845 1/2: Make 7702 statutory rates scalar


From: Greg Chicares
Subject: [lmi-commits] [lmi] master e361845 1/2: Make 7702 statutory rates scalar
Date: Fri, 12 Mar 2021 06:32:47 -0500 (EST)

branch: master
commit e361845cd8ad74b7b0b54f0db9ddfde9149395ea
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Make 7702 statutory rates scalar
    
    This revision causes regressions in 'Irc7702NetGSP' only, the largest
    |absolute| and |relative| errors being 8.67362e-19 and 1.85737e-16,
    respectively. That's 1 ulp, DBL_EPSILON being 2.2204460492503131E-16.
    
    It's plausible that GSP is affected while GLP is not because the
    statutory rate is 'X' in these formulas:
       GLP = Max(       X, Y) - Z
       GSP = Max(0.02 + X, Y) - Z
    and 'Y' may dominate in the first but not the second. Alternatively,
    given that X is 0.04 in all affected testcases, perhaps 0.04 rounds
    one way while 0.06 rounds another way when popped from an 80-bit x87
    register, and changing X from vector to scalar removes a needless
    round trip through the x87.
---
 i7702.cpp | 12 ++++++------
 i7702.hpp |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/i7702.cpp b/i7702.cpp
index 288d80e..cdc21a6 100644
--- a/i7702.cpp
+++ b/i7702.cpp
@@ -172,8 +172,8 @@
 ///     use contractual rates if greater
 
 i7702::i7702
-    (std::vector<double> const& A0
-    ,std::vector<double> const& A1
+    (double                     A0
+    ,double                     A1
     ,std::vector<double> const& Bgen
     ,std::vector<double> const& Bsep
     ,std::vector<double> const& Bflr
@@ -211,8 +211,8 @@ i7702::i7702
     (product_database   const& database
     ,stratified_charges const& stratified
     )
-    :A0_   (database.length())
-    ,A1_   (database.length())
+    :A0_   {}
+    ,A1_   {}
     ,Bgen_ (database.length())
     ,Bsep_ (database.length())
     ,Bflr_ (database.length())
@@ -235,7 +235,7 @@ i7702::i7702
     // DCV calculations in the account value class as well as
     // GPT calculations in the 7702 class.
 
-    database.query_into(DB_AnnInterestRate7702, A0_);
+    A0_ = database.query<double>(DB_AnnInterestRate7702);
 
     database.query_into(DB_GuarInt, Bgen_);
 
@@ -339,7 +339,7 @@ i7702::i7702
     std::vector<double> operative_naar_discount(database.length(), 0.0);
     operative_naar_discount +=
         Max
-            (apply_unary(i_upper_12_over_12_from_i<double>(), A0_)
+            (i_upper_12_over_12_from_i<double>()(A0_)
             ,Max(Em_, theoretical_naar_discount)
             );
     ig_ = no_naar_discount ? zero : operative_naar_discount;
diff --git a/i7702.hpp b/i7702.hpp
index 0b045f2..82b50c1 100644
--- a/i7702.hpp
+++ b/i7702.hpp
@@ -53,8 +53,8 @@ class LMI_SO i7702 final
   private:
     // Private ctor for unit test.
     i7702
-        (std::vector<double> const& A0
-        ,std::vector<double> const& A1
+        (double                     A0
+        ,double                     A1
         ,std::vector<double> const& Bgen
         ,std::vector<double> const& Bsep
         ,std::vector<double> const& Bflr
@@ -75,8 +75,8 @@ class LMI_SO i7702 final
     // Parameters from product database--member names are
     // capitalized to match formulas in documentation, but
     // suffixed to mark them as members.
-    std::vector<double> A0_   ;
-    std::vector<double> A1_   ;
+    double              A0_   ;
+    double              A1_   ;
     std::vector<double> Bgen_ ;
     std::vector<double> Bsep_ ;
     std::vector<double> Bflr_ ;



reply via email to

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