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

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


The following commit has been merged in the upstream-hg branch:
commit b1959f8858e031b9c52c8e7e01549051c8668978
Author: Alexander Dreyer <adreyer at gmx.de>
Date:   Tue Feb 28 15:05:21 2012 +0100

    CHA: delayed comparison optimizes

diff --git a/groebner/include/polybori/groebner/DelayedLongProduct.h b/groebner/include/polybori/groebner/DelayedLongProduct.h
index 4b83c6d..1e6dd31 100644
--- a/groebner/include/polybori/groebner/DelayedLongProduct.h
+++ b/groebner/include/polybori/groebner/DelayedLongProduct.h
@@ -33,12 +33,13 @@ BEGIN_NAMESPACE_PBORIGB
 
 class DelayedLongProduct:
   private DelayedLongLong {
-
   typedef DelayedLongLong base;
+
 public:
   DelayedLongProduct(const long_type& high, const long_type & low):
     base(high, low) {}
 
+  /// 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)
@@ -46,6 +47,7 @@ public:
     return (second != 0) && (first > rhs/second);
   }
 
+  /// compare carry-over savely with represented by two unsigned longs
   template <long_type MaxHigh, long_type MaxLow>
   bool greater(const LongLongConstant<MaxHigh, MaxLow>&) const {
 
@@ -53,13 +55,13 @@ public:
       return false;
 
     BitMask<sizeof(long_type)*8 - NBitsUsed<MaxHigh>::value > front;
-    long_type front_part = (front.shift(MaxHigh) + front.high(MaxLow)) ;
-
+    const long_type front_part = (front.shift(MaxHigh) + front.high(MaxLow));
     long_type divided  = front_part / second;
- 
-    return (front.high(divided) == 0) &&
-      (first > (front.back(divided) + 
-		(front.back(front_part%second)+ front.low(MaxLow) ) / second));
+
+    return  (front.high(divided) == 0) && 
+      (first > front.back(divided)) &&
+      (first - front.back(divided) > 
+       (front.back(front_part%second)+ front.low(MaxLow) ) / second);
   }
 };
 

-- 
polybori: Polynomials over Boolean Rings



More information about the debian-science-commits mailing list