[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4885] Rename 'ihs_commfns.?pp' to 'commutation_functions.
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4885] Rename 'ihs_commfns.?pp' to 'commutation_functions.?pp' |
Date: |
Sat, 01 May 2010 15:57:41 +0000 |
Revision: 4885
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4885
Author: chicares
Date: 2010-05-01 15:57:41 +0000 (Sat, 01 May 2010)
Log Message:
-----------
Rename 'ihs_commfns.?pp' to 'commutation_functions.?pp'
Modified Paths:
--------------
lmi/trunk/Makefile.am
lmi/trunk/commutation_functions_test.cpp
lmi/trunk/ihs_irc7702.cpp
lmi/trunk/mec_server.cpp
lmi/trunk/objects.make
Added Paths:
-----------
lmi/trunk/commutation_functions.cpp
lmi/trunk/commutation_functions.hpp
Removed Paths:
-------------
lmi/trunk/ihs_commfns.cpp
lmi/trunk/ihs_commfns.hpp
Modified: lmi/trunk/Makefile.am
===================================================================
--- lmi/trunk/Makefile.am 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/Makefile.am 2010-05-01 15:57:41 UTC (rev 4885)
@@ -316,6 +316,7 @@
liblmi_la_SOURCES = \
authenticity.cpp \
ce_product_name.cpp \
+ commutation_functions.cpp \
datum_base.cpp \
datum_boolean.cpp \
datum_string.cpp \
@@ -325,7 +326,6 @@
ihs_avsolve.cpp \
ihs_avstrtgy.cpp \
ihs_basicval.cpp \
- ihs_commfns.cpp \
ihs_database.cpp \
ihs_dbdict.cpp \
ihs_funddata.cpp \
@@ -514,8 +514,8 @@
test_commutation_functions_SOURCES = \
$(common_test_objects) \
- commutation_functions_test.cpp \
- ihs_commfns.cpp
+ commutation_functions.cpp \
+ commutation_functions_test.cpp
test_commutation_functions_CXXFLAGS = $(AM_CXXFLAGS)
test_comma_punct_SOURCES = \
@@ -871,6 +871,7 @@
census_view.hpp \
ce_product_name.hpp \
comma_punct.hpp \
+ commutation_functions.hpp \
config_bc551.hpp \
config_como_mingw.hpp \
config.hpp \
@@ -908,7 +909,6 @@
group_values.hpp \
handle_exceptions.hpp \
icon_monger.hpp \
- ihs_commfns.hpp \
ihs_dbdict.hpp \
ihs_funddata.hpp \
ihs_irc7702a.hpp \
Copied: lmi/trunk/commutation_functions.cpp (from rev 4821,
lmi/trunk/ihs_commfns.cpp)
===================================================================
--- lmi/trunk/commutation_functions.cpp (rev 0)
+++ lmi/trunk/commutation_functions.cpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -0,0 +1,209 @@
+// Ordinary- and universal-life commutation functions.
+//
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifdef __BORLANDC__
+# include "pchfile.hpp"
+# pragma hdrstop
+#endif // __BORLANDC__
+
+#include "commutation_functions.hpp"
+
+#include "assert_lmi.hpp"
+#include "et_vector.hpp" // [VECTORIZE]
+
+#include <algorithm> // std::rotate_copy() [VECTORIZE]
+#include <cmath> // std::pow()
+#include <functional> // std::multiplies() [VECTORIZE]
+#include <numeric> // std::partial_sum()
+
+/// Interest- and mortality-rate vectors --> commutation functions.
+///
+/// In the general case, interest rates may vary by year. Most often,
+/// they are the same for all years; but optimizing for that common
+/// special case at the cost of code complexity would probably be
+/// a mistake.
+///
+/// SOMEDAY !! Revisit the 'VECTORIZE' alternative with gcc-4.x .
+/// With gcc-3.4.5, it's twenty-five percent slower as measured by the
+/// unit test's mete_olcf().
+
+OLCommFns::OLCommFns
+ (std::vector<double> const& a_q
+ ,std::vector<double> const& a_i
+ )
+ :q(a_q)
+ ,i(a_i)
+{
+ Length = q.size();
+ LMI_ASSERT(i.size() == q.size());
+
+#if defined VECTORIZE
+ ed.resize(Length);
+ d .resize(Length);
+ c .resize(Length);
+ n .resize(Length);
+ m .resize(Length);
+
+ std::vector<double> v(Length);
+ v += 1.0 / (1.0 + i);
+
+ ed += v * (1.0 - q);
+ std::partial_sum(ed.begin(), ed.end(), ed.begin(),
std::multiplies<double>());
+
+ std::rotate_copy(ed.begin(), -1 + ed.end(), ed.end(), d.begin());
+ d[0] = 1.0;
+
+ c += d * v * q;
+#else // !defined VECTORIZE
+ d.resize(1 + Length);
+ c.resize( Length);
+ n.resize( Length);
+ m.resize( Length);
+
+ d[0] = 1.0;
+ for(int j = 0; j < Length; j++)
+ {
+ LMI_ASSERT(-1.0 != i[j]);
+ double v = 1.0 / (1.0 + i[j]);
+ double p = 1.0 - q[j];
+ c[j] = d[j] * v * q[j];
+ d[1 + j] = d[j] * v * p;
+ }
+
+ ed = d;
+ ed.erase(ed.begin());
+ d.pop_back();
+#endif // !defined VECTORIZE
+
+ std::partial_sum(d.rbegin(), d.rend(), n.rbegin());
+ std::partial_sum(c.rbegin(), c.rend(), m.rbegin());
+}
+
+OLCommFns::~OLCommFns()
+{
+}
+
+/// Interest- and mortality-rate vectors --> commutation functions.
+///
+/// Constructor arguments:
+/// a_qc Eckley's Q: mortality rates
+/// a_ic Eckley's ic: "current" interest rates
+/// a_ig Eckley's ig: "guaranteed" interest rates
+/// dbo death benefit option
+/// mode n-iversary mode
+///
+/// Numeric arguments--mortality and interest rates--must be on
+/// the mode for which commutation functions are wanted. If monthly
+/// functions are to be obtained from annual rates, convert the
+/// rates to monthly before passing them as arguments. There's more
+/// than one way to perform a modal conversion, and it's not this
+/// class's responsibility to choose.
+///
+/// The mode argument specifies the frequency of UL n-iversary
+/// processing. This is most often monthly, but need not be.
+
+ULCommFns::ULCommFns
+ (std::vector<double> const& a_qc
+ ,std::vector<double> const& a_ic
+ ,std::vector<double> const& a_ig
+ ,mcenum_dbopt dbo
+ ,mcenum_mode mode
+ )
+ :qc (a_qc)
+ ,ic (a_ic)
+ ,ig (a_ig)
+ ,dbo_ (dbo)
+ ,mode_ (mode)
+{
+ Length = qc.size();
+ LMI_ASSERT(ic.size() == qc.size());
+ LMI_ASSERT(ig.size() == qc.size());
+
+ ad.resize(1 + Length);
+ kd.resize( Length);
+ kc.resize( Length);
+ an.resize( Length);
+ km.resize( Length);
+
+ int periods_per_year = mode_;
+ int months_per_period = 12 / periods_per_year;
+
+ ad[0] = 1.0;
+ for(int j = 0; j < Length; j++)
+ {
+ LMI_ASSERT( 0.0 <= qc[j] && qc[j] <= 1.0);
+ LMI_ASSERT(-1.0 < ic[j]);
+ LMI_ASSERT( 0.0 <= ig[j]);
+ // Eckley equations (7) and (8).
+ double f = qc[j] * (1.0 + ic[j]) / (1.0 + ig[j]);
+ // f cannot be negative, so division by 1+f is safe.
+ double g = 1.0 / (1.0 + f);
+ // Eckley equation (11).
+ double i = (ic[j] + ig[j] * f) * g;
+ // Eckley equation (12).
+ double q = f * g;
+ // Eckley equation (19).
+ if(mce_option2 == dbo_)
+ {
+ i = i - q;
+ }
+ LMI_ASSERT(-1.0 != i);
+ double v = 1.0 / (1.0 + i);
+ double p = 1.0 - q;
+ // Present value of $1 one month hence.
+ double vp = v * p;
+ // Present value of $1 twelve months hence.
+ double vp12 = std::pow(vp, 12);
+ double vpn = std::pow(vp, periods_per_year);
+ // Twelve times a'' upper 12 (Eckley equations 28 and 31),
+ // determined analytically using the geometric series theorem.
+// double aa = 1.0;
+// // Eckley equation (31).
+// double sa = (1.0 - vp12) / (1.0 - std::pow(vp, 6));
+// double qa = (1.0 - vp12) / (1.0 - std::pow(vp, 3));
+// // Eckley equation (28).
+// double ma = (1.0 - vp12) / (1.0 - vp);
+ // The prefix k indicates the processing mode, which is
+ // an input parameter.
+ double ka = 1.0;
+ if(1.0 != vp)
+ {
+ ka = (1.0 - vp12) / (1.0 - std::pow(vp, months_per_period));
+ }
+ kd[j] = ka * ad[j];
+ kc[j] = ka * ad[j] * v * q;
+ ad[1 + j] = ad[j] * vpn;
+ }
+
+ ead = ad;
+ ead.erase(ead.begin());
+ ad.pop_back();
+
+ std::partial_sum(ad.rbegin(), ad.rend(), an.rbegin());
+ std::partial_sum(kc.rbegin(), kc.rend(), km.rbegin());
+}
+
+ULCommFns::~ULCommFns()
+{
+}
+
Copied: lmi/trunk/commutation_functions.hpp (from rev 4821,
lmi/trunk/ihs_commfns.hpp)
===================================================================
--- lmi/trunk/commutation_functions.hpp (rev 0)
+++ lmi/trunk/commutation_functions.hpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -0,0 +1,129 @@
+// Ordinary- and universal-life commutation functions.
+//
+// Copyright (C) 1998, 1999, 2000, 2001, 2005, 2006, 2007, 2008, 2009, 2010
Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifndef commutation_functions_hpp
+#define commutation_functions_hpp
+
+#include "config.hpp"
+
+#include "mc_enum_type_enums.hpp"
+#include "obstruct_slicing.hpp"
+#include "so_attributes.hpp"
+
+#include <boost/utility.hpp>
+
+#include <vector>
+
+/// Ordinary-life commutation functions.
+
+class LMI_SO OLCommFns
+ :private boost::noncopyable
+ ,virtual private obstruct_slicing<OLCommFns>
+{
+ public:
+ OLCommFns
+ (std::vector<double> const& a_q
+ ,std::vector<double> const& a_i
+ );
+
+ ~OLCommFns();
+
+ double Domega() const {return ed.back();}
+ std::vector<double> const& ED() const {return ed;}
+ std::vector<double> const& D() const {return d;}
+ std::vector<double> const& C() const {return c;}
+ std::vector<double> const& N() const {return n;}
+ std::vector<double> const& M() const {return m;}
+
+ private:
+ int Length;
+
+ std::vector<double> const& q;
+ std::vector<double> const& i;
+
+ std::vector<double> ed;
+ std::vector<double> d;
+ std::vector<double> c;
+ std::vector<double> n;
+ std::vector<double> m;
+};
+
+/// Universal-life commutation functions: Eckley, TSA XXXIX, page 18.
+///
+/// All commutation functions are calculated on the mode specified
+/// by mode_. Annual D and N are always also calculated because
+/// premiums are often paid annually. Use monthly D and N for
+/// monthly deductions in the numerator of an actuarial function,
+/// but use their annual analogs in the denominator when premiums
+/// are assumed to be paid annually. C and M have no such analogs
+/// because no contract pays claims only at year end.
+///
+/// Accessors have names like aD() for the always-annual Dx, versus
+/// kD() for the modal Dx. The 'k-' prefix signifies that the mode is
+/// k-ly, for mode parameter k; 'm-' might seem more clearly to stand
+/// for "modal", but would too easily be taken as connoting "monthly".
+
+class LMI_SO ULCommFns
+ :private boost::noncopyable
+ ,virtual private obstruct_slicing<ULCommFns>
+{
+ public:
+ ULCommFns
+ (std::vector<double> const& a_qc
+ ,std::vector<double> const& a_ic
+ ,std::vector<double> const& a_ig
+ ,mcenum_dbopt dbo
+ ,mcenum_mode mode
+ );
+
+ ~ULCommFns();
+
+ double aDomega() const {return ead.back();}
+ std::vector<double> const& EaD() const {return ead;}
+ std::vector<double> const& aD() const {return ad;}
+ std::vector<double> const& kD() const {return kd;}
+ std::vector<double> const& kC() const {return kc;}
+ std::vector<double> const& aN() const {return an;}
+ std::vector<double> const& kM() const {return km;}
+
+ private:
+ std::vector<double> qc;
+ std::vector<double> ic;
+ std::vector<double> ig;
+
+ // SOMEDAY !! It would be nice to let dbo_ vary by year.
+ mcenum_dbopt dbo_;
+ mcenum_mode mode_;
+
+ int Length;
+
+ std::vector<double> ead;
+ std::vector<double> ad;
+ std::vector<double> kd;
+ std::vector<double> kc;
+ std::vector<double> an;
+ std::vector<double> km;
+};
+
+#endif // commutation_functions_hpp
+
Modified: lmi/trunk/commutation_functions_test.cpp
===================================================================
--- lmi/trunk/commutation_functions_test.cpp 2010-05-01 13:14:15 UTC (rev
4884)
+++ lmi/trunk/commutation_functions_test.cpp 2010-05-01 15:57:41 UTC (rev
4885)
@@ -26,7 +26,7 @@
# pragma hdrstop
#endif // __BORLANDC__
-#include "ihs_commfns.hpp"
+#include "commutation_functions.hpp"
#include "et_vector.hpp"
#include "math_functors.hpp"
Deleted: lmi/trunk/ihs_commfns.cpp
===================================================================
--- lmi/trunk/ihs_commfns.cpp 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/ihs_commfns.cpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -1,209 +0,0 @@
-// Ordinary- and universal-life commutation functions.
-//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009, 2010 Gregory W. Chicares.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-//
-// http://savannah.nongnu.org/projects/lmi
-// email: <address@hidden>
-// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-
-// $Id$
-
-#ifdef __BORLANDC__
-# include "pchfile.hpp"
-# pragma hdrstop
-#endif // __BORLANDC__
-
-#include "ihs_commfns.hpp"
-
-#include "assert_lmi.hpp"
-#include "et_vector.hpp" // [VECTORIZE]
-
-#include <algorithm> // std::rotate_copy() [VECTORIZE]
-#include <cmath> // std::pow()
-#include <functional> // std::multiplies() [VECTORIZE]
-#include <numeric> // std::partial_sum()
-
-/// Interest- and mortality-rate vectors --> commutation functions.
-///
-/// In the general case, interest rates may vary by year. Most often,
-/// they are the same for all years; but optimizing for that common
-/// special case at the cost of code complexity would probably be
-/// a mistake.
-///
-/// SOMEDAY !! Revisit the 'VECTORIZE' alternative with gcc-4.x .
-/// With gcc-3.4.5, it's twenty-five percent slower as measured by the
-/// unit test's mete_olcf().
-
-OLCommFns::OLCommFns
- (std::vector<double> const& a_q
- ,std::vector<double> const& a_i
- )
- :q(a_q)
- ,i(a_i)
-{
- Length = q.size();
- LMI_ASSERT(i.size() == q.size());
-
-#if defined VECTORIZE
- ed.resize(Length);
- d .resize(Length);
- c .resize(Length);
- n .resize(Length);
- m .resize(Length);
-
- std::vector<double> v(Length);
- v += 1.0 / (1.0 + i);
-
- ed += v * (1.0 - q);
- std::partial_sum(ed.begin(), ed.end(), ed.begin(),
std::multiplies<double>());
-
- std::rotate_copy(ed.begin(), -1 + ed.end(), ed.end(), d.begin());
- d[0] = 1.0;
-
- c += d * v * q;
-#else // !defined VECTORIZE
- d.resize(1 + Length);
- c.resize( Length);
- n.resize( Length);
- m.resize( Length);
-
- d[0] = 1.0;
- for(int j = 0; j < Length; j++)
- {
- LMI_ASSERT(-1.0 != i[j]);
- double v = 1.0 / (1.0 + i[j]);
- double p = 1.0 - q[j];
- c[j] = d[j] * v * q[j];
- d[1 + j] = d[j] * v * p;
- }
-
- ed = d;
- ed.erase(ed.begin());
- d.pop_back();
-#endif // !defined VECTORIZE
-
- std::partial_sum(d.rbegin(), d.rend(), n.rbegin());
- std::partial_sum(c.rbegin(), c.rend(), m.rbegin());
-}
-
-OLCommFns::~OLCommFns()
-{
-}
-
-/// Interest- and mortality-rate vectors --> commutation functions.
-///
-/// Constructor arguments:
-/// a_qc Eckley's Q: mortality rates
-/// a_ic Eckley's ic: "current" interest rates
-/// a_ig Eckley's ig: "guaranteed" interest rates
-/// dbo death benefit option
-/// mode n-iversary mode
-///
-/// Numeric arguments--mortality and interest rates--must be on
-/// the mode for which commutation functions are wanted. If monthly
-/// functions are to be obtained from annual rates, convert the
-/// rates to monthly before passing them as arguments. There's more
-/// than one way to perform a modal conversion, and it's not this
-/// class's responsibility to choose.
-///
-/// The mode argument specifies the frequency of UL n-iversary
-/// processing. This is most often monthly, but need not be.
-
-ULCommFns::ULCommFns
- (std::vector<double> const& a_qc
- ,std::vector<double> const& a_ic
- ,std::vector<double> const& a_ig
- ,mcenum_dbopt dbo
- ,mcenum_mode mode
- )
- :qc (a_qc)
- ,ic (a_ic)
- ,ig (a_ig)
- ,dbo_ (dbo)
- ,mode_ (mode)
-{
- Length = qc.size();
- LMI_ASSERT(ic.size() == qc.size());
- LMI_ASSERT(ig.size() == qc.size());
-
- ad.resize(1 + Length);
- kd.resize( Length);
- kc.resize( Length);
- an.resize( Length);
- km.resize( Length);
-
- int periods_per_year = mode_;
- int months_per_period = 12 / periods_per_year;
-
- ad[0] = 1.0;
- for(int j = 0; j < Length; j++)
- {
- LMI_ASSERT( 0.0 <= qc[j] && qc[j] <= 1.0);
- LMI_ASSERT(-1.0 < ic[j]);
- LMI_ASSERT( 0.0 <= ig[j]);
- // Eckley equations (7) and (8).
- double f = qc[j] * (1.0 + ic[j]) / (1.0 + ig[j]);
- // f cannot be negative, so division by 1+f is safe.
- double g = 1.0 / (1.0 + f);
- // Eckley equation (11).
- double i = (ic[j] + ig[j] * f) * g;
- // Eckley equation (12).
- double q = f * g;
- // Eckley equation (19).
- if(mce_option2 == dbo_)
- {
- i = i - q;
- }
- LMI_ASSERT(-1.0 != i);
- double v = 1.0 / (1.0 + i);
- double p = 1.0 - q;
- // Present value of $1 one month hence.
- double vp = v * p;
- // Present value of $1 twelve months hence.
- double vp12 = std::pow(vp, 12);
- double vpn = std::pow(vp, periods_per_year);
- // Twelve times a'' upper 12 (Eckley equations 28 and 31),
- // determined analytically using the geometric series theorem.
-// double aa = 1.0;
-// // Eckley equation (31).
-// double sa = (1.0 - vp12) / (1.0 - std::pow(vp, 6));
-// double qa = (1.0 - vp12) / (1.0 - std::pow(vp, 3));
-// // Eckley equation (28).
-// double ma = (1.0 - vp12) / (1.0 - vp);
- // The prefix k indicates the processing mode, which is
- // an input parameter.
- double ka = 1.0;
- if(1.0 != vp)
- {
- ka = (1.0 - vp12) / (1.0 - std::pow(vp, months_per_period));
- }
- kd[j] = ka * ad[j];
- kc[j] = ka * ad[j] * v * q;
- ad[1 + j] = ad[j] * vpn;
- }
-
- ead = ad;
- ead.erase(ead.begin());
- ad.pop_back();
-
- std::partial_sum(ad.rbegin(), ad.rend(), an.rbegin());
- std::partial_sum(kc.rbegin(), kc.rend(), km.rbegin());
-}
-
-ULCommFns::~ULCommFns()
-{
-}
-
Deleted: lmi/trunk/ihs_commfns.hpp
===================================================================
--- lmi/trunk/ihs_commfns.hpp 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/ihs_commfns.hpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -1,129 +0,0 @@
-// Ordinary- and universal-life commutation functions.
-//
-// Copyright (C) 1998, 1999, 2000, 2001, 2005, 2006, 2007, 2008, 2009, 2010
Gregory W. Chicares.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-//
-// http://savannah.nongnu.org/projects/lmi
-// email: <address@hidden>
-// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-
-// $Id$
-
-#ifndef ihs_commfns_hpp
-#define ihs_commfns_hpp
-
-#include "config.hpp"
-
-#include "mc_enum_type_enums.hpp"
-#include "obstruct_slicing.hpp"
-#include "so_attributes.hpp"
-
-#include <boost/utility.hpp>
-
-#include <vector>
-
-/// Ordinary-life commutation functions.
-
-class LMI_SO OLCommFns
- :private boost::noncopyable
- ,virtual private obstruct_slicing<OLCommFns>
-{
- public:
- OLCommFns
- (std::vector<double> const& a_q
- ,std::vector<double> const& a_i
- );
-
- ~OLCommFns();
-
- double Domega() const {return ed.back();}
- std::vector<double> const& ED() const {return ed;}
- std::vector<double> const& D() const {return d;}
- std::vector<double> const& C() const {return c;}
- std::vector<double> const& N() const {return n;}
- std::vector<double> const& M() const {return m;}
-
- private:
- int Length;
-
- std::vector<double> const& q;
- std::vector<double> const& i;
-
- std::vector<double> ed;
- std::vector<double> d;
- std::vector<double> c;
- std::vector<double> n;
- std::vector<double> m;
-};
-
-/// Universal-life commutation functions: Eckley, TSA XXXIX, page 18.
-///
-/// All commutation functions are calculated on the mode specified
-/// by mode_. Annual D and N are always also calculated because
-/// premiums are often paid annually. Use monthly D and N for
-/// monthly deductions in the numerator of an actuarial function,
-/// but use their annual analogs in the denominator when premiums
-/// are assumed to be paid annually. C and M have no such analogs
-/// because no contract pays claims only at year end.
-///
-/// Accessors have names like aD() for the always-annual Dx, versus
-/// kD() for the modal Dx. The 'k-' prefix signifies that the mode is
-/// k-ly, for mode parameter k; 'm-' might seem more clearly to stand
-/// for "modal", but would too easily be taken as connoting "monthly".
-
-class LMI_SO ULCommFns
- :private boost::noncopyable
- ,virtual private obstruct_slicing<ULCommFns>
-{
- public:
- ULCommFns
- (std::vector<double> const& a_qc
- ,std::vector<double> const& a_ic
- ,std::vector<double> const& a_ig
- ,mcenum_dbopt dbo
- ,mcenum_mode mode
- );
-
- ~ULCommFns();
-
- double aDomega() const {return ead.back();}
- std::vector<double> const& EaD() const {return ead;}
- std::vector<double> const& aD() const {return ad;}
- std::vector<double> const& kD() const {return kd;}
- std::vector<double> const& kC() const {return kc;}
- std::vector<double> const& aN() const {return an;}
- std::vector<double> const& kM() const {return km;}
-
- private:
- std::vector<double> qc;
- std::vector<double> ic;
- std::vector<double> ig;
-
- // SOMEDAY !! It would be nice to let dbo_ vary by year.
- mcenum_dbopt dbo_;
- mcenum_mode mode_;
-
- int Length;
-
- std::vector<double> ead;
- std::vector<double> ad;
- std::vector<double> kd;
- std::vector<double> kc;
- std::vector<double> an;
- std::vector<double> km;
-};
-
-#endif // ihs_commfns_hpp
-
Modified: lmi/trunk/ihs_irc7702.cpp
===================================================================
--- lmi/trunk/ihs_irc7702.cpp 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/ihs_irc7702.cpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -30,7 +30,7 @@
#include "alert.hpp"
#include "basic_values.hpp" // For target-premium callback.
-#include "ihs_commfns.hpp"
+#include "commutation_functions.hpp"
#include "materially_equal.hpp"
#include "zero.hpp"
Modified: lmi/trunk/mec_server.cpp
===================================================================
--- lmi/trunk/mec_server.cpp 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/mec_server.cpp 2010-05-01 15:57:41 UTC (rev 4885)
@@ -32,12 +32,12 @@
#include "alert.hpp"
#include "assert_lmi.hpp"
#include "basic_values.hpp" // lowest_premium_tax_load()
+#include "commutation_functions.hpp"
#include "configurable_settings.hpp"
#include "data_directory.hpp"
#include "database.hpp"
#include "dbnames.hpp"
#include "et_vector.hpp"
-#include "ihs_commfns.hpp"
#include "ihs_irc7702a.hpp"
#include "materially_equal.hpp"
#include "math_functors.hpp"
Modified: lmi/trunk/objects.make
===================================================================
--- lmi/trunk/objects.make 2010-05-01 13:14:15 UTC (rev 4884)
+++ lmi/trunk/objects.make 2010-05-01 15:57:41 UTC (rev 4885)
@@ -266,13 +266,13 @@
lmi_common_objects := \
$(common_common_objects) \
authenticity.o \
+ commutation_functions.o \
ihs_acctval.o \
ihs_avdebug.o \
ihs_avmly.o \
ihs_avsolve.o \
ihs_avstrtgy.o \
ihs_basicval.o \
- ihs_commfns.o \
ihs_database.o \
ihs_dbdict.o \
ihs_funddata.o \
@@ -370,6 +370,7 @@
alert_cli.o \
calendar_date.o \
ce_product_name.o \
+ commutation_functions.o \
configurable_settings.o \
crc32.o \
data_directory.o \
@@ -383,7 +384,6 @@
fenv_lmi.o \
global_settings.o \
ihs_basicval.o \
- ihs_commfns.o \
ihs_database.o \
ihs_dbdict.o \
ihs_funddata.o \
@@ -448,8 +448,8 @@
authenticity_test \
calendar_date_test \
callback_test \
+ comma_punct_test \
commutation_functions_test \
- comma_punct_test \
crc32_test \
expression_template_0_test \
fenv_lmi_test \
@@ -568,17 +568,17 @@
$(common_test_objects) \
callback_test.o \
+comma_punct_test$(EXEEXT): \
+ $(common_test_objects) \
+ comma_punct_test.o \
+
commutation_functions_test$(EXEEXT): \
$(common_test_objects) \
+ commutation_functions.o \
commutation_functions_test.o \
expm1.o \
- ihs_commfns.o \
timer.o \
-comma_punct_test$(EXEEXT): \
- $(common_test_objects) \
- comma_punct_test.o \
-
crc32_test$(EXEEXT): \
$(common_test_objects) \
crc32.o \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4885] Rename 'ihs_commfns.?pp' to 'commutation_functions.?pp',
Greg Chicares <=