lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5782] Refactor to facilitate reuse


From: Greg Chicares
Subject: [lmi-commits] [5782] Refactor to facilitate reuse
Date: Tue, 08 Oct 2013 22:24:35 +0000

Revision: 5782
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5782
Author:   chicares
Date:     2013-10-08 22:24:35 +0000 (Tue, 08 Oct 2013)
Log Message:
-----------
Refactor to facilitate reuse

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

Modified: lmi/trunk/gpt_test.cpp
===================================================================
--- lmi/trunk/gpt_test.cpp      2013-10-08 22:11:33 UTC (rev 5781)
+++ lmi/trunk/gpt_test.cpp      2013-10-08 22:24:35 UTC (rev 5782)
@@ -29,7 +29,6 @@
 #include "gpt_commutation_functions.hpp"
 
 #include "math_functors.hpp"
-#include "miscellany.hpp"               // stifle_warning_for_unused_value()
 #include "test_tools.hpp"
 #include "timer.hpp"
 
@@ -68,6 +67,8 @@
 }
 } // Unnamed namespace.
 
+/// Implicitly-declared special member functions do the right thing.
+
 class gpt_test
 {
   public:
@@ -86,11 +87,10 @@
 {
 }
 
-void mete_gpt_vector_parms()
+gpt_vector_parms v_parms()
 {
     static std::vector<double> zero(sample_q(0).size(), 0.0);
-    // This is not static: its construction speed is being measured.
-    volatile gpt_vector_parms z =
+    gpt_vector_parms z =
         {zero // prem_load_target
         ,zero // prem_load_excess
         ,zero // policy_fee_monthly
@@ -103,38 +103,26 @@
         ,zero // qab_child_rate
         ,zero // qab_waiver_rate
         };
-    stifle_warning_for_unused_value(z);
+    return z;
 }
 
-void mete_gpt_cf_triad()
+/// Instantiate GPT commutation functions.
+
+gpt_cf_triad instantiate_cf()
 {
     static std::vector<double> zero(sample_q(0).size(), 0.0);
-    static gpt_vector_parms parms =
-        {zero // prem_load_target
-        ,zero // prem_load_excess
-        ,zero // policy_fee_monthly
-        ,zero // policy_fee_annual
-        ,zero // specamt_load_monthly
-        ,zero // qab_gio_rate
-        ,zero // qab_adb_rate
-        ,zero // qab_term_rate
-        ,zero // qab_spouse_rate
-        ,zero // qab_child_rate
-        ,zero // qab_waiver_rate
-        };
     static unsigned int length = sample_q(0).size();
     static std::vector<double> ic(length, 
i_upper_12_over_12_from_i<double>()(0.07));
     static std::vector<double> ig(length, 
i_upper_12_over_12_from_i<double>()(0.07));
-    volatile gpt_cf_triad z(sample_q(0), ic, ig, ic, ig, parms);
-    stifle_warning_for_unused_value(z);
+    return gpt_cf_triad(sample_q(0), ic, ig, ic, ig, v_parms());
 }
 
 void gpt_test::assay_speed()
 {
     std::cout
         << "\n  Speed tests..."
-        << "\n  Init parms: " << TimeAnAliquot(mete_gpt_vector_parms)
-        << "\n  Triad     : " << TimeAnAliquot(mete_gpt_cf_triad    )
+        << "\n  Init parms: " << TimeAnAliquot(v_parms             )
+        << "\n  Triad     : " << TimeAnAliquot(instantiate_cf      )
         << std::endl
         ;
 }




reply via email to

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