[SCM] polybori: Polynomials over Boolean Rings branch, upstream-hg, updated. b4a5cffaa908c53e1d958a42110f8c4dad853aa3

Alexander Dreyer adreyer at gmx.de
Fri Mar 23 08:01:54 UTC 2012


The following commit has been merged in the upstream-hg branch:
commit ebb7ba77bdc81e6aed0c6defff551cf2261a4dda
Author: Alexander Dreyer <adreyer at gmx.de>
Date:   Thu Mar 1 13:54:59 2012 +0100

    CHA: Use software product

diff --git a/groebner/include/polybori/groebner/DelayedLongProduct.h b/groebner/include/polybori/groebner/DelayedLongProduct.h
index dc74d88..0ac4e2a 100644
--- a/groebner/include/polybori/groebner/DelayedLongProduct.h
+++ b/groebner/include/polybori/groebner/DelayedLongProduct.h
@@ -20,8 +20,6 @@
 #include "groebner_defs.h"
 #include "PseudoLongLong.h"
 #include "BitMask.h"
-#include "NBitsUsed.h"
-
 
 BEGIN_NAMESPACE_PBORIGB
 
@@ -32,23 +30,26 @@ BEGIN_NAMESPACE_PBORIGB
  **/
 
 class DelayedLongProduct:
-  public std::pair<unsigned long, unsigned long>,
   protected BitMask<sizeof(unsigned long)*4> {
 
-  typedef std::pair<unsigned long, unsigned long> base;
-
 public:
   typedef unsigned long long_type;
 
-  DelayedLongProduct(const long_type& high, const long_type & low):
-    base(high, low) {}
+  DelayedLongProduct(const long_type& first, const long_type & second):
+    least(low(first)*low(second)), most(high(first)*high(second)) {
+
+    long_type mixed = high(least) + high(first)*low(second);
+    most += high(mixed);
+    
+    mixed = low(mixed) + low(first)*high(second);
+    most += high(mixed);
+
+    least = shift(mixed) + low(least);
+  }
 
   /// compare carry-over savely
-  // b != 0,  a <= c/b:  a*b <= (c/b)*b  <= (c/b)*b + (c%b) = c
-  // b != 0,  a >  c/b:  Assume a*b  <= c = (c/b)*b + (c%b) ->
-  //   (c/b)*b < a*b  <= (c/b)*b + (c%b)  ->  c/b < a < c/b+1 (contradicts int)
   bool greater(long_type rhs) const {
-    return (second != 0) && (first > rhs/second);
+    return (most > 0) || (least > rhs);
   }
 
   /// compare carry-over savely with represented by two unsigned longs
@@ -60,18 +61,11 @@ public:
   /// compare carry-over savely with represented by two unsigned longs
   template <long_type MaxHigh, long_type MaxLow>
   bool greater(const PseudoLongLong<MaxHigh, MaxLow>&) const {
-
-    long_type least = low(first)*low(second);
-    long_type mixed = high(least) + high(first)*low(second);
-    long_type most = high(mixed) + high(first)*high(second);
-    if (most > MaxHigh)
-      return true;
-
-    mixed = low(mixed) + low(first)*high(second);
-    most += high(mixed);
-    least = shift(mixed) + low(least);
     return (most > MaxHigh) || ( (most == MaxHigh) && (least > MaxLow) );
   }
+
+private:
+  long_type most, least;
 };
 
 template <class RhsType>

-- 
polybori: Polynomials over Boolean Rings



More information about the debian-science-commits mailing list