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

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


The following commit has been merged in the upstream-hg branch:
commit 68344151dc166cde6b49a2122997ec9b025bcb41
Author: Alexander Dreyer <adreyer at gmx.de>
Date:   Fri Feb 24 22:23:13 2012 +0100

    CHA: moved classes to own files

diff --git a/ChangeLog b/ChangeLog
index ce374d6..c66fb03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,7 +11,8 @@ Release Name: 0.8.1
 * Install/InstallAs fixes permissions
 * ipbori -t runs PolyBoRi's doctests	
 * internal refactoring of ReductionStrategy and GroebnerStrategy started
-	
+* avoiding long long
+
 Release Name: 0.8.0
 * improved standard-conformity, multiprocessing safety, and usability
 * renamed subdirectory polybori to libpolybori
diff --git a/groebner/include/polybori/groebner/.h b/groebner/include/polybori/groebner/.h
index f801bd5..e69de29 100644
--- a/groebner/include/polybori/groebner/.h
+++ b/groebner/include/polybori/groebner/.h
@@ -1,47 +0,0 @@
-// -*- c++ -*-
-//*****************************************************************************
-/** @file .h 
- *
- * @author Alexander Dreyer 
- * @date 2012-01-31 
- *
- * This file includes the definition of the class @c .
- *
- * @par Copyright:
- *   (c) 2012 by The PolyBoRi Team
- *
-**/
-//*****************************************************************************
-
-#ifndef polybori_groebner__h_
-#define polybori_groebner__h_
-
-// include basic definitions
-#include "groebner_defs.h"
-
-BEGIN_NAMESPACE_PBORIGB
-
-/** @class 
- * @brief This class defines .
- *
- **/
-
-class  {
-  /// Type of *this
-  typedef  self;
-
-public:
-  /// Default constructor
-  () {}
-
-  /// Copy constructor
-  (const self& rhs) {}
-
-  /// Destructor
-  ~() {}
-
-};
-
-END_NAMESPACE_PBORIGB
-
-#endif /* polybori_groebner__h_ */
diff --git a/groebner/include/polybori/groebner/BitMask.h b/groebner/include/polybori/groebner/BitMask.h
new file mode 100644
index 0000000..be8553a
--- /dev/null
+++ b/groebner/include/polybori/groebner/BitMask.h
@@ -0,0 +1,64 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file BitMask.h 
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c BitMask.
+ *
+ * @par Copyright:
+ *   (c) 2012 by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_BitMask_h_
+#define polybori_groebner_BitMask_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class BitMask
+ * @brief This class defines a bit mask and related operations.
+ *
+ **/
+
+template <unsigned NBits>
+class BitMask;
+
+template <>
+class BitMask<0> {
+public:
+  static const unsigned nbits = 0;
+  static const unsigned long mask = 0;
+
+  unsigned long low(const unsigned long& value) const { return 0; }
+  const unsigned long& high(const unsigned long& value) const { return value; }
+  const unsigned long& shift(const unsigned long& value) const { return value; }
+};
+
+template <unsigned NBits>
+class BitMask {
+public:
+  static const unsigned nbits = NBits;
+  static const unsigned long mask = (BitMask<nbits-1>::mask << 1) + 1;
+
+  unsigned long low(const unsigned long& value) const {
+    return value & mask;
+  }
+  unsigned long high(const unsigned long& value) const {
+    return value >> NBits;
+  }
+  unsigned long shift(const unsigned long& value) const {
+    return value << NBits;
+  }
+};
+
+
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_BitMask_h_ */
diff --git a/groebner/include/polybori/groebner/DelayedLongLong.h b/groebner/include/polybori/groebner/DelayedLongLong.h
new file mode 100644
index 0000000..855ffb2
--- /dev/null
+++ b/groebner/include/polybori/groebner/DelayedLongLong.h
@@ -0,0 +1,54 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file DelayedLongLong.h 
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c DelayedLongLong.
+ *
+ * @par Copyright:
+ *   (c) 2012 by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_DelayedLongLong_h_
+#define polybori_groebner_DelayedLongLong_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+#include "BitMask.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class DelayedLongLong
+ * @brief This class unses two (unsigned) longs to represent @c long long.
+ *
+ **/
+
+class DelayedLongLong:
+  protected std::pair<unsigned long, unsigned long>,
+  protected BitMask<sizeof(unsigned long)*4> {
+
+public:
+  typedef unsigned long long_type;
+
+protected:
+  typedef std::pair<long_type, long_type> base;
+
+public:
+  DelayedLongLong(const long_type& high, const long_type& low):
+    base(high, low) {}
+
+#ifdef PBORI_HAVE_LONG_LONG
+  operator unsigned long long() const {
+    return (unsigned long long(first) << (sizeof(long_type)*8)) + second;
+  }
+#endif
+};
+
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_DelayedLongLong_h_ */
diff --git a/groebner/include/polybori/groebner/DelayedLongProduct.h b/groebner/include/polybori/groebner/DelayedLongProduct.h
new file mode 100644
index 0000000..db6a6af
--- /dev/null
+++ b/groebner/include/polybori/groebner/DelayedLongProduct.h
@@ -0,0 +1,56 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file DelayedLongProduct.h 
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c DelayedLongProduct.
+ *
+ * @par Copyright:
+ *   (c) by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_DelayedLongProduct_h_
+#define polybori_groebner_DelayedLongProduct_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+#include "DelayedLongLong.h"
+#include "LongLongConstant.h"
+#include "LongProductLess.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class DelayedLongProduct
+ * @brief This class defines a delayed product of longs and comparison with
+ * @c LongLong Constant.
+ *
+ **/
+
+class DelayedLongProduct:
+  private DelayedLongLong {
+
+  typedef DelayedLongLong base;
+public:
+  DelayedLongProduct(const long_type& high, const long_type & low):
+    base(high, low) {}
+
+  template <long_type MaxHigh, long_type MaxLow>
+  bool less(const LongLongConstant<MaxHigh, MaxLow>&) const {
+    return LongProductLess<MaxHigh, MaxLow>()(first, second);
+  }
+};
+
+template <class RhsType>
+inline bool
+operator> (DelayedLongProduct lhs, const RhsType& rhs) {
+   return lhs.less(rhs);
+}
+
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_DelayedLongProduct_h_ */
diff --git a/groebner/include/polybori/groebner/LongLongConstant.h b/groebner/include/polybori/groebner/LongLongConstant.h
new file mode 100644
index 0000000..37cc390
--- /dev/null
+++ b/groebner/include/polybori/groebner/LongLongConstant.h
@@ -0,0 +1,51 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file LongLongConstant.h 
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c LongLongConstant.
+ *
+ * @par Copyright:
+ *   (c) 2012 
+by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_LongLongConstant_h_
+#define polybori_groebner_LongLongConstant_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+#include "DelayedLongLong.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class LongLongConstant
+ * @brief This class defines LongLongConstant.
+ *
+ **/
+
+template <DelayedLongLong::long_type High,
+          DelayedLongLong::long_type Low>
+class LongLongConstant {
+public:
+  typedef typename DelayedLongLong::long_type long_type;
+  static const long_type first = High;
+  static const long_type second = Low;
+
+#ifdef PBORI_HAVE_LONG_LONG
+  operator DelayedLongLong() const {
+    return DelayedLongLong(first, second);
+  }
+  operator unsigned long long() const {
+    return operator DelayedLongLong();
+  }
+#endif
+};
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_LongLongConstant_h_ */
diff --git a/groebner/include/polybori/groebner/LongProductLess.h b/groebner/include/polybori/groebner/LongProductLess.h
new file mode 100644
index 0000000..bfc392e
--- /dev/null
+++ b/groebner/include/polybori/groebner/LongProductLess.h
@@ -0,0 +1,81 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file LongProductLess.h 
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c LongProductLess.
+ *
+ * @par Copyright:
+ *   (c) 2012 by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_LongProductLess_h_
+#define polybori_groebner_LongProductLess_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+#include "DelayedLongLong.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class LongProductLess
+ * @brief This class compared a delayed product with a delayed (constant) sum
+ * of (unsigned) long. It avoids to use long long instances.
+ *
+ **/
+
+template <DelayedLongLong::long_type MaxHigh,
+          DelayedLongLong::long_type MaxLow>
+class LongProductLess:
+  private DelayedLongLong {
+  typedef DelayedLongLong base;
+
+public:
+  LongProductLess():
+    base(0, 0) {}
+
+  bool operator()(const long_type& higher, const long_type & lower) {
+
+    return most(high(higher) * high(lower)) || 
+      mid(high(higher)*low(lower)) || mid(low(higher)*high(lower)) ||
+      least(low(higher)*low(lower));
+  }
+
+protected:
+  bool most(const long_type& number) {
+    first = number;
+    second = 0;
+    return (first > MaxHigh);
+  }
+
+  bool mid(const long_type& number) {
+    first += high(number);
+
+    if (first > MaxHigh)
+      return true;
+    second += low(number);
+
+    first += high(second);
+
+    if (first > MaxHigh)
+      return true;
+
+    second = low(second);
+    return false;
+  }
+
+  bool least(const long_type& number) {
+    return mid(high(number)) ||
+      ((first == MaxHigh) && ( (shift(second) + low(number)) > MaxLow));
+  }
+
+
+};
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_LongProductLess_h_ */
diff --git a/groebner/include/polybori/groebner/linear_algebra_step.h b/groebner/include/polybori/groebner/linear_algebra_step.h
index 500014a..5717348 100644
--- a/groebner/include/polybori/groebner/linear_algebra_step.h
+++ b/groebner/include/polybori/groebner/linear_algebra_step.h
@@ -26,6 +26,10 @@
 #include "MatrixMonomialOrderTables.h"
 #include "PolyMonomialPairComparerLess.h"
 
+#include "BitMask.h"
+#include "DelayedLongProduct.h"
+#include "LongLongConstant.h"
+
 #ifdef PBORI_HAVE_NTL
 #include <NTL/GF2.h>
 #include <NTL/mat_GF2.h>
@@ -243,145 +247,6 @@ pbori_transpose(mzd_t* mat) {
 }
 
 
-template <unsigned NBits>
-class BitMask;
-
-template <>
-class BitMask<0> {
-public:
-  static const unsigned nbits = 0;
-  static const unsigned long mask = 0;
-
-  unsigned long low(const unsigned long& value) const { return 0; }
-  const unsigned long& high(const unsigned long& value) const { return value; }
-  const unsigned long& shift(const unsigned long& value) const { return value; }
-};
-
-template <unsigned NBits>
-class BitMask {
-public:
-  static const unsigned nbits = NBits;
-  static const unsigned long mask = (BitMask<nbits-1>::mask << 1) + 1;
-
-  unsigned long low(const unsigned long& value) const {
-    return value & mask;
-  }
-  unsigned long high(const unsigned long& value) const {
-    return value >> NBits;
-  }
-  unsigned long shift(const unsigned long& value) const {
-    return value << NBits;
-  }
-};
-
-
-class DelayedLongLong:
-  protected std::pair<unsigned long, unsigned long>,
-  protected BitMask<sizeof(unsigned long)*4> {
-
-public:
-  typedef unsigned long long_type;
-
-protected:
-  typedef std::pair<long_type, long_type> base;
-
-public:
-  DelayedLongLong(const long_type& high, const long_type& low):
-    base(high, low) {}
-
-#ifdef PBORI_HAVE_LONG_LONG
-  operator unsigned long long() const {
-    return (unsigned long long(first) << (sizeof(long_type)*8)) + second;
-  }
-#endif
-};
-
-template <DelayedLongLong::long_type High,
-          DelayedLongLong::long_type Low>
-class LongLongConstant {
-public:
-  typedef typename DelayedLongLong::long_type long_type;
-  static const long_type first = High;
-  static const long_type second = Low;
-
-#ifdef PBORI_HAVE_LONG_LONG
-  operator DelayedLongLong() const {
-    return DelayedLongLong(first, second);
-  }
-  operator unsigned long long() const {
-    return operator DelayedLongLong();
-  }
-#endif
-};
-
-
-
-template <DelayedLongLong::long_type MaxHigh,
-          DelayedLongLong::long_type MaxLow>
-class LongProductLess:
-  private DelayedLongLong {
-  typedef DelayedLongLong base;
-
-public:
-  LongProductLess():
-    base(0, 0) {}
-
-  bool operator()(const long_type& higher, const long_type & lower) {
-
-    return most(high(higher) * high(lower)) || 
-      mid(high(higher)*low(lower)) || mid(low(higher)*high(lower)) ||
-      least(low(higher)*low(lower));
-  }
-
-protected:
-  bool most(const long_type& number) {
-    first = number;
-    second = 0;
-    return (first > MaxHigh);
-  }
-
-  bool mid(const long_type& number) {
-    first += high(number);
-
-    if (first > MaxHigh)
-      return true;
-    second += low(number);
-
-    first += high(second);
-
-    if (first > MaxHigh)
-      return true;
-
-    second = low(second);
-    return false;
-  }
-
-  bool least(const long_type& number) {
-    return mid(high(number)) ||
-      ((first == MaxHigh) && ( (shift(second) + low(number)) > MaxLow));
-  }
-
-
-};
-
-class DelayedLongProduct:
-  private DelayedLongLong {
-
-  typedef DelayedLongLong base;
-public:
-  DelayedLongProduct(const long_type& high, const long_type & low):
-    base(high, low) {}
-
-  template <long_type MaxHigh, long_type MaxLow>
-  bool less(const LongLongConstant<MaxHigh, MaxLow>&) const {
-    return LongProductLess<MaxHigh, MaxLow>()(first, second);
-  }
-};
-
-template <class RhsType>
-bool operator> (DelayedLongProduct lhs, const RhsType& rhs) {
-   return lhs.less(rhs);
-}
 
 inline void 
 linalg_step_modified(std::vector < Polynomial > &polys, MonomialSet terms, MonomialSet leads_from_strat, bool log, bool optDrawMatrices, const char* matrixPrefix)

-- 
polybori: Polynomials over Boolean Rings



More information about the debian-science-commits mailing list