lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5473] Permit switching between implementations, with bina


From: Greg Chicares
Subject: [lmi-commits] [5473] Permit switching between implementations, with binary as the default
Date: Mon, 28 May 2012 11:21:20 +0000

Revision: 5473
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5473
Author:   chicares
Date:     2012-05-28 11:21:19 +0000 (Mon, 28 May 2012)
Log Message:
-----------
Permit switching between implementations, with binary as the default

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/actuarial_table.cpp
    lmi/trunk/actuarial_table.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2012-05-28 09:49:37 UTC (rev 5472)
+++ lmi/trunk/ChangeLog 2012-05-28 11:21:19 UTC (rev 5473)
@@ -30144,3 +30144,20 @@
 Compile table-migration tools; fix compiler diagnostics. See, e.g.:
   http://lists.nongnu.org/archive/html/lmi/2012-05/msg00013.html
 
+20120528T0949Z <address@hidden> [578]
+
+  actuarial_table.cpp
+Test binary and xml implementations against each other (VS). See:
+  http://lists.nongnu.org/archive/html/lmi/2012-05/msg00015.html
+
+20120528T1121Z <address@hidden> [578]
+
+  actuarial_table.cpp
+  actuarial_table.hpp
+Permit switching between implementations, with binary as the default.
+This default shields production from temporary effects of the xml
+implementation (some small numerical differences in system testing,
+and a performance issue discussed here:
+  http://lists.nongnu.org/archive/html/lmi/2012-05/msg00018.html
+) while xml development continues.
+

Modified: lmi/trunk/actuarial_table.cpp
===================================================================
--- lmi/trunk/actuarial_table.cpp       2012-05-28 09:49:37 UTC (rev 5472)
+++ lmi/trunk/actuarial_table.cpp       2012-05-28 11:21:19 UTC (rev 5473)
@@ -180,7 +180,7 @@
         }
 }
 
-actuarial_table::actuarial_table(std::string const& filename, int table_number)
+xml_actuarial_table::xml_actuarial_table(std::string const& filename, int 
table_number)
 {
     // SOA !! This is temporary code for API compatibility with 
soa_actuarial_table.
     // It should be changed so that the constructor takes only a single
@@ -192,11 +192,11 @@
     load_xml_table(xmlfile);
 }
 
-actuarial_table::~actuarial_table()
+xml_actuarial_table::~xml_actuarial_table()
 {
 }
 
-void actuarial_table::load_xml_table(std::string const& filename)
+void xml_actuarial_table::load_xml_table(std::string const& filename)
 {
     xml_lmi::dom_parser parser(filename);
     xml::element root(parser.root_node("table"));
@@ -232,7 +232,7 @@
         }
 }
 
-void actuarial_table::load_xml_table_with_ages
+void xml_actuarial_table::load_xml_table_with_ages
     (xml::element const& node
     ,std::vector<double>& data
     ,int& min_age
@@ -281,7 +281,7 @@
     LMI_ASSERT(data.size() == size_t(max_age - min_age + 1));
 }
 
-void actuarial_table::load_xml_aggregate_table(xml::element const& node)
+void xml_actuarial_table::load_xml_aggregate_table(xml::element const& node)
 {
     load_xml_table_with_ages
         (node
@@ -293,7 +293,7 @@
     table_type_ = e_table_aggregate;
 }
 
-void actuarial_table::load_xml_duration_table(xml::element const& node)
+void xml_actuarial_table::load_xml_duration_table(xml::element const& node)
 {
     xml::const_nodes_view const values = node.elements("value");
 
@@ -308,7 +308,7 @@
     table_type_ = e_table_duration;
 }
 
-void actuarial_table::load_xml_select_table(xml::element const& node)
+void xml_actuarial_table::load_xml_select_table(xml::element const& node)
 {
     xml::const_nodes_view const rows = node.elements("row");
 
@@ -384,7 +384,7 @@
     table_type_ = e_table_select_and_ultimate;
 }
 
-void actuarial_table::load_xml_select_and_ultimate_table(xml::element const& 
node)
+void xml_actuarial_table::load_xml_select_and_ultimate_table(xml::element 
const& node)
 {
     load_xml_select_table(*xml_lmi::retrieve_element(node, "select"));
 
@@ -411,7 +411,7 @@
     table_type_ = e_table_select_and_ultimate;
 }
 
-std::vector<double> actuarial_table::specific_values
+std::vector<double> xml_actuarial_table::specific_values
     (int issue_age
     ,int length
     ) const
@@ -935,7 +935,8 @@
     ,int                length
     )
 {
-    actuarial_table     z    (table_filename, table_number);
+#if defined LMI_USE_XML_TABLES
+    xml_actuarial_table     z(table_filename, table_number);
     soa_actuarial_table z_soa(table_filename, table_number);
 
     std::vector<double> values    (z.values(issue_age, length));
@@ -945,11 +946,11 @@
     // remove this once satisfied
     LMI_ASSERT(almost_equal_doubles(values, values_soa));
     return values;
-#if 0
+#else  // !defined LMI_USE_XML_TABLES
 // SOA !! Ultimately, there will be only one class:
     actuarial_table z(table_filename, table_number);
     return z.values(issue_age, length);
-#endif // 0
+#endif // !defined LMI_USE_XML_TABLES
 }
 
 std::vector<double> actuarial_table_rates_elaborated
@@ -962,7 +963,8 @@
     ,int                      reset_duration
     )
 {
-    actuarial_table     z    (table_filename, table_number);
+#if defined LMI_USE_XML_TABLES
+    xml_actuarial_table     z(table_filename, table_number);
     soa_actuarial_table z_soa(table_filename, table_number);
 
     std::vector<double> values(z.values_elaborated
@@ -984,7 +986,7 @@
     // remove this once satisfied
     LMI_ASSERT(almost_equal_doubles(values, values_soa));
     return values;
-#if 0
+#else  // !defined LMI_USE_XML_TABLES
 // SOA !! Ultimately, there will be only one class:
     actuarial_table z(table_filename, table_number);
     return z.values_elaborated
@@ -994,6 +996,6 @@
         ,inforce_duration
         ,reset_duration
         );
-#endif // 0
+#endif // !defined LMI_USE_XML_TABLES
 }
 

Modified: lmi/trunk/actuarial_table.hpp
===================================================================
--- lmi/trunk/actuarial_table.hpp       2012-05-28 09:49:37 UTC (rev 5472)
+++ lmi/trunk/actuarial_table.hpp       2012-05-28 11:21:19 UTC (rev 5473)
@@ -163,14 +163,14 @@
 
 /// Read actuarial table from XML file.
 
-class actuarial_table
+class xml_actuarial_table
     :        public  actuarial_table_base
-    ,        private lmi::uncopyable <actuarial_table>
-    ,virtual private obstruct_slicing<actuarial_table>
+    ,        private lmi::uncopyable <xml_actuarial_table>
+    ,virtual private obstruct_slicing<xml_actuarial_table>
 {
   public:
-    actuarial_table(std::string const& filename, int table_number);
-    ~actuarial_table();
+    xml_actuarial_table(std::string const& filename, int table_number);
+    ~xml_actuarial_table();
 
   protected:
     std::vector<double> specific_values(int issue_age, int length) const;
@@ -269,5 +269,13 @@
     ,int                      reset_duration
     );
 
+// #define LMI_USE_XML_TABLES
+
+#if defined LMI_USE_XML_TABLES
+typedef xml_actuarial_table actuarial_table;
+#else  // !defined LMI_USE_XML_TABLES
+typedef soa_actuarial_table actuarial_table;
+#endif // !defined LMI_USE_XML_TABLES
+
 #endif // actuarial_table_hpp
 




reply via email to

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