[mathicgb] 282/393: Reduced another free module order to another one by preprocessing up front. In particular, by reversing and unreversing components.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:20 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 c10f39abb80bd46e47acf14a5da0367e80415f1a
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Thu Apr 18 16:02:13 2013 -0400

    Reduced another free module order to another one by preprocessing up front. In particular, by reversing and unreversing components.
---
 src/cli/SigGBAction.cpp          |  2 ++
 src/mathicgb/FreeModuleOrder.cpp |  2 +-
 src/mathicgb/GroebnerBasis.cpp   |  9 +++++++++
 src/mathicgb/GroebnerBasis.hpp   |  4 ++++
 src/mathicgb/SignatureGB.cpp     | 28 +++++++++++++++++++++-------
 src/mathicgb/SignatureGB.hpp     |  4 +++-
 src/test/FreeModuleOrderTest.cpp |  2 +-
 src/test/gb-test.cpp             |  4 +++-
 8 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/src/cli/SigGBAction.cpp b/src/cli/SigGBAction.cpp
index 8dad9df..04da797 100755
--- a/src/cli/SigGBAction.cpp
+++ b/src/cli/SigGBAction.cpp
@@ -57,6 +57,8 @@ void SigGBAction::performAction() {
     ideal = Ideal::parse(inputFile);
   }
   std::unique_ptr<PolyRing const> ring(&(ideal->ring()));
+  if (mModuleOrder.value() == 2)
+    ideal->reverse();
 
   SignatureGB alg(
     *ideal,
diff --git a/src/mathicgb/FreeModuleOrder.cpp b/src/mathicgb/FreeModuleOrder.cpp
index 7a68e95..fdd3cfb 100755
--- a/src/mathicgb/FreeModuleOrder.cpp
+++ b/src/mathicgb/FreeModuleOrder.cpp
@@ -709,7 +709,7 @@ std::unique_ptr<FreeModuleOrder> FreeModuleOrder::makeOrder(FreeModuleOrderType
     return make_unique<ConcreteOrder<OrderA>>(OrderA(I->getPolyRing()));
 
   case 2:
-   return make_unique<ConcreteOrder<OrderB>>(OrderB(I));
+    //return make_unique<ConcreteOrder<OrderB>>(OrderB(I));
   case 3:
    return make_unique<ConcreteOrder<OrderC>>(OrderC(I));
   case 4:
diff --git a/src/mathicgb/GroebnerBasis.cpp b/src/mathicgb/GroebnerBasis.cpp
index 357d257..d6c0d2c 100755
--- a/src/mathicgb/GroebnerBasis.cpp
+++ b/src/mathicgb/GroebnerBasis.cpp
@@ -416,6 +416,15 @@ void GroebnerBasis::unschreyer(const std::vector<Monomial>& leads) {
   }
 }
 
+void GroebnerBasis::reverseComponents(const size_t componentCount) {
+  for (size_t i = 0; i < mSignatures.size(); ++i) {
+    auto sig = mSignatures[i];
+    auto c = ring().monomialGetComponent(sig);
+    MATHICGB_ASSERT(c < componentCount);
+    ring().monomialChangeComponent(sig, componentCount - 1 - c);
+  }
+}
+
 size_t GroebnerBasis::getMemoryUse() const
 {
   // Note: we do not count the signatures as they are counted elsewhere.
diff --git a/src/mathicgb/GroebnerBasis.hpp b/src/mathicgb/GroebnerBasis.hpp
index 9af351b..598c5de 100755
--- a/src/mathicgb/GroebnerBasis.hpp
+++ b/src/mathicgb/GroebnerBasis.hpp
@@ -106,6 +106,10 @@ public:
   /// all sorts of internal invariants - it's a temporary hack.
   void unschreyer(const std::vector<Monomial>& leads);
 
+  // Replaces component i with componentCount - 1 - i. As unschreyer,
+  // this breaks internval invariants and should be replaced.
+  void reverseComponents(const size_t componentCount);
+
   class StoredRatioCmp {
   public:
     // Stores the ratio numerator/denominator and prepares it for comparing
diff --git a/src/mathicgb/SignatureGB.cpp b/src/mathicgb/SignatureGB.cpp
index 1a57d82..e892a0d 100755
--- a/src/mathicgb/SignatureGB.cpp
+++ b/src/mathicgb/SignatureGB.cpp
@@ -42,17 +42,23 @@ SignatureGB::SignatureGB(
   Hsyz(MonomialTableArray::make(R, montable_type, ideal.size(), !mPostponeKoszul)),
   Hsyz2(MonomialTableArray::make(R, montable_type, ideal.size(), !mPostponeKoszul)),
   reducer(Reducer::makeReducer(reductiontyp, *R)),
-  SP(make_unique<SigSPairs>(R, F.get(), GB.get(), Hsyz.get(), reducer.get(), mPostponeKoszul, mUseBaseDivisors, useSingularCriterionEarly, queueType))
+  SP(make_unique<SigSPairs>(R, F.get(), GB.get(), Hsyz.get(), reducer.get(), mPostponeKoszul, mUseBaseDivisors, useSingularCriterionEarly, queueType)),
+  mReverseComponents(typ == 2),
+  mComponentCount(ideal.size())
 {
   // Populate GB
-  for (size_t i = 0; i < ideal.size(); i++) {
+  for (size_t j = 0; j < ideal.size(); j++)
+    GB->addComponent();
+
+  for (size_t j = 0; j < ideal.size(); j++) {
+    int i = !mReverseComponents ? j : ideal.size() - 1 - j;
+
     Poly *g = new Poly(*R);
     ideal.getPoly(i)->copy(*g);
     g->makeMonic();
 
     monomial sig = 0;
     sig = R->allocMonomial();
-    GB->addComponent();
     R->monomialEi(i, sig);
     if (typ == 5) {
       auto lead = R->allocMonomial();
@@ -124,15 +130,23 @@ void SignatureGB::computeGrobnerBasis()
   stats_nsecs = mTimer.getMilliseconds() / 1000.0;
   //GB->displayBrief(out);
 
-  if (!mSchreyerTerms.empty()) {
+  if (!mSchreyerTerms.empty())
     GB->unschreyer(mSchreyerTerms);
+  if (mReverseComponents)
+    GB->reverseComponents(mComponentCount);
+  if (!mSchreyerTerms.empty() || mReverseComponents) {
     std::vector<const_monomial> v;
     Hsyz->getMonomials(v);
     for (size_t i = 0; i < v.size(); ++i) {
       auto sig = R->allocMonomial();
-      auto c = R->monomialGetComponent(v[i]);
-      MATHICGB_ASSERT(c < mSchreyerTerms.size());
-      R->monomialDivide(v[i], mSchreyerTerms[c], sig);
+      R->monomialCopy(v[i], sig);
+      auto c = R->monomialGetComponent(sig);
+      if (!mSchreyerTerms.empty()) {
+        MATHICGB_ASSERT(c < mSchreyerTerms.size());
+        R->monomialDivide(sig, mSchreyerTerms[c], sig);
+      }
+      if (mReverseComponents)
+        R->monomialChangeComponent(sig, mComponentCount - 1 - c);
       Hsyz2->insert(sig, 0);
     }
   }
diff --git a/src/mathicgb/SignatureGB.hpp b/src/mathicgb/SignatureGB.hpp
index 8546a7c..efc9f7e 100755
--- a/src/mathicgb/SignatureGB.hpp
+++ b/src/mathicgb/SignatureGB.hpp
@@ -43,7 +43,7 @@ public:
   unsigned long long getSingularReductionCount() const;
 
   GroebnerBasis* getGB() { return GB.get(); }
-  MonomialTableArray* getSyzTable() { return mSchreyerTerms.empty() ? Hsyz.get() : Hsyz2.get(); }
+  MonomialTableArray* getSyzTable() { return (mSchreyerTerms.empty() && !mReverseComponents) ? Hsyz.get() : Hsyz2.get(); }
   SigSPairs* getSigSPairs() { return SP.get(); }
 
   size_t getMemoryUse() const;
@@ -104,6 +104,8 @@ private:
   std::unique_ptr<Reducer> reducer;
   std::unique_ptr<SigSPairs> SP;
   std::vector<monomial> mSchreyerTerms;
+  const bool mReverseComponents;
+  const size_t mComponentCount;
 };
 
 #endif
diff --git a/src/test/FreeModuleOrderTest.cpp b/src/test/FreeModuleOrderTest.cpp
index 89a4351..10e7f15 100755
--- a/src/test/FreeModuleOrderTest.cpp
+++ b/src/test/FreeModuleOrderTest.cpp
@@ -87,7 +87,7 @@ TEST(FreeModuleOrder, One) {
     "ab2c<2>\n";
   
   runTest(ideal, sigs, "0 1 6 4 5 3 7 2", 1);
-  runTest(ideal, sigs, "0 6 5 1 4 3 7 2", 2); 
+  //runTest(ideal, sigs, "0 6 5 1 4 3 7 2", 2); 
   runTest(ideal, sigs, "0 6 5 1 7 4 3 2", 3); 
   runTest(ideal, sigs, "0 6 5 1 4 3 7 2", 4); 
 //  runTest(ideal, sigs, "0 6 5 1 4 7 3 2", 5); 
diff --git a/src/test/gb-test.cpp b/src/test/gb-test.cpp
index 1322585..6c5ca74 100755
--- a/src/test/gb-test.cpp
+++ b/src/test/gb-test.cpp
@@ -307,7 +307,9 @@ spairQueue	reducerType	divLookup	monTable	buchberger	postponeKoszul	useBaseDivis
         << reducerType << ' ' << divLookup << ' '
         << monTable << ' ' << postponeKoszul << ' ' << useBaseDivisors;
     } else {
-      SignatureGB basis
+      if (freeModuleOrder == 2)
+        I->reverse();
+     SignatureGB basis
         (*I, freeModuleOrder, Reducer::reducerType(reducerType),
          divLookup, monTable, postponeKoszul, useBaseDivisors,
          preferSparseReducers, useSingularCriterionEarly, spairQueue);

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