lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master e6ba6ba 3/4: Think arithmetic in APL always;


From: Greg Chicares
Subject: [lmi-commits] [lmi] master e6ba6ba 3/4: Think arithmetic in APL always; write it in APL whenever possible
Date: Thu, 15 Mar 2018 16:34:41 -0400 (EDT)

branch: master
commit e6ba6ba0ba8d636ae3adcc4560dab7ef7a406280
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Think arithmetic in APL always; write it in APL whenever possible
    
    Multiplying a vector V times a constant C should be as readable as
      V *= C
    and the distressful
      transform(blah, blah, blah, blah, multiplies<nondeduced_type>))
    is in fact measurably slower.
---
 ledger_base.cpp | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/ledger_base.cpp b/ledger_base.cpp
index 46ac4fe..bbd8673 100644
--- a/ledger_base.cpp
+++ b/ledger_base.cpp
@@ -26,13 +26,13 @@
 #include "alert.hpp"
 #include "assert_lmi.hpp"
 #include "crc32.hpp"
+#include "et_vector.hpp"
 #include "miscellany.hpp"               // minmax
 #include "stl_extensions.hpp"           // nonstd::power()
 #include "value_cast.hpp"
 
-#include <algorithm>                    // max(), min(), transform()
+#include <algorithm>                    // max(), min()
 #include <cmath>                        // floor(), log10()
-#include <functional>                   // multiplies
 
 //============================================================================
 LedgerBase::LedgerBase(int a_Length)
@@ -421,18 +421,9 @@ void LedgerBase::ApplyScaleFactor(int decimal_power)
 
     scale_unit_ = look_up_scale_unit(scale_power_);
 
-    // ET !! *i.second *= M;
-    std::vector<double>M(GetLength(), 1.0 / nonstd::power(10.0, scale_power_));
     for(auto& i : ScalableVectors)
         {
-        std::vector<double>& v = *i.second;
-        std::transform
-            (v.begin()
-            ,v.end()
-            ,M.begin()
-            ,v.begin()
-            ,std::multiplies<double>()
-            );
+        *i.second *= 1.0 / nonstd::power(10.0, scale_power_);
         }
 }
 



reply via email to

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