lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5800] Introduce a valuable invariant


From: Greg Chicares
Subject: [lmi-commits] [5800] Introduce a valuable invariant
Date: Fri, 18 Oct 2013 12:08:13 +0000

Revision: 5800
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5800
Author:   chicares
Date:     2013-10-18 12:08:12 +0000 (Fri, 18 Oct 2013)
Log Message:
-----------
Introduce a valuable invariant

Modified Paths:
--------------
    lmi/trunk/gpt_test.cpp
    lmi/trunk/stl_extensions.hpp

Modified: lmi/trunk/gpt_test.cpp
===================================================================
--- lmi/trunk/gpt_test.cpp      2013-10-18 11:52:11 UTC (rev 5799)
+++ lmi/trunk/gpt_test.cpp      2013-10-18 12:08:12 UTC (rev 5800)
@@ -32,6 +32,7 @@
 #include "assert_lmi.hpp"
 #include "materially_equal.hpp"
 #include "math_functors.hpp"
+#include "stl_extensions.hpp"           // nonstd::iota()
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -128,7 +129,8 @@
 /// distinct primes, to make it easier to track down any discrepancy.
 ///
 /// In order to expose problems that uniform values would mask, each
-/// vector's first element is altered if necessary.
+/// vector is altered if necessary--such that v[x]+t == v[x+t], so
+/// that the same invariant may be tested for premiums.
 
 void gpt_test::initialize(int issue_age)
 {
@@ -152,22 +154,25 @@
     qab_child_rate       .assign(length,  0.000023);
     qab_waiver_rate      .assign(length,  0.000029);
 
-    LMI_ASSERT(0 < length);
-    glp_ic               [0] *= 1.01;
-    glp_ig               [0] *= 1.01;
-    gsp_ic               [0] *= 1.01;
-    gsp_ig               [0] *= 1.01;
-    prem_load_target     [0] *= 1.01;
-    prem_load_excess     [0] *= 1.01;
-    policy_fee_monthly   [0] *= 1.01;
-    policy_fee_annual    [0] *= 1.01;
-    specamt_load_monthly [0] *= 1.01;
-    qab_gio_rate         [0] *= 1.01;
-    qab_adb_rate         [0] *= 1.01;
-    qab_term_rate        [0] *= 1.01;
-    qab_spouse_rate      [0] *= 1.01;
-    qab_child_rate       [0] *= 1.01;
-    qab_waiver_rate      [0] *= 1.01;
+    std::vector<int>    iota_i(length);
+    nonstd::iota(iota_i.begin(), iota_i.end(), issue_age);
+    std::vector<double> iota_d(length, 0.0);
+    iota_d += 1.0 + 0.001 * iota_i;
+    glp_ic               *= iota_d;
+    glp_ig               *= iota_d;
+    gsp_ic               *= iota_d;
+    gsp_ig               *= iota_d;
+    prem_load_target     *= iota_d;
+    prem_load_excess     *= iota_d;
+    policy_fee_monthly   *= iota_d;
+    policy_fee_annual    *= iota_d;
+    specamt_load_monthly *= iota_d;
+    qab_gio_rate         *= iota_d;
+    qab_adb_rate         *= iota_d;
+    qab_term_rate        *= iota_d;
+    qab_spouse_rate      *= iota_d;
+    qab_child_rate       *= iota_d;
+    qab_waiver_rate      *= iota_d;
 }
 
 /// Instantiate vector parameters from globals set by initialize().

Modified: lmi/trunk/stl_extensions.hpp
===================================================================
--- lmi/trunk/stl_extensions.hpp        2013-10-18 11:52:11 UTC (rev 5799)
+++ lmi/trunk/stl_extensions.hpp        2013-10-18 12:08:12 UTC (rev 5800)
@@ -119,6 +119,19 @@
 
     return true;
 }
+
+template<typename ForwardIterator, typename T>
+void iota
+    (ForwardIterator first
+    ,ForwardIterator last
+    ,T               value
+    )
+{
+    while(first != last)
+        {
+        *first++ = value++;
+        }
+}
 } // namespace nonstd
 
 #endif // stl_extensions_hpp




reply via email to

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