[mathicgb] 16/393: Transformed PairQueue to use mathic::PairQueue in place of its own previous implementation.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:24 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 314fd4b4d3ede8fb2e853cce1c4c60df58aa9b8c
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Mon Aug 6 02:45:55 2012 -0400

    Transformed PairQueue to use mathic::PairQueue in place of its own previous implementation.
---
 Makefile.am                      |   6 +-
 src/mathicgb/BuchbergerAlg.cpp   |   2 +-
 src/mathicgb/FreeModuleOrder.cpp |  83 +--------------
 src/mathicgb/FreeModuleOrder.hpp |  12 ++-
 src/mathicgb/PairTriangle.cpp    | 216 +++++++++------------------------------
 src/mathicgb/PairTriangle.hpp    | 122 +++++++++++-----------
 src/mathicgb/SPairHandler.cpp    |  18 +---
 src/mathicgb/SPairHandler.hpp    |  24 +----
 src/mathicgb/SPairQueue.cpp      |   4 -
 src/mathicgb/SPairQueue.hpp      |  24 -----
 src/mathicgb/SPairs.cpp          |   4 -
 src/mathicgb/SPairs.hpp          |   2 +-
 src/mathicgb/SignatureGB.cpp     |   5 +-
 13 files changed, 124 insertions(+), 398 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 11651b1..bf63f52 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,9 +17,8 @@ libmathicgb_la_LIBADD= $(DEPS_LIBS)
 
 # the sources that are built to make libmathicgb. Listing the headers in
 # sources ensure that those files are included in distributions.
-libmathicgb_la_SOURCES = src/mathicgb/BjarkeGeobucket2.cpp			\
-  src/mathicgb/BjarkeGeobucket2.hpp 						\
-  src/mathicgb/BjarkeGeobucket.cpp				\
+libmathicgb_la_SOURCES = src/mathicgb/BjarkeGeobucket2.cpp				\
+  src/mathicgb/BjarkeGeobucket2.hpp src/mathicgb/BjarkeGeobucket.cpp	\
   src/mathicgb/BjarkeGeobucket.hpp src/mathicgb/BuchbergerAlg.cpp		\
   src/mathicgb/BuchbergerAlg.hpp src/mathicgb/ChainedHashTable.cpp		\
   src/mathicgb/ChainedHashTable.hpp src/mathicgb/DivisorLookup.cpp		\
@@ -51,7 +50,6 @@ libmathicgb_la_SOURCES = src/mathicgb/BjarkeGeobucket2.cpp			\
   src/mathicgb/ReducerPack.hpp src/mathicgb/ReducerPackDedup.hpp		\
   src/mathicgb/SignatureGB.cpp src/mathicgb/SignatureGB.hpp				\
   src/mathicgb/SPairHandler.cpp src/mathicgb/SPairHandler.hpp			\
-  src/mathicgb/SPairQueue.cpp src/mathicgb/SPairQueue.hpp				\
   src/mathicgb/SPairs.cpp src/mathicgb/SPairs.hpp						\
   src/mathicgb/stdinc.h src/mathicgb/TournamentReducer.cpp				\
   src/mathicgb/TournamentReducer.hpp
diff --git a/src/mathicgb/BuchbergerAlg.cpp b/src/mathicgb/BuchbergerAlg.cpp
old mode 100644
new mode 100755
index c128161..dc71d58
--- a/src/mathicgb/BuchbergerAlg.cpp
+++ b/src/mathicgb/BuchbergerAlg.cpp
@@ -216,7 +216,7 @@ void BuchbergerAlg::printStats(std::ostream& out) const {
 
   const size_t basisSize = mBasis.size();
   const double mseconds = mTimer.getMilliseconds();
-  const size_t pending = mSPairs.size();
+  const size_t pending = mSPairs.pairCount();
 
   name << "Time spent:\n";
   value << mTimer << '\n';
diff --git a/src/mathicgb/FreeModuleOrder.cpp b/src/mathicgb/FreeModuleOrder.cpp
old mode 100644
new mode 100755
index f532b72..4834cd8
--- a/src/mathicgb/FreeModuleOrder.cpp
+++ b/src/mathicgb/FreeModuleOrder.cpp
@@ -4,77 +4,10 @@
 #include <iostream>
 #include <algorithm>
 #include "FreeModuleOrder.hpp"
-#include "SPairQueue.hpp"
 #include "Poly.hpp"
 #include "Ideal.hpp"
 #include <mathic.h>
-
-namespace {
-  struct SizeSummer {
-  public:
-    SizeSummer(): mSum(0) {}
-    bool proceed(const SPairGroup* group) {
-      mSum += group->size();
-      return true;
-    }
-    size_t sum() const {return mSum;}
-  private:
-    size_t mSum;
-  };
-}
-
-template<class Cmp, template<class> class Queue = mathic::TourTree>
-class ConcreteQueue : public SPairQueue {
-public:
-  ConcreteQueue(const Cmp& cmp): mQueue(Configuration(cmp)) {}
-
-  virtual bool empty() const {return mQueue.empty();}
-  virtual void push(const Entry& entry) {mQueue.push(entry);}
-  virtual Entry pop() {return mQueue.pop();}
-  virtual Entry top() const {return mQueue.top();}
-  virtual void decreaseTop(const Entry& newValue) {
-    mQueue.decreaseTop(newValue);
-  }
-
-  virtual void print(std::ostream& out) const {mQueue.print(out);}
-  virtual std::string getName() const {return mQueue.getName();}
-  virtual size_t getMemoryUse() const {return mQueue.getMemoryUse();}
-  virtual size_t sumOfSizes() const {
-    SizeSummer summer;
-    mQueue.forAll(summer);
-    return summer.sum();
-  }
-
-private:
-  class Configuration {
-  public:
-    typedef SPairQueue::Entry Entry;
-
-    Configuration(const Cmp& cmp): mCmp(cmp) {}
-
-    typedef int CompareResult;
-    CompareResult compare(const Entry& a, const Entry& b) const {
-      return mCmp.signatureCompare(a->signature(), b->signature());
-    }
-    bool cmpLessThan(CompareResult r) const {return r == GT;}
-    bool cmpEqual(CompareResult r) const {
-      ASSERT(false); // not supposed to be used
-      return r == EQ;
-    }
-    Entry deduplicate(const Entry& a, const Entry& b) const {
-      ASSERT(false); // not supposed to be used
-      return a;
-    }
-
-    static const bool supportDeduplication = false;
-    static const bool fastIndex = true;
-
-  private:
-    const Cmp& mCmp;
-  };
-
-  Queue<Configuration> mQueue;
-};
+#include "PairTriangle.hpp"
 
 template<class Cmp>
 class ConcreteOrder : public FreeModuleOrder {
@@ -107,20 +40,6 @@ public:
     mCmp.appendBasisElement(m);
   }
 
-  virtual std::auto_ptr<SPairQueue> makeQueue(size_t queueType) const {
-    switch (queueType) {
-    case 0:
-      return std::auto_ptr<SPairQueue>
-        (new ConcreteQueue<Cmp, mic::TourTree>(mCmp));
-    case 1:
-      return std::auto_ptr<SPairQueue>
-        (new ConcreteQueue<Cmp, mic::Heap>(mCmp));
-    default:
-      mic::reportError("Unknown queue type.");
-      return std::auto_ptr<SPairQueue>(); // won't reach this far
-    }
-  }
-
   virtual std::string description() const {
     return mCmp.description();
   }
diff --git a/src/mathicgb/FreeModuleOrder.hpp b/src/mathicgb/FreeModuleOrder.hpp
old mode 100644
new mode 100755
index a39bd7f..60416f5
--- a/src/mathicgb/FreeModuleOrder.hpp
+++ b/src/mathicgb/FreeModuleOrder.hpp
@@ -4,13 +4,19 @@
 #define _free_module_order_h_
 
 #include "PolyRing.hpp"
-#include "PairTriangle.hpp"
 
 class PolyRing;
-class SPairQueue;
 class Ideal;
 typedef int FreeModuleOrderType;
 
+typedef unsigned short SmallIndex;
+typedef unsigned int BigIndex;
+
+struct PreSPair {
+  BigIndex i;
+  monomial signature;
+};
+
 class FreeModuleOrder
 {
 public:
@@ -39,8 +45,6 @@ public:
 
   virtual std::string description() const = 0;
 
-  virtual std::auto_ptr<SPairQueue> makeQueue(size_t type) const = 0;
-
   static FreeModuleOrder* makeOrder(FreeModuleOrderType type, const Ideal* I);
 
   static void displayOrderTypes(std::ostream &o);
diff --git a/src/mathicgb/PairTriangle.cpp b/src/mathicgb/PairTriangle.cpp
old mode 100644
new mode 100755
index af2e7be..f20c72c
--- a/src/mathicgb/PairTriangle.cpp
+++ b/src/mathicgb/PairTriangle.cpp
@@ -5,113 +5,11 @@
 #include <stdexcept>
 #include "FreeModuleOrder.hpp"
 
-SPairGroup::SPairGroup(
-  size_t fixedIndex,
-  monomial signature,
-  std::vector<PreSPair>& prePairs,
-  memt::Arena& arena
-):
-  mSignature(signature),
-  mFixedIndex(fixedIndex)
-{
-  const size_t prePairCount = prePairs.size();
-  if (big()) {
-    std::pair<BigIndex*, BigIndex*> range =
-      arena.allocArrayNoCon<BigIndex>(prePairCount);
-    for (size_t i = 0; i < prePairCount; ++i) {
-      ASSERT(prePairs[i].i < mFixedIndex);
-      ASSERT(prePairs[i].i <= std::numeric_limits<BigIndex>::max());
-      range.first[i] = prePairs[i].i;
-    }
-    bigBegin = range.first;
-    bigEnd = range.second;
-  } else {
-    std::pair<SmallIndex*, SmallIndex*> range =
-      arena.allocArrayNoCon<SmallIndex>(prePairCount);
-    for (size_t i = 0; i < prePairCount; ++i) {
-      ASSERT(prePairs[i].i < mFixedIndex);
-      ASSERT(prePairs[i].i <= std::numeric_limits<SmallIndex>::max());
-      range.first[i] = prePairs[i].i;
-    }
-    smallBegin = range.first;
-    smallEnd = range.second;
-  }
-  ASSERT(size() == prePairCount);
-  ASSERT(empty() == (prePairCount == 0));
-}
-
-void SPairGroup::write(const PolyRing* R, std::ostream& out) {
-  if (big()) {
-    for (BigIndex* f = bigBegin; f != bigEnd; f++) {
-      out << "  [" << fixedIndex() << " " << *f;
-      if (f == bigBegin)
-        R->monomialDisplay(out, signature());
-      out << "]" << std::endl;
-    }
-  } else {
-    for (SmallIndex* f = smallBegin; f != smallEnd; f++) {
-      out << "  [" << fixedIndex() << " " << *f;
-      if (f == smallBegin)
-        R->monomialDisplay(out, signature());
-      out << "]" << std::endl;
-    }
-  }
-}
-
-size_t SPairGroup::otherIndex() const {
-  ASSERT(!empty());
-  if (big())
-    return *bigBegin;
-  else
-    return *smallBegin;
-}
-
-void SPairGroup::increment() {
-  ASSERT(!empty());
-  do {
-    if (big())
-      ++bigBegin;
-    else
-      ++smallBegin;
-  } while (!empty() && otherIndex() == fixedIndex());
-}
-
-bool SPairGroup::empty() const {
-  if (big())
-    return bigBegin == bigEnd;
-  else
-    return smallBegin == smallEnd;
-}
-
-bool SPairGroup::big() const {
-  return mFixedIndex >
-    static_cast<size_t>(std::numeric_limits<SmallIndex>::max());
-}
-
-size_t SPairGroup::size() const {
-  if (big())
-    return bigEnd - bigBegin;
-  else
-    return smallEnd - smallBegin;
-}
-
 PairTriangle::PairTriangle(const FreeModuleOrder& order, const PolyRing& ring, size_t queueType):
-  mUseSingletonGroups((queueType & 2) != 0),
   mColumnCount(0),
-  mQueue(order.makeQueue((queueType & 1))),
   mOrder(order),
-  mRing(ring) {
-}
-
-PairTriangle::~PairTriangle() {
-}
-
-size_t PairTriangle::size() const {
-  size_t sum = 0;
-  for (size_t i = 0; i < mGroups.size(); ++i)
-    if (mGroups[i] != 0)
-      sum += mGroups[i]->size();
-  return sum;
+  mRing(ring),
+  mPairQueue(*this) {
 }
 
 void PairTriangle::beginColumn() {
@@ -137,90 +35,68 @@ void PairTriangle::addPair(size_t index, monomial orderBy) {
   mPrePairs.push_back(p);
 }
 
-void PairTriangle::endColumn() {
-  ++mColumnCount;
-  if (mPrePairs.empty())
-    return;
-
-  size_t const newGen = mColumnCount - 1;
-  if (mUseSingletonGroups) {
-    size_t const size = mPrePairs.size();
-    for (size_t i = 0; i < size; ++i) {
-      mGroups.push_back(mArena.allocObjectNoCon<SPairGroup>());
-      SPairGroup* p = mGroups.back();
-
-      ASSERT(mPrePairTmp.empty());
-      mPrePairTmp.push_back(mPrePairs[i]);
-      new (p) SPairGroup
-        (newGen, mPrePairTmp.front().signature, mPrePairTmp, mArena);
-      mPrePairTmp.clear();
-
-      calculateOrderBy(p->fixedIndex(), p->otherIndex(), p->signature());
-      mQueue->push(p);
-    }
-  } else {
-    mGroups.push_back(mArena.allocObjectNoCon<SPairGroup>());
-    SPairGroup* p = mGroups.back();
-
-    mOrder.destructiveSort(mPrePairs);
+namespace {
+  template<class PairIterator>
+  class IndexIterator {
+  public:
+	typedef typename PairIterator::iterator_category iterator_category;
+	typedef typename PairIterator::value_type value_type;
+	typedef typename PairIterator::difference_type difference_type;
+	typedef typename PairIterator::pointer pointer;
+	typedef typename PairIterator::reference reference;
+
+	IndexIterator(PairIterator pairIterator): mIterator(pairIterator) {}
+	IndexIterator& operator++() {++mIterator; return *this;}
+	size_t operator*() const {return mIterator->i;}
+	difference_type operator-(const IndexIterator<PairIterator>& it) const {
+	  return mIterator - it.mIterator;
+	}
+	bool operator==(const IndexIterator<PairIterator>& it) const {
+	  return mIterator == it.mIterator;
+	}
+	bool operator!=(const IndexIterator<PairIterator>& it) const {
+	  return mIterator != it.mIterator;
+	}
+
+  private:
+	PairIterator mIterator;
+  };
+}
 
-    // Take the very first one and insert it into the queue
-    new (p) SPairGroup(newGen, mPrePairs.front().signature, mPrePairs, mArena);
-    const size_t size = mPrePairs.size();
-    for (size_t i = 1; i < size; ++i)
-      mRing.freeMonomial(mPrePairs[i].signature);
+void PairTriangle::endColumn() {
+  mOrder.destructiveSort(mPrePairs);
+  typedef IndexIterator<std::vector<PreSPair>::const_iterator> Iter;
+  mPairQueue.addColumnDescending
+	(Iter(mPrePairs.begin()), Iter(mPrePairs.end()));
 
-    calculateOrderBy(p->fixedIndex(), p->otherIndex(), p->signature());
-    mQueue->push(p);
-  }
+  ++mColumnCount;
+  ASSERT(mColumnCount == columnCount());
+  for (std::vector<PreSPair>::iterator it = mPrePairs.begin();
+	   it != mPrePairs.end(); ++it)
+    mRing.freeMonomial(it->signature);
   mPrePairs.clear();
 }
 
 void PairTriangle::pop() {
-  ASSERT(!empty());
-
-  SPairGroup* topGroup = mQueue->top();
-  ASSERT(topGroup != 0);
-
-  while (true) {
-    topGroup->increment();
-    if (topGroup->empty()) {
-      mQueue->pop();
-      mRing.freeMonomial(topGroup->signature());
-      topGroup->setSignature(0);
-    } else {
-      // Compute the signature of the next S-pair in topGroup.
-      if (!calculateOrderBy
-        (topGroup->fixedIndex(), topGroup->otherIndex(), topGroup->signature()))
-        continue;
-      mQueue->decreaseTop(topGroup);
-    }
-    break;
-  }
+  mPairQueue.pop();
 }
 
 size_t PairTriangle::getMemoryUse() const {
-  return mArena.getMemoryUse() + mQueue->getMemoryUse();
+  return mPrePairs.capacity() * sizeof(mPrePairs.front()) +
+	mPairQueue.getMemoryUse();
 }
 
 std::string PairTriangle::name() const {
-  return mQueue->getName() + (mUseSingletonGroups ? "" : "-triangle");
+  return "todo";
+  // return mPairQueue.name();
 }
 
 std::pair<size_t, size_t> PairTriangle::topPair() const {
-  ASSERT(!mQueue->empty());
-  SPairGroup* group = mQueue->top();
-  ASSERT(group != 0);
-  ASSERT(!group->empty());
-  return std::make_pair(group->fixedIndex(), group->otherIndex());
+  return mPairQueue.topPair();
 }
 
 // Returns the minimal orderBy monomial along all pairs. This is the orderBy
 // monomial of topPair().
 const_monomial PairTriangle::topOrderBy() const {
-  ASSERT(!mQueue->empty());
-  SPairGroup* group = mQueue->top();
-  ASSERT(group != 0);
-  ASSERT(!group->empty());
-  return group->signature();
+  return mPairQueue.topPairData();
 }
diff --git a/src/mathicgb/PairTriangle.hpp b/src/mathicgb/PairTriangle.hpp
old mode 100644
new mode 100755
index b6b6c54..7d2040a
--- a/src/mathicgb/PairTriangle.hpp
+++ b/src/mathicgb/PairTriangle.hpp
@@ -1,84 +1,38 @@
 #ifndef _pair_triangle_h
 #define _pair_triangle_h
 
-#include "SPairQueue.hpp"
+#include <memtailor.h>
+#include <mathic.h>
 #include "PolyRing.hpp"
+#include "FreeModuleOrder.hpp"
 class FreeModuleOrder;
 
-typedef unsigned short SmallIndex;
+/*typedef unsigned short SmallIndex;
 typedef unsigned int BigIndex;
 
 // The following type is only used in the creation of SPairGroups
 struct PreSPair {
   BigIndex i;
   monomial signature;
-};
-
-class SPairGroup {
-public:
-  SPairGroup(size_t fixedIndex, monomial signature, std::vector<PreSPair>& prePairs, memt::Arena& arena);
-
-  monomial signature() {return mSignature;}
-  void setSignature(monomial signature) {mSignature = signature;}
-  const_monomial signature() const {return mSignature;}
-  size_t fixedIndex() const {return mFixedIndex;}
-  size_t otherIndex() const;
-
-  void increment();
-  bool empty() const;
-  size_t size() const; // number of S-pairs remaining in this group
+  };*/
 
-  void write(const PolyRing* R, std::ostream& out);
-
-private:
-  bool big() const;
-
-  monomial mSignature; // signature of the current pair
-  const size_t mFixedIndex; // all pairs here have this index
-
-  union {
-    BigIndex* bigBegin; // the current other index is *begin
-    SmallIndex* smallBegin;
-  };
-  union {
-    BigIndex* bigEnd; // the other indexes lie in [begin, end)
-    SmallIndex* smallEnd;
-  };
-};
-
-
-// Object that stores integer pairs.
-// The pairs are stored in the shape of a triangle:
-//
-//          3
-//        2 2
-//      1 1 1
-//    0 0 0 0
-//  ---------
-//  0 1 2 3 4
-//
-// So column a stores the numbers b such that (a,b) is a pair
-// with a > b. Not all pairs need be present, and there can be
-// any ordering of the entries in each column.
-//
-// PairTriangles are useful for storing S-pair indices, and the
-// class has code that helps with that.
+// Object that stores S-pairs and orders them according to a monomial
+// or signature.
 class PairTriangle {
 public:
   PairTriangle(
     const FreeModuleOrder& order,
     const PolyRing& ring,
     size_t queueType);
-  ~PairTriangle();
 
   // Returns how many columns the triangle has
-  size_t columnCount() const {return mColumnCount;}
+  size_t columnCount() const {return mPairQueue.columnCount();}
 
   // Returns how many pairs are in the triangle
-  size_t size() const;
+  size_t pairCount() const {return mPairQueue.pairCount();}
 
   // Returns true if there are no pairs in the triangle
-  bool empty() const {return mQueue->empty();}
+  bool empty() const {return mPairQueue.empty();}
 
   // Adds a new column of the triangle and opens it for addition of pairs.
   // This increases columnCount() by one, and the index of the new column
@@ -111,6 +65,7 @@ public:
   size_t getMemoryUse() const;
 
   std::string name() const;
+  size_t mColumnCount;
 
 protected:
   // Sub classes implement this to say what monomial each pair is ordered
@@ -121,15 +76,58 @@ protected:
   virtual bool calculateOrderBy(size_t a, size_t b, monomial orderBy) const = 0;
 
 private:
-  bool const mUseSingletonGroups;
-  size_t mColumnCount;
-  std::vector<SPairGroup*> mGroups;
-  std::auto_ptr<SPairQueue> mQueue;
-  memt::Arena mArena;
   FreeModuleOrder const& mOrder;
   std::vector<PreSPair> mPrePairs;
-  std::vector<PreSPair> mPrePairTmp;
   PolyRing const& mRing;
+
+  class PC {
+  public:
+	PC(PairTriangle const& tri): mTri(tri) {}
+	
+	typedef monomial PairData;
+	void computePairData(size_t col, size_t row, monomial m) {
+	  mTri.calculateOrderBy(col, row, m);
+	}
+
+	typedef bool CompareResult;
+	bool compare(int colA, int rowA, const_monomial a,
+				 int colB, int rowB, const_monomial b) const {
+	  return mTri.mOrder.signatureCompare(a, b) == GT;
+	}
+	bool cmpLessThan(bool v) const {return v;}
+
+	// these are not required for a configuration but we will use
+	// them from this code.
+	monomial allocPairData() {return mTri.mRing.allocMonomial();}
+	void freePairData(monomial m) {mTri.mRing.freeMonomial(m);}
+
+  private:
+	PairTriangle const& mTri;
+  };
+  mathic::PairQueue<PC> mPairQueue;
+  friend void mathic::PairQueueNamespace::constructPairData<PC>(void*,Index,Index,PC&);
+  friend void mathic::PairQueueNamespace::destructPairData<PC>(monomial*,Index,Index, PC&);
 };
 
+namespace mathic {
+  namespace PairQueueNamespace {
+	template<>
+	inline void constructPairData<PairTriangle::PC>
+	(void* memory, Index col, Index row, PairTriangle::PC& conf) {
+	  MATHICGB_ASSERT(memory != 0);
+	  MATHICGB_ASSERT(col > row);
+	  monomial* pd = new (memory) monomial(conf.allocPairData());
+	  conf.computePairData(col, row, *pd);
+	}
+
+	template<>
+	inline void destructPairData
+	(monomial* pd, Index col, Index row, PairTriangle::PC& conf) {
+	  MATHICGB_ASSERT(pd != 0);
+	  MATHICGB_ASSERT(col > row);
+	  conf.freePairData(*pd);
+	}	
+  }
+}
+
 #endif
diff --git a/src/mathicgb/SPairHandler.cpp b/src/mathicgb/SPairHandler.cpp
old mode 100644
new mode 100755
index a5e7619..f3c4468
--- a/src/mathicgb/SPairHandler.cpp
+++ b/src/mathicgb/SPairHandler.cpp
@@ -593,25 +593,9 @@ std::string SPairHandler::name() {
   return mTri.name();
 }
 
-void SPairHandler::write(std::ostream &out) const
-{
-  out << "-- spairs --" << std::endl;
-  // We write out all the pairs, one per line, in the form: [i j signature]
-  // We do each element of the heap:
-  for (size_t i = 0; i<heap.size(); i++)
-    heap[i]->write(R, out);
-}
-void SPairHandler::dump() const
-{
-  write(std::cerr);
-}
-
 size_t SPairHandler::getMemoryUse() const
 {
-  return
-    mTri.getMemoryUse() +
-    heap.capacity() * sizeof(heap.front()) +
-    getKnownSyzygyBitsMemoryUse();
+  return mTri.getMemoryUse() + getKnownSyzygyBitsMemoryUse();
 }
 
 size_t SPairHandler::getKnownSyzygyBitsMemoryUse() const {
diff --git a/src/mathicgb/SPairHandler.hpp b/src/mathicgb/SPairHandler.hpp
index 635db4d..6f69c69 100755
--- a/src/mathicgb/SPairHandler.hpp
+++ b/src/mathicgb/SPairHandler.hpp
@@ -12,7 +12,6 @@
 #include <vector>
 #include "PolyRing.hpp"
 #include "KoszulQueue.hpp"
-#include "SPairQueue.hpp"
 #include <mathic.h>
 #include <memtailor.h>
 
@@ -42,23 +41,8 @@ public:
   typedef std::vector<std::pair<size_t, size_t> > PairContainer;
   monomial popSignature(PairContainer& pairs);
 
+  // fills in all the S-pairs with i.
   void newPairs(size_t i);
-  // fills in the next SPairGroup
-  // loops through 0..i-1 making each pair
-  // do the following for each new pair:
-  // a. create it (meaning, find gcd, and two multipliers, and two signatures
-  // b. determine which one is larger, discard the other
-  // c. check if that signature is in the Hsyz module.
-  //    if so: throw it out
-  //    if not: insert it into the current vector
-  //            compute lead term of the corresponding Koszul syz
-  //            if that is not in Hsyz, then insert it.
-  // d. sort the vector of spairs
-  // e. insert the first one onto the spair heap
-
-  // debug display
-  void dump() const;
-  void write(std::ostream &out) const;
 
   // Set to true to enable hasEssentialPair().
   void setTrackEssentialPair(bool value);
@@ -104,7 +88,7 @@ public:
   };
   Stats getStats() const;
 
-  size_t size() const {return mTri.size();}
+  size_t pairCount() const {return mTri.pairCount();}
 
   size_t getMemoryUse() const;
   size_t getKnownSyzygyBitsMemoryUse() const;
@@ -136,8 +120,6 @@ private:
   // lead term of div. Only used if mTrackEssentialPair is true.
   std::vector<char> mDidReducingSPair;
 
-  bool increment(SPairGroup* p);
-
   void makePreSPairs(size_t newGen);
 
   struct BaseDivisor { // a low ratio base divisor
@@ -156,8 +138,6 @@ private:
 
   FreeModuleOrder *F;
 
-  std::vector<SPairGroup *> heap; // the actual heap
-
   // if true, apply the early singular criterion
   bool const mUseSingularCriterionEarly;
 
diff --git a/src/mathicgb/SPairQueue.cpp b/src/mathicgb/SPairQueue.cpp
deleted file mode 100644
index 13b13c0..0000000
--- a/src/mathicgb/SPairQueue.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "stdinc.h"
-#include "SPairQueue.hpp"
-
-#include <mathic.h>
diff --git a/src/mathicgb/SPairQueue.hpp b/src/mathicgb/SPairQueue.hpp
deleted file mode 100644
index 91abb47..0000000
--- a/src/mathicgb/SPairQueue.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _sPairQueue_h_
-#define _sPairQueue_h_
-
-#include <ostream>
-class SPairGroup;
-
-// Get concrete instances through a module order.
-class SPairQueue {
-public:
-  typedef SPairGroup* Entry;
-
-  virtual bool empty() const = 0;
-  virtual void push(const Entry& entry) = 0;
-  virtual Entry pop() = 0;
-  virtual Entry top() const = 0;
-  virtual void decreaseTop(const Entry& newValue) = 0;
-
-  virtual void print(std::ostream& out) const = 0;
-  virtual std::string getName() const = 0;
-  virtual size_t getMemoryUse() const = 0;
-  virtual size_t sumOfSizes() const = 0;
-};
-
-#endif
diff --git a/src/mathicgb/SPairs.cpp b/src/mathicgb/SPairs.cpp
index 82d17fa..01eccd4 100755
--- a/src/mathicgb/SPairs.cpp
+++ b/src/mathicgb/SPairs.cpp
@@ -36,10 +36,6 @@ std::pair<size_t, size_t> SPairs::pop() {
   return std::make_pair(static_cast<size_t>(-1), static_cast<size_t>(-1));
 }
 
-size_t SPairs::size() const {
-  return mTri.size();
-}
-
 namespace {
   // Records multiples of a basis element.
   // Used in addPairs().
diff --git a/src/mathicgb/SPairs.hpp b/src/mathicgb/SPairs.hpp
index 18ed5e5..98abd53 100755
--- a/src/mathicgb/SPairs.hpp
+++ b/src/mathicgb/SPairs.hpp
@@ -14,7 +14,7 @@ public:
   SPairs(const PolyBasis& basis, size_t queueType);
 
   // Returns the number of S-pairs in the data structure.
-  size_t size() const;
+  size_t pairCount() const {mTri.pairCount();}
 
   // Returns true if there all S-pairs have been eliminated or popped.
   bool empty() const {return mTri.empty();}
diff --git a/src/mathicgb/SignatureGB.cpp b/src/mathicgb/SignatureGB.cpp
old mode 100644
new mode 100755
index 6e4282c..dd54f30
--- a/src/mathicgb/SignatureGB.cpp
+++ b/src/mathicgb/SignatureGB.cpp
@@ -33,7 +33,7 @@ void SignatureGB::computeGrobnerBasis()
 
     if (mBreakAfter > 0 && GB->size() > mBreakAfter) {
       break;
-      const size_t pairs = SP->size();
+      const size_t pairs = SP->pairCount();
       size_t sigs = 0;
       size_t syzygySigs = 0;
       while (!SP->empty()) {
@@ -126,7 +126,6 @@ SignatureGB::SignatureGB(
     SP->newPairs(i);
 
   if (tracingLevel >= 2) {
-    SP->dump();
     Hsyz->dump();
   }
 }
@@ -501,7 +500,7 @@ void SignatureGB::displaySomeStats(std::ostream& out) const {
 
   const size_t basisSize = GB->size();
   const double mseconds = mTimer.getMilliseconds();
-  const size_t pending = SP->size();
+  const size_t pending = SP->pairCount();
 
   name << "Time spent:\n";
   value << mTimer << '\n';

-- 
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