lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 038e34d 3/3: Fix defect introduced 20210314T1


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 038e34d 3/3: Fix defect introduced 20210314T1102Z: Max != max
Date: Wed, 24 Mar 2021 10:37:26 -0400 (EDT)

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

    Fix defect introduced 20210314T1102Z: Max != max
    
    Commit d59b96b4a56af of 20210314T1102Z wrote "max" where "Max" was
    intended. With two vector arguments:
     - Max() compares each element and selects the greater;
     - std::max() selects one of its two arguments.
    
    * i7702_test.cpp: Demonstrated the defect.
    * i7702.cpp: Fixed the defect.
---
 i7702.cpp      |  6 +++---
 i7702_test.cpp | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/i7702.cpp b/i7702.cpp
index 41068e5..6983934 100644
--- a/i7702.cpp
+++ b/i7702.cpp
@@ -328,9 +328,9 @@ void i7702::initialize()
 
     if(!each_equal(Em_, 0.0))
         {
-        ig_usual_ += max(ic_usual_, Em_);
-        ig_glp_   += max(ic_glp_  , Em_);
-        ig_gsp_   += max(ic_gsp_  , Em_);
+        ig_usual_ += Max(ic_usual_, Em_);
+        ig_glp_   += Max(ic_glp_  , Em_);
+        ig_gsp_   += Max(ic_gsp_  , Em_);
         }
 
     if(trace_)
diff --git a/i7702_test.cpp b/i7702_test.cpp
index 37cd760..ff052db 100644
--- a/i7702_test.cpp
+++ b/i7702_test.cpp
@@ -26,6 +26,9 @@
 #include "materially_equal.hpp"
 #include "test_tools.hpp"
 
+#include <cfloat>                       // DECIMAL_DIG
+#include <iomanip>                      // setprecision()
+
 class i7702_test
 {
   public:
@@ -65,10 +68,39 @@ void i7702_test::test0()
         ,{1.0}       // use_vlr
         };
     LMI_TEST(materially_equal(0.0032737, z.ig_usual()[0], 0.0000125));
+    LMI_TEST(materially_equal(0.00327373978219886374239, z.ig_usual()[0]));
+
+    std::cout<< std::setprecision(DECIMAL_DIG) << z.ig_usual()[0] << std::endl;
 }
 
 void i7702_test::test1()
 {
+    i7702 z
+        {2                      // length
+        ,0.04                   // A0
+        ,0.06                   // A1
+        ,{0.03     , 0.03     } // Bgen
+        ,{0.00     , 0.00     } // Bsep
+        ,{0.02     , 0.02     } // Bflr
+        ,{0.02     , 0.02     } // Bvlr
+        ,{0.05     , 0.00     } // Cgen
+        ,{0.00     , 0.00     } // Csep
+        ,{0.00     , 0.00     } // Cflr
+        ,{0.00     , 0.00     } // Cvlr
+        ,{0.00     , 0.00     } // Dgen
+        ,{0.00     , 0.00     } // Dsep
+        ,{0.00     , 0.00     } // Dflr
+        ,{0.00     , 0.00     } // Dvlr
+        ,{0.0032738, 0.0032738} // Em
+        ,{1.0      , 1.0      } // use_gen
+        ,{1.0      , 1.0      } // use_sep
+        ,{1.0      , 1.0      } // use_flr
+        ,{1.0      , 1.0      } // use_vlr
+        };
+    LMI_TEST(materially_equal(0.00407412378364830143895, z.ig_usual()[0]));
+    LMI_TEST(materially_equal(0.0032738                , z.ig_usual()[1]));
+    std::cout<< std::setprecision(DECIMAL_DIG) << z.ig_usual()[0] << std::endl;
+    std::cout<< std::setprecision(DECIMAL_DIG) << z.ig_usual()[1] << std::endl;
 }
 
 int test_main(int, char*[])



reply via email to

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