lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 2c0ec871 07/11: Use lmi rather than std funct


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 2c0ec871 07/11: Use lmi rather than std functions
Date: Thu, 26 May 2022 18:14:25 -0400 (EDT)

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

    Use lmi rather than std functions
    
    Throughout the "Actuarial functions" section, replaced
      std::expm1() --> lmi::expm1()
      std::log1p() --> lmi::log1p()
---
 Makefile.am        | 36 ++++++++++++++++++++++++++++++------
 math_functions.hpp | 18 +++++++++---------
 objects.make       | 24 ++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 15 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5874d2e6..83751ab4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -340,6 +340,8 @@ liblmi_common_sources = \
     death_benefits.cpp \
     emit_ledger.cpp \
     facets.cpp \
+    fdlibm_expm1.c \
+    fdlibm_log1p.c \
     fenv_guard.cpp \
     fenv_lmi.cpp \
     file_command.cpp \
@@ -370,6 +372,7 @@ liblmi_common_sources = \
     ledgervalues.cpp \
     license.cpp \
     loads.cpp \
+    math_functions.cpp \
     mc_enum.cpp \
     mc_enum_types.cpp \
     mc_enum_types_aux.cpp \
@@ -650,7 +653,10 @@ comma_punct_test_LDADD = \
 commutation_functions_test_SOURCES = \
   commutation_functions.cpp \
   commutation_functions_test.cpp \
-  cso_table.cpp
+  cso_table.cpp \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
+  math_functions.cpp
 commutation_functions_test_CXXFLAGS = $(AM_CXXFLAGS)
 commutation_functions_test_LDADD = \
   libtest_common.la
@@ -734,9 +740,12 @@ global_settings_test_LDADD = \
 gpt_cf_triad_test_SOURCES = \
   commutation_functions.cpp \
   cso_table.cpp \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   gpt_cf_triad_test.cpp \
   gpt_commutation_functions.cpp \
-  ihs_irc7702.cpp
+  ihs_irc7702.cpp \
+  math_functions.cpp
 gpt_cf_triad_test_CXXFLAGS = $(AM_CXXFLAGS)
 gpt_cf_triad_test_LDADD = \
   libtest_common.la
@@ -744,9 +753,12 @@ gpt_cf_triad_test_LDADD = \
 gpt_test_SOURCES = \
   commutation_functions.cpp \
   cso_table.cpp \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   gpt7702.cpp \
   gpt_commutation_functions.cpp \
-  gpt_test.cpp
+  gpt_test.cpp \
+  math_functions.cpp
 gpt_test_CXXFLAGS = $(AM_CXXFLAGS)
 gpt_test_LDADD = \
   libtest_common.la
@@ -755,8 +767,11 @@ handle_exceptions_test_LDADD = \
   libtest_common.la
 
 i7702_test_SOURCES = \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   i7702.cpp \
-  i7702_test.cpp
+  i7702_test.cpp \
+  math_functions.cpp
 i7702_test_CXXFLAGS = $(AM_CXXFLAGS)
 i7702_test_LDADD = \
   libtest_common.la
@@ -821,8 +836,11 @@ interpolate_string_test_LDADD = \
 irc7702_tables_test_SOURCES = \
   commutation_functions.cpp \
   cso_table.cpp \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   irc7702_tables.cpp \
-  irc7702_tables_test.cpp
+  irc7702_tables_test.cpp \
+  math_functions.cpp
 irc7702_tables_test_CXXFLAGS = $(AM_CXXFLAGS)
 irc7702_tables_test_LDADD = \
   libtest_common.la
@@ -863,8 +881,11 @@ ledger_test_LDADD = \
   $(XMLWRAPP_LIBS)
 
 loads_test_SOURCES = \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   loads.cpp \
-  loads_test.cpp
+  loads_test.cpp \
+  math_functions.cpp
 loads_test_CXXFLAGS = $(AM_CXXFLAGS)
 loads_test_LDADD = \
   libtest_common.la
@@ -909,7 +930,10 @@ monnaie_test_LDADD = \
   libtest_common.la
 
 mortality_rates_test_SOURCES = \
+  fdlibm_expm1.c \
+  fdlibm_log1p.c \
   ihs_mortal.cpp \
+  math_functions.cpp \
   mortality_rates_test.cpp
 mortality_rates_test_CXXFLAGS = $(AM_CXXFLAGS)
 mortality_rates_test_LDADD = \
diff --git a/math_functions.hpp b/math_functions.hpp
index f6f7a447..30f43f99 100644
--- a/math_functions.hpp
+++ b/math_functions.hpp
@@ -25,7 +25,7 @@
 #include "config.hpp"
 
 #include <algorithm>                    // max(), min(), transform()
-#include <cmath>                        // expm1(), log1p(), signbit()
+#include <cmath>                        // signbit()
 #include <limits>
 #include <numeric>                      // midpoint(), partial_sum()
 #include <stdexcept>
@@ -148,7 +148,7 @@ struct i_upper_n_over_n_from_i
             }
 
         // naively:    (1+i)^(1/n) - 1
-        return std::expm1(std::log1p(i) / n);
+        return lmi::expm1(lmi::log1p(i) / n);
         }
 };
 
@@ -172,7 +172,7 @@ struct i_from_i_upper_n_over_n
     T operator()(T i) const
         {
         // naively:    (1+i)^n - 1
-        return std::expm1(std::log1p(i) * n);
+        return lmi::expm1(lmi::log1p(i) * n);
         }
 };
 
@@ -204,7 +204,7 @@ struct d_upper_n_from_i
             }
 
         // naively:    n * (1 - (1+i)^(-1/n))
-        return -n * std::expm1(std::log1p(i) / -n);
+        return -n * lmi::expm1(lmi::log1p(i) / -n);
         }
 };
 
@@ -237,11 +237,11 @@ struct net_i_from_gross
         //   -   (1+spread)^(1/n)
         //   -         fee *(1/n)
         //   )^n - 1
-        return std::expm1
+        return lmi::expm1
             (
-            n * std::log1p
-                (   std::expm1(std::log1p(i)      / n)
-                -   std::expm1(std::log1p(spread) / n)
+            n * lmi::log1p
+                (   lmi::expm1(lmi::log1p(i)      / n)
+                -   lmi::expm1(lmi::log1p(spread) / n)
                 -              fee                / n
                 )
             );
@@ -301,7 +301,7 @@ struct coi_rate_from_q
         else
             {
             // naively:    1 - (1-q)^(1/12)
-            T monthly_q = -std::expm1(std::log1p(-q) / 12);
+            T monthly_q = -lmi::expm1(lmi::log1p(-q) / 12);
             if(T(1) == monthly_q)
                 {
                 throw std::logic_error("Monthly q equals unity.");
diff --git a/objects.make b/objects.make
index 3cadfa8a..22745726 100644
--- a/objects.make
+++ b/objects.make
@@ -146,6 +146,8 @@ common_common_objects := \
   death_benefits.o \
   emit_ledger.o \
   facets.o \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   fenv_guard.o \
   fenv_lmi.o \
   file_command.o \
@@ -176,6 +178,7 @@ common_common_objects := \
   ledgervalues.o \
   license.o \
   loads.o \
+  math_functions.o \
   mc_enum.o \
   mc_enum_types.o \
   mc_enum_types_aux.o \
@@ -534,6 +537,9 @@ commutation_functions_test$(EXEEXT): \
   commutation_functions.o \
   commutation_functions_test.o \
   cso_table.o \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
+  math_functions.o \
   timer.o \
 
 configurable_settings_test$(EXEEXT): EXTRA_LDFLAGS = $(xml_ldflags)
@@ -627,10 +633,13 @@ gpt_cf_triad_test$(EXEEXT): \
   calendar_date.o \
   commutation_functions.o \
   cso_table.o \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   global_settings.o \
   gpt_cf_triad_test.o \
   gpt_commutation_functions.o \
   ihs_irc7702.o \
+  math_functions.o \
   miscellany.o \
   null_stream.o \
   path_utility.o \
@@ -640,9 +649,12 @@ gpt_test$(EXEEXT): \
   $(common_test_objects) \
   commutation_functions.o \
   cso_table.o \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   gpt7702.o \
   gpt_commutation_functions.o \
   gpt_test.o \
+  math_functions.o \
 
 handle_exceptions_test$(EXEEXT): \
   $(common_test_objects) \
@@ -650,8 +662,11 @@ handle_exceptions_test$(EXEEXT): \
 
 i7702_test$(EXEEXT): \
   $(common_test_objects) \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   i7702.o \
   i7702_test.o \
+  math_functions.o \
   timer.o \
 
 ieee754_test$(EXEEXT): \
@@ -723,9 +738,12 @@ irc7702_tables_test$(EXEEXT): \
   calendar_date.o \
   commutation_functions.o \
   cso_table.o \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   global_settings.o \
   irc7702_tables.o \
   irc7702_tables_test.o \
+  math_functions.o \
   miscellany.o \
   null_stream.o \
   path_utility.o \
@@ -777,8 +795,11 @@ ledger_test$(EXEEXT): \
 
 loads_test$(EXEEXT): \
   $(common_test_objects) \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   loads.o \
   loads_test.o \
+  math_functions.o \
   timer.o \
 
 map_lookup_test$(EXEEXT): \
@@ -829,7 +850,10 @@ monnaie_test$(EXEEXT): \
 
 mortality_rates_test$(EXEEXT): \
   $(common_test_objects) \
+  fdlibm_expm1.o \
+  fdlibm_log1p.o \
   ihs_mortal.o \
+  math_functions.o \
   mortality_rates_test.o \
 
 name_value_pairs_test$(EXEEXT): \



reply via email to

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