[mathicgb] 317/393: Moved KoszulQueue to using Monoid fully, made it movable and changed to use its own MonoPool.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.

commit f70dcf3e427b3cd2451d0dba8b939010916b55a0
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Sat May 11 14:45:55 2013 +0200

    Moved KoszulQueue to using Monoid fully, made it movable and changed to use its own MonoPool.
---
 src/mathicgb/KoszulQueue.hpp | 39 ++++++++++++++++++++++-----------------
 src/mathicgb/MonoMonoid.hpp  | 13 ++++++++-----
 src/mathicgb/SignatureGB.cpp |  7 +++----
 3 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/src/mathicgb/KoszulQueue.hpp b/src/mathicgb/KoszulQueue.hpp
index bc98602..78986e7 100755
--- a/src/mathicgb/KoszulQueue.hpp
+++ b/src/mathicgb/KoszulQueue.hpp
@@ -10,24 +10,32 @@ public:
   typedef PolyRing::Monoid Monoid;
   typedef Monoid::Mono Mono;
   typedef Monoid::ConstMonoRef ConstMonoRef;
+  typedef Monoid::MonoPool MonoPool;
 
-  KoszulQueue(const Monoid& monoid): mQueue(Configuration(monoid)) {}
-  KoszulQueue(KoszulQueue&& kq): mQueue(std::move(kq.mQueue)) {}
+  KoszulQueue(const Monoid& monoid):
+    mPool(monoid),
+    mQueue(Configuration(monoid, mPool))
+  {}
+
+  KoszulQueue(KoszulQueue&& kq):
+    mQueue(std::move(kq.mQueue)),
+    mPool(std::move(kq.mPool))
+  {}
 
   ConstMonoRef top() const {
     MATHICGB_ASSERT(!empty());
-    return mQueue.top();
+    return *mQueue.top();
   }
 
   void pop() {
     MATHICGB_ASSERT(!empty());
-    monoid().freeRaw(mQueue.pop());
+    mPool.freeRaw(*mQueue.pop());
   }
 
   void push(ConstMonoRef sig) {
-    auto m = monoid().alloc();
+    auto m = mPool.alloc();
     monoid().copy(sig, m);
-    mQueue.push(*m.release());
+    mQueue.push(m.release());
   }
   bool empty() const {return mQueue.empty();}
   size_t size() const {return mQueue.size();}
@@ -39,13 +47,14 @@ public:
 private:
   class Configuration {
   public:
-    typedef Monoid::MonoRef Entry;
+    typedef Monoid::MonoPtr Entry;
 
-    Configuration(const Monoid& monoid): mMonoid(monoid) {}
+    Configuration(const Monoid& monoid, MonoPool& pool):
+      mMonoid(monoid), mPool(pool) {}
 
     typedef Monoid::CompareResult CompareResult;
     CompareResult compare(const Entry& a, const Entry& b) const {
-      return ring().monoid().compare(a, b);
+      return monoid().compare(*a, *b);
     }
     bool cmpLessThan(CompareResult r) const {return r == Monoid::GreaterThan;}
 
@@ -53,9 +62,8 @@ private:
     static const bool supportDeduplication = true;
     bool cmpEqual(CompareResult r) const {return r == Monoid::EqualTo;}
 
-    Entry deduplicate(Entry a, Entry b)
-    {
-      monoid().freeRaw(b);
+    Entry deduplicate(Entry a, Entry b) {
+      mPool.freeRaw(*b);
       return a;
     }
 
@@ -63,14 +71,11 @@ private:
 
   private:
     const Monoid& mMonoid;
+    MonoPool& mPool;
   };
 
+  MonoPool mPool;
   mic::Heap<Configuration> mQueue;
 };
 
 #endif
-
-// Local Variables:
-// compile-command: "make -C .. "
-// indent-tabs-mode: nil
-// End:
diff --git a/src/mathicgb/MonoMonoid.hpp b/src/mathicgb/MonoMonoid.hpp
index 67b5792..c81b60a 100755
--- a/src/mathicgb/MonoMonoid.hpp
+++ b/src/mathicgb/MonoMonoid.hpp
@@ -1227,11 +1227,17 @@ public:
 
   // *** Classes that provide memory resources for monomials
 
-  class MonoPool {
+  class MonoPool : public NonCopyable<MonoPool> {
   public:
     MonoPool(const MonoMonoid& monoid):
       mMonoid(monoid),
-      mPool(sizeof(Exponent) * mMonoid.entryCount()) {}
+      mPool(sizeof(Exponent) * mMonoid.entryCount())
+    {}
+
+    MonoPool(MonoPool&& pool):
+      mMonoid(pool.mMonoid),
+      mPool(std::move(pool.mPool))
+    {}
 
     Mono alloc() {
       const auto ptr = static_cast<Exponent*>(mPool.alloc());
@@ -1256,9 +1262,6 @@ public:
     }
 
   private:
-    MonoPool(const MonoPool&); // not available
-    void operator=(const MonoPool&); // not available
-
     const MonoMonoid& mMonoid;
     memt::BufferPool mPool;
   };
diff --git a/src/mathicgb/SignatureGB.cpp b/src/mathicgb/SignatureGB.cpp
index 748dd2f..de915a5 100755
--- a/src/mathicgb/SignatureGB.cpp
+++ b/src/mathicgb/SignatureGB.cpp
@@ -38,7 +38,7 @@ SignatureGB::SignatureGB(
   stats_pairsReduced(0),
   stats_nsecs(0.0),
   GB(make_unique<GroebnerBasis>(R, F.get(), divlookup_type, montable_type, preferSparseReducers)),
-  mKoszuls(*R),
+  mKoszuls(R->monoid()),
   Hsyz(MonomialTableArray::make(R, montable_type, basis.size(), !mPostponeKoszul)),
   Hsyz2(MonomialTableArray::make(R, montable_type, basis.size(), !mPostponeKoszul)),
   reducer(Reducer::makeReducer(reductiontyp, *R)),
@@ -222,13 +222,12 @@ bool SignatureGB::step()
 
   // Not a known syzygy
 
-  while (!mKoszuls.empty()
-         && F->signatureCompare(mKoszuls.top(), sig) == LT)
+  while (!mKoszuls.empty() && R->monoid().lessThan(mKoszuls.top(), sig))
     {
       mKoszuls.pop();
     }
 
-  if (!mKoszuls.empty() && R->monomialEQ(mKoszuls.top(), sig))
+  if (!mKoszuls.empty() && R->monoid().equal(mKoszuls.top(), sig))
     {
       ++stats_koszulEliminated;
       // This signature is of a syzygy that is not in Hsyz, so add it

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git



More information about the debian-science-commits mailing list