[mathicgb] 264/393: Removed computation of size of monomials from PolyRing.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:16 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 c2c3f84f6e0b61ae86f1f84da2d217b3ddb67ba8
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Tue Apr 16 17:45:19 2013 -0400

    Removed computation of size of monomials from PolyRing.
---
 src/mathicgb/Poly.hpp     |  2 +-
 src/mathicgb/PolyRing.cpp | 20 +++++++-------------
 src/mathicgb/PolyRing.hpp | 14 +++++---------
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/src/mathicgb/Poly.hpp b/src/mathicgb/Poly.hpp
index 657c148..823fa7d 100755
--- a/src/mathicgb/Poly.hpp
+++ b/src/mathicgb/Poly.hpp
@@ -177,7 +177,7 @@ inline void Poly::appendTerm(coefficient a, const_monomial m)
 {
   // the monomial will be copied on.
   coeffs.push_back(a);
-  size_t len = R->monomialSize(m);
+  size_t len = R->maxMonomialSize();
   exponent const * e = m.unsafeGetRepresentation();
   monoms.insert(monoms.end(), e, e + len);
 }
diff --git a/src/mathicgb/PolyRing.cpp b/src/mathicgb/PolyRing.cpp
index 84d765d..83597fb 100755
--- a/src/mathicgb/PolyRing.cpp
+++ b/src/mathicgb/PolyRing.cpp
@@ -16,9 +16,7 @@ PolyRing::PolyRing(const Field& field, const Monoid& monoid):
   mMonoid(monoid),
   mNumWeights(monoid.gradingCount()),
   mTopIndex(monoid.varCount() + mNumWeights),
-  mMaxMonomialSize(monoid.varCount() + mNumWeights + 2),
-  mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
-  mMonomialPool(mMaxMonomialByteSize)
+  mMonomialPool(maxMonomialByteSize())
 {
 }
 
@@ -31,9 +29,7 @@ PolyRing::PolyRing(
   mMonoid(nvars, weights),
   mNumWeights(nvars == 0 ? 0 : weights.size() / nvars),
   mTopIndex(nvars + mNumWeights),
-  mMaxMonomialSize(nvars + mNumWeights + 2),
-  mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
-  mMonomialPool(mMaxMonomialByteSize)
+  mMonomialPool(maxMonomialByteSize())
 {
 }
 
@@ -41,12 +37,10 @@ PolyRing::PolyRing(coefficient p0,
                    int nvars,
                    int nweights):
   mField(p0),
-    mMonoid(nvars),
-    mNumWeights(nweights),
-    mTopIndex(nvars + nweights),
-    mMaxMonomialSize(nvars + nweights + 2),
-    mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
-    mMonomialPool(mMaxMonomialByteSize)
+  mMonoid(nvars),
+  mNumWeights(nweights),
+  mTopIndex(nvars + nweights),
+  mMonomialPool(maxMonomialByteSize())
 {
 }
 
@@ -150,7 +144,7 @@ void PolyRing::monomialParse(std::istream &i,
 {
 //  monoid().parseM2(i, result);
   // first initialize result:
-  for (size_t j=0; j<mMaxMonomialSize; j++) result[j] = 0;
+  for (size_t j=0; j< maxMonomialSize(); j++) result[j] = 0;
 
   uint64 e;
   int v, x;
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index 0275d5c..84fe7d5 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -225,12 +225,12 @@ public:
   //  This monomial may only be freed if no other elements that were allocated
   // later are live on A.  In this case, use freeMonomial(A,m) to free 'm'.
   Monomial allocMonomial(memt::Arena &A) const {
-    exponent* ptr = static_cast<exponent*>(A.alloc(mMaxMonomialByteSize));
+    exponent* ptr = static_cast<exponent*>(A.alloc(maxMonomialByteSize()));
 #ifdef MATHICGB_DEBUG
     // fill with value that do not make sense to catch bugs in debug
     // mode. The maximum value of setting all bits increases the
     // chances of getting an assert.
-    std::fill_n(reinterpret_cast<char*>(ptr), mMaxMonomialByteSize,
+    std::fill_n(reinterpret_cast<char*>(ptr), maxMonomialByteSize(),
                 ~static_cast<char>(0));
 #endif
     return ptr;
@@ -256,7 +256,7 @@ public:
     // fill with value that do not make sense to catch bugs in debug
     // mode. The maximum value of setting all bits increases the
     // chances of getting an assert.
-    std::fill_n(reinterpret_cast<char*>(ptr), mMaxMonomialByteSize,
+    std::fill_n(reinterpret_cast<char*>(ptr), maxMonomialByteSize(),
                 ~static_cast<char>(0));
 #endif
     return ptr;
@@ -305,9 +305,9 @@ public:
   //  nterms comp v1 e1 ... v_nterms e_nterms
   // with each e_i nonzero, and v_1 > v_2 > ... > v_nterms
 
-  size_t maxMonomialByteSize() const { return mMaxMonomialByteSize; }
+  size_t maxMonomialByteSize() const { return maxMonomialSize() * sizeof(exponent); }
 
-  size_t maxMonomialSize() const { return mMaxMonomialSize; }
+  size_t maxMonomialSize() const { return monoid().entryCount(); }
 
   ///////////////////////////////////////////
   // Monomial Routines //////////////////////
@@ -369,8 +369,6 @@ public:
   /// as monomialEQ, but optimized for the case that the answer is true.
   bool monomialEqualHintTrue(ConstMonomial a, ConstMonomial b) const;
 
-  size_t monomialSize(ConstMonomial) const { return mMaxMonomialSize; }
-
   exponent monomialGetComponent(ConstMonomial a) const { return *a.mValue; }
 
   void monomialChangeComponent(Monomial a, int x) const {
@@ -490,8 +488,6 @@ private:
 
   size_t mNumWeights;
   size_t mTopIndex;
-  size_t mMaxMonomialSize;
-  size_t mMaxMonomialByteSize;
 
   mutable memt::BufferPool mMonomialPool;
   mutable coefficientStats mStats;

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