[mathicgb] 52/393: Now makes a new matrix for each degree. This is a speed up on homogenous ideals though it needs to be turned off for non-homogenous matrices - currently there is no option to do so.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:31 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 4c8ffc7bf48ea3e9f27ec367b7592281e6b4f82b
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Sun Oct 7 13:18:47 2012 +0200

    Now makes a new matrix for each degree. This is a speed up on homogenous ideals though it needs to be turned off for non-homogenous matrices - currently there is no option to do so.
---
 src/mathicgb/BuchbergerAlg.cpp |  4 +++-
 src/mathicgb/PolyRing.hpp      |  9 +++++++++
 src/mathicgb/SPairs.cpp        | 31 +++++++++++++++++++++++++++++++
 src/mathicgb/SPairs.hpp        |  5 +++++
 4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/mathicgb/BuchbergerAlg.cpp b/src/mathicgb/BuchbergerAlg.cpp
index d51d429..4e353e6 100755
--- a/src/mathicgb/BuchbergerAlg.cpp
+++ b/src/mathicgb/BuchbergerAlg.cpp
@@ -248,8 +248,10 @@ void BuchbergerAlg::step() {
     }
   } else {
     std::vector<std::pair<size_t, size_t> > spairGroup;
+    exponent w = 0;
     for (unsigned int i = 0; i < mSPairGroupSize; ++i) {
-      std::pair<size_t, size_t> p = mSPairs.pop();
+      std::pair<size_t, size_t> p;
+      p = mSPairs.pop(w);
       if (p.first == static_cast<size_t>(-1)) {
         ASSERT(p.second == static_cast<size_t>(-1));
         break; // no more S-pairs
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index a1bb68b..f00f4a6 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -334,6 +334,10 @@ public:
                                       ConstMonomial baseDivLead,
                                       Monomial result) const;
 
+  // Returns the weight (degree) of a. Takes the first weight if
+  // working with several weight vectors.
+  exponent weight(ConstMonomial a) const;
+
   void setWeightsAndHash(Monomial& a) const;
 
   inline void setWeightsOnly(Monomial& a) const;
@@ -566,6 +570,11 @@ private:
   bool mTotalDegreeGradedOnly;
 };
 
+inline exponent PolyRing::weight(ConstMonomial a) const {
+  MATHICGB_ASSERT(weightsCorrect(a));
+  return a[mNumVars + 1];
+}
+
 ////////////////////////////////////////////////
 // New Monomial Routines ///////////////////////
 ////////////////////////////////////////////////
diff --git a/src/mathicgb/SPairs.cpp b/src/mathicgb/SPairs.cpp
index 99edbc6..d39d720 100755
--- a/src/mathicgb/SPairs.cpp
+++ b/src/mathicgb/SPairs.cpp
@@ -36,6 +36,37 @@ std::pair<size_t, size_t> SPairs::pop() {
   return std::make_pair(static_cast<size_t>(-1), static_cast<size_t>(-1));
 }
 
+std::pair<size_t, size_t> SPairs::pop(exponent& w) {
+  // Must call addPairs for new elements before popping.
+  ASSERT(mEliminated.columnCount() == mBasis.size());
+
+  while (!mTri.empty()) {
+    std::pair<size_t, size_t> p;
+    p = mTri.topPair();
+    if (mBasis.retired(p.first) || mBasis.retired(p.second)) {
+      mTri.pop();
+      continue;
+    }
+    const_monomial lcm = mTri.topOrderBy();
+    ASSERT(mRing.monomialIsLeastCommonMultiple
+      (mBasis.leadMonomial(p.first),
+      mBasis.leadMonomial(p.second), lcm));
+    // Can't pop before done with lcm as popping overwrites lcm.
+    if (advancedBuchbergerLcmCriterion(p.first, p.second, lcm)) {
+      mTri.pop();
+      continue;
+    }
+    if (w == 0)
+      w = mRing.weight(lcm);
+    else if (w != mRing.weight(lcm))
+      break;
+    mTri.pop();
+    mEliminated.setBit(p.first, p.second, true);
+    return p;
+  }
+  return std::make_pair(static_cast<size_t>(-1), static_cast<size_t>(-1));
+}
+
 namespace {
   // Records multiples of a basis element.
   // Used in addPairs().
diff --git a/src/mathicgb/SPairs.hpp b/src/mathicgb/SPairs.hpp
index 98abd53..6da2bc2 100755
--- a/src/mathicgb/SPairs.hpp
+++ b/src/mathicgb/SPairs.hpp
@@ -31,6 +31,11 @@ public:
   // the queue may have been found to be useless.
   std::pair<size_t, size_t> pop();
 
+  // As pop(), but only pops S-pairs whose lcm have the passed-in
+  // weight. If deg is already 0, then instead set deg to the weight
+  // of the returned S-pair, if any.
+  std::pair<size_t, size_t> pop(exponent& w);
+
   // Add the pairs (index,a) to the data structure for those a such that
   // a < index. Some of those pairs may be eliminated if they can be proven
   // to be useless. index must be a valid index of a basis element

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