[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 19c01d9 2/7: Add minimum- and maximum-age arg
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 19c01d9 2/7: Add minimum- and maximum-age arguments to cso_table() |
Date: |
Sat, 11 May 2019 13:26:23 -0400 (EDT) |
branch: master
commit 19c01d9647570e5d14a5e7edf18af914d7d58716
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add minimum- and maximum-age arguments to cso_table()
This revision introduces default arguments with a "magical" value of
negative one. Such "magic" is dangerous, and will soon be replaced by
overloading.
---
cso_table.cpp | 23 ++++++++++++++---------
cso_table.hpp | 2 ++
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/cso_table.cpp b/cso_table.cpp
index aa13356..73f8c28 100644
--- a/cso_table.cpp
+++ b/cso_table.cpp
@@ -941,6 +941,8 @@ std::vector<double> cso_table
,oenum_alb_or_anb alb_or_anb
,mcenum_gender gender
,mcenum_smoking smoking
+ ,int min_age
+ ,int max_age
)
{
bool const is_anb = alb_or_anb != oe_age_last_birthday;
@@ -965,8 +967,13 @@ std::vector<double> cso_table
);
LMI_ASSERT(each_equal(p, p + sns_age, 0.0));
+ LMI_ASSERT(0 == std::count(p + sns_age, p + omega, 0.0));
+ LMI_ASSERT(1.0 == p[omega - 1]);
- std::vector<double> v(p + sns_age, p + omega);
+ if(-1 == min_age) min_age = sns_age;
+ if(-1 == max_age) max_age = omega;
+
+ std::vector<double> v(p + min_age, p + max_age);
if
(oe_heterodox == autopisty
@@ -980,19 +987,17 @@ std::vector<double> cso_table
// was also ratified by NAIC).
if(is_anb)
{
- LMI_ASSERT(0.03831 == v[56]);
- v[56] = 0.03891;
+ LMI_ASSERT(0.03831 == v[71 - min_age]);
+ v[71 - min_age] = 0.03891;
}
else
{
- LMI_ASSERT(0.03644 == v[55]);
- v[55] = 0.03673;
- LMI_ASSERT(0.04039 == v[56]);
- v[56] = 0.04070;
+ LMI_ASSERT(0.03644 == v[71 - min_age - 1]);
+ v[71 - min_age - 1] = 0.03673;
+ LMI_ASSERT(0.04039 == v[71 - min_age]);
+ v[71 - min_age] = 0.04070;
}
}
- LMI_ASSERT(0 == std::count(v.begin(), v.end(), 0.0));
- LMI_ASSERT(1.0 == v.back());
return v;
}
diff --git a/cso_table.hpp b/cso_table.hpp
index 99e07a3..2e69f34 100644
--- a/cso_table.hpp
+++ b/cso_table.hpp
@@ -36,6 +36,8 @@ std::vector<double> LMI_SO cso_table
,oenum_alb_or_anb
,mcenum_gender
,mcenum_smoking
+ ,int min_age = -1
+ ,int max_age = -1
);
#endif // cso_table_hpp
- [lmi-commits] [lmi] master updated (30f5cff -> fe191f3), Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master 49d083a 5/7: Upgrade to gcc-8.x, Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master 09d67a8 4/7: Calculate 7PP and CVAT corridor from first principles, Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master fe191f3 7/7: Fully reflect earlier eradication of cygwin "MinGW_" mount, Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master bc0c833 6/7: Install bsdtar in chroot, Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master 7566ae5 3/7: Prefer overloading to "magical" default argument values, Greg Chicares, 2019/05/11
- [lmi-commits] [lmi] master 19c01d9 2/7: Add minimum- and maximum-age arguments to cso_table(),
Greg Chicares <=
- [lmi-commits] [lmi] master ac642ae 1/7: Simplify an assertion, Greg Chicares, 2019/05/11