[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/005 cb722b2 4/9: Replace a complaint with a
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/005 cb722b2 4/9: Replace a complaint with a solution |
Date: |
Wed, 20 Jan 2021 00:51:32 -0500 (EST) |
branch: valyuta/005
commit cb722b2d4f25094b1a389fbb04caffc95668d4b7
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Replace a complaint with a solution
Added an overload to class round_to<>
std::vector<currency> c(std::vector<currency> const&) const;
for which no use case had previously been identified, thereby resolving
a documented issue.
'Speed*' files are included in this commit only because the last few
commits have shown apparent speed differences that are of questionable
significance. Here, doing more work "improves" speed slightly.
---
Speed_gcc_i686-w64-mingw32 | 12 ++++++------
Speed_gcc_x86_64-pc-linux-gnu | 12 ++++++------
Speed_gcc_x86_64-w64-mingw32 | 12 ++++++------
outlay.cpp | 6 +-----
round_to.hpp | 11 +++++++++++
5 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/Speed_gcc_i686-w64-mingw32 b/Speed_gcc_i686-w64-mingw32
index 6ea65e3..459e00d 100644
--- a/Speed_gcc_i686-w64-mingw32
+++ b/Speed_gcc_i686-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 5.632e-02 s mean; 53206 us least of 18 runs
- naic, specamt solve : 1.124e-01 s mean; 99068 us least of 9 runs
- naic, ee prem solve : 9.087e-02 s mean; 90032 us least of 12 runs
- finra, no solve : 1.740e-02 s mean; 16281 us least of 58 runs
- finra, specamt solve: 5.861e-02 s mean; 58086 us least of 18 runs
- finra, ee prem solve: 5.407e-02 s mean; 53546 us least of 19 runs
+ naic, no solve : 5.349e-02 s mean; 52965 us least of 19 runs
+ naic, specamt solve : 9.965e-02 s mean; 98694 us least of 11 runs
+ naic, ee prem solve : 9.075e-02 s mean; 90136 us least of 12 runs
+ finra, no solve : 1.678e-02 s mean; 16402 us least of 60 runs
+ finra, specamt solve: 5.909e-02 s mean; 58090 us least of 17 runs
+ finra, ee prem solve: 5.412e-02 s mean; 53476 us least of 19 runs
diff --git a/Speed_gcc_x86_64-pc-linux-gnu b/Speed_gcc_x86_64-pc-linux-gnu
index f51edd2..edd915e 100644
--- a/Speed_gcc_x86_64-pc-linux-gnu
+++ b/Speed_gcc_x86_64-pc-linux-gnu
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 2.279e-02 s mean; 20333 us least of 44 runs
- naic, specamt solve : 4.035e-02 s mean; 37009 us least of 25 runs
- naic, ee prem solve : 3.971e-02 s mean; 33669 us least of 26 runs
- finra, no solve : 6.329e-03 s mean; 5841 us least of 100 runs
- finra, specamt solve: 2.332e-02 s mean; 20978 us least of 43 runs
- finra, ee prem solve: 2.022e-02 s mean; 19156 us least of 50 runs
+ naic, no solve : 2.045e-02 s mean; 20221 us least of 49 runs
+ naic, specamt solve : 3.695e-02 s mean; 36645 us least of 28 runs
+ naic, ee prem solve : 3.372e-02 s mean; 33278 us least of 30 runs
+ finra, no solve : 5.975e-03 s mean; 5707 us least of 100 runs
+ finra, specamt solve: 2.097e-02 s mean; 20638 us least of 48 runs
+ finra, ee prem solve: 1.936e-02 s mean; 19023 us least of 52 runs
diff --git a/Speed_gcc_x86_64-w64-mingw32 b/Speed_gcc_x86_64-w64-mingw32
index 85abe1f..29b38ff 100644
--- a/Speed_gcc_x86_64-w64-mingw32
+++ b/Speed_gcc_x86_64-w64-mingw32
@@ -1,7 +1,7 @@
Test speed:
- naic, no solve : 3.173e-02 s mean; 28045 us least of 32 runs
- naic, specamt solve : 4.890e-02 s mean; 47947 us least of 21 runs
- naic, ee prem solve : 4.463e-02 s mean; 43659 us least of 23 runs
- finra, no solve : 1.087e-02 s mean; 10383 us least of 92 runs
- finra, specamt solve: 2.939e-02 s mean; 28657 us least of 35 runs
- finra, ee prem solve: 2.732e-02 s mean; 26606 us least of 37 runs
+ naic, no solve : 2.886e-02 s mean; 27218 us least of 35 runs
+ naic, specamt solve : 4.744e-02 s mean; 46894 us least of 22 runs
+ naic, ee prem solve : 4.351e-02 s mean; 42983 us least of 23 runs
+ finra, no solve : 1.055e-02 s mean; 10306 us least of 95 runs
+ finra, specamt solve: 2.843e-02 s mean; 27959 us least of 36 runs
+ finra, ee prem solve: 2.645e-02 s mean; 26071 us least of 38 runs
diff --git a/outlay.cpp b/outlay.cpp
index 7e93d91..c29fe9f 100644
--- a/outlay.cpp
+++ b/outlay.cpp
@@ -74,11 +74,7 @@ void modal_outlay::set_er_modal_premiums(currency z, int
from_year, int to_year)
void modal_outlay::set_er_modal_premiums(std::vector<currency> const& z)
{
LMI_ASSERT(z.size() == er_modal_premiums_.size());
-// er_modal_premiums_ = round_gross_premium_.c(z);
- // Temporarily disregard rounding, which remains necessary: the
- // new value is currency, so it's rounded to cents somehow, but
- // premiums could be rounded differently--say, up to dollars.
- er_modal_premiums_ = z; // CURRENCY
+ er_modal_premiums_ = round_gross_premium_.c(z); // already rounded?
}
void modal_outlay::set_withdrawals(currency z, int from_year, int to_year)
diff --git a/round_to.hpp b/round_to.hpp
index 41d66d9..402e635 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -271,6 +271,7 @@ class round_to
std::vector<currency> c(std::vector<RealType> const&) const;
currency c(currency) const;
+ std::vector<currency> c(std::vector<currency> const&) const;
int decimals() const;
rounding_style style() const;
@@ -414,6 +415,16 @@ inline currency round_to<RealType>::c(currency z) const
}
template<typename RealType>
+inline std::vector<currency> round_to<RealType>::c
+ (std::vector<currency> const& v) const
+{
+ std::vector<currency> z;
+ z.reserve(v.size());
+ for(auto const& i : v) {z.push_back(c(i));}
+ return z;
+}
+
+template<typename RealType>
int round_to<RealType>::decimals() const
{
return decimals_;
- [lmi-commits] [lmi] valyuta/005 updated (4401725 -> ca84095), Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 4483b09 1/9: Avoid passing 'currency' by const reference, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 1dd82ec 3/9: Rationalize argument names, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 cb722b2 4/9: Replace a complaint with a solution,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/005 2e73521 5/9: Begin to conditionalize use of currency class, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 b835c6d 2/9: Partially revert the last commit, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 afa4967 8/9: Make lmi build without currency class, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 ca84095 9/9: Record speed measurements, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 df368ca 6/9: Replace currency::d() with d(currency) almost everywhere, Greg Chicares, 2021/01/20
- [lmi-commits] [lmi] valyuta/005 75f8adf 7/9: Add and use free function from_cents(), Greg Chicares, 2021/01/20