[SCM] polybori: Polynomials over Boolean Rings branch, upstream-hg, updated. b4a5cffaa908c53e1d958a42110f8c4dad853aa3
Alexander Dreyer
adreyer at gmx.de
Fri Mar 23 08:01:28 UTC 2012
The following commit has been merged in the upstream-hg branch:
commit de4fafebf512060436819aa10f277bbff876d44b
Author: Alexander Dreyer <adreyer at gmx.de>
Date: Sat Feb 25 23:43:50 2012 +0100
CHA: improved long-long-less check for 64bitted longs
diff --git a/groebner/include/polybori/groebner/DelayedLongProduct.h b/groebner/include/polybori/groebner/DelayedLongProduct.h
index db6a6af..25a9177 100644
--- a/groebner/include/polybori/groebner/DelayedLongProduct.h
+++ b/groebner/include/polybori/groebner/DelayedLongProduct.h
@@ -38,8 +38,15 @@ public:
DelayedLongProduct(const long_type& high, const long_type & low):
base(high, low) {}
+ bool greater(long_type rhs) const {
+ if (high(first) && high(second))
+ return (first > rhs/second);
+
+ return (first * second) > rhs;
+ }
+
template <long_type MaxHigh, long_type MaxLow>
- bool less(const LongLongConstant<MaxHigh, MaxLow>&) const {
+ bool greater(const LongLongConstant<MaxHigh, MaxLow>&) const {
return LongProductLess<MaxHigh, MaxLow>()(first, second);
}
};
@@ -47,10 +54,11 @@ public:
template <class RhsType>
inline bool
operator> (DelayedLongProduct lhs, const RhsType& rhs) {
- return lhs.less(rhs);
+ return lhs.greater(rhs);
}
+
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_DelayedLongProduct_h_ */
diff --git a/groebner/include/polybori/groebner/Long64From32BitsPair.h b/groebner/include/polybori/groebner/Long64From32BitsPair.h
new file mode 100644
index 0000000..3d916cc
--- /dev/null
+++ b/groebner/include/polybori/groebner/Long64From32BitsPair.h
@@ -0,0 +1,69 @@
+// -*- c++ -*-
+//*****************************************************************************
+/** @file Long64From32BitsPair.h
+ *
+ * @author Alexander Dreyer
+ * @date 2012-02-23
+ *
+ * This file includes the definition of the class @c Long64From32BitsPair.
+ *
+ * @par Copyright:
+ * (c) 2012 by The PolyBoRi Team
+ *
+**/
+//*****************************************************************************
+
+#ifndef polybori_groebner_Long64From32BitsPair_h_
+#define polybori_groebner_Long64From32BitsPair_h_
+
+// include basic definitions
+#include "groebner_defs.h"
+#include "DelayedLongLong.h"
+#include "LongLongConstant.h"
+
+BEGIN_NAMESPACE_PBORIGB
+
+/** @class Long64From32BitsPairBase
+ * @brief This class defines an auxiliary class for @c Long64From32BitsPair.
+ *
+ **/
+
+template <DelayedLongLong::long_type High,
+ DelayedLongLong::long_type Low, unsigned SizeOfLong>
+class Long64From32BitsPairBase;
+
+
+template <DelayedLongLong::long_type High,
+ DelayedLongLong::long_type Low>
+class Long64From32BitsPairBase<High, Low, 4> {
+public:
+ static const LongLongConstant<High, Low> value;
+};
+
+
+template <DelayedLongLong::long_type High,
+ DelayedLongLong::long_type Low>
+class Long64From32BitsPairBase<High, Low, 8> {
+public:
+ typedef typename DelayedLongLong::long_type long_type;
+ static const long_type value = ((High << sizeof(long_type)*4) + Low);
+};
+
+/** @class Long64From32BitsPair
+ * @brief This class defines Long64From32BitsPair.
+ *
+ **/
+template <DelayedLongLong::long_type High,
+ DelayedLongLong::long_type Low>
+class Long64From32BitsPair:
+ public Long64From32BitsPairBase<High, Low,
+ sizeof(DelayedLongLong::long_type)> {
+public:
+ typedef typename DelayedLongLong::long_type long_type;
+
+};
+
+
+END_NAMESPACE_PBORIGB
+
+#endif /* polybori_groebner_Long64From32BitsPair_h_ */
diff --git a/groebner/include/polybori/groebner/LongLongConstant.h b/groebner/include/polybori/groebner/LongLongConstant.h
index 37cc390..8df2617 100644
--- a/groebner/include/polybori/groebner/LongLongConstant.h
+++ b/groebner/include/polybori/groebner/LongLongConstant.h
@@ -36,10 +36,10 @@ public:
static const long_type first = High;
static const long_type second = Low;
-#ifdef PBORI_HAVE_LONG_LONG
operator DelayedLongLong() const {
return DelayedLongLong(first, second);
}
+#ifdef PBORI_HAVE_LONG_LONG
operator unsigned long long() const {
return operator DelayedLongLong();
}
diff --git a/groebner/include/polybori/groebner/linear_algebra_step.h b/groebner/include/polybori/groebner/linear_algebra_step.h
index 5717348..0607a37 100644
--- a/groebner/include/polybori/groebner/linear_algebra_step.h
+++ b/groebner/include/polybori/groebner/linear_algebra_step.h
@@ -28,7 +28,7 @@
#include "BitMask.h"
#include "DelayedLongProduct.h"
-#include "LongLongConstant.h"
+#include "Long64From32BitsPair.h"
#ifdef PBORI_HAVE_NTL
#include <NTL/GF2.h>
@@ -266,9 +266,9 @@ linalg_step_modified(std::vector < Polynomial > &polys, MonomialSet terms, Monom
int unmodified_rows=polys.size();
int unmodified_cols=terms.size();
- /// This checks cols*rows > 20000000000ll = 4*2^32 + 2820130816
+ /// This checks cols*rows > 20000000000 = 4*2^32 + 2820130816
if (PBORI_UNLIKELY( (DelayedLongProduct(unmodified_cols, unmodified_rows) >
- LongLongConstant<4,2820130816>()) )){
+ Long64From32BitsPair<4u, 2820130816u>::value) )){
PBoRiError error(CTypes::matrix_size_exceeded);
throw error;
}
diff --git a/testsuite/src/DelayedLongProductTest.cc b/testsuite/src/DelayedLongProductTest.cc
index a986c66..82ec03b 100644
--- a/testsuite/src/DelayedLongProductTest.cc
+++ b/testsuite/src/DelayedLongProductTest.cc
@@ -24,6 +24,7 @@ USING_NAMESPACE_PBORI
USING_NAMESPACE_PBORIGB
struct Fdelayedlongprod {
+ typedef unsigned long long_type;
Fdelayedlongprod() {
BOOST_TEST_MESSAGE( "setup fixture" );
@@ -64,6 +65,24 @@ BOOST_AUTO_TEST_CASE(test_less) {
(unsigned long)(2)<<(sizeof(long)*4) )>
LongLongConstant<4,1>()), false);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, 7) > 34), true);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, 7) > 35), false);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, 7) > 36), false);
+
+ BOOST_CHECK_EQUAL((DelayedLongProduct(long_type(5)<<32, 7) >
+ long_type(34)<<32), true);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(long_type(5)<<32, 7) >
+ long_type(35)<<32), false);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(long_type(5)<<32, 7) >
+ long_type(36)<<32), false);
+
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, long_type(7)<<32) >
+ long_type(34)<<32), true);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, long_type(7)<<32) >
+ long_type(35)<<32), false);
+ BOOST_CHECK_EQUAL((DelayedLongProduct(5, long_type(7)<<32) >
+ long_type(36)<<32), false);
+
}
BOOST_AUTO_TEST_SUITE_END()
--
polybori: Polynomials over Boolean Rings
More information about the debian-science-commits
mailing list