[mathicgb] 223/393: MonoMonoid now correctly uses less memory when the hash field is disabled. That was already the case for component and order.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:06 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 e6619bfb1801da6f6ee21d1d5be4f011952f6c26
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Thu Apr 4 14:32:06 2013 +0200

    MonoMonoid now correctly uses less memory when the hash field is disabled. That was already the case for component and order.
---
 src/mathicgb/MonoMonoid.hpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/mathicgb/MonoMonoid.hpp b/src/mathicgb/MonoMonoid.hpp
index 88c1d45..ec54cf9 100755
--- a/src/mathicgb/MonoMonoid.hpp
+++ b/src/mathicgb/MonoMonoid.hpp
@@ -261,13 +261,15 @@ public:
     // It is OK that the degree field can be negative (a field we might go
     // into without caring about it because it shares a 64 bit field with
     // the last exponent), because it is at the end so the overflowing
-    // bit will not interfere.
+    // bit will not interfere. For this reason we need to have a degree
+    // or a hash value stored there - otherwise two equal monomials could
+    // have different things stored next to them which would confuse this code.
     
     // todo: ensure 8 byte alignment. Though there seem to be no ill effects
     // for unaligned access. Performance seems to be no worse than for using
     // 32 bit integers directly.
 
-    if (sizeof(Exponent) != 4)
+    if (sizeof(Exponent) != 4 || (!StoreHash && !StoreOrder))
       return isProductOf(a, b, ab);
 
     uint64 orOfXor = 0;
@@ -296,7 +298,7 @@ public:
     ConstMonoRef a1b,
     ConstMonoRef a2b
   ) const {
-    if (sizeof(Exponent) != 4)
+    if (sizeof(Exponent) != 4 || (!StoreHash && !StoreOrder))
       return (isProductOf(a1, b, a1b) && isProductOf(a2, b, a2b));
 
     uint64 orOfXor = 0;
@@ -999,7 +1001,7 @@ private:
     // Check assumptions for layout in memory.
     MATHICGB_ASSERT(orderIndexBegin() == exponentsIndexEnd());
     MATHICGB_ASSERT(orderIndexBegin() + orderEntryCount() == orderIndexEnd());
-    MATHICGB_ASSERT(orderIndexEnd() < entryCount());
+    MATHICGB_ASSERT(orderIndexEnd() <= entryCount());
     MATHICGB_ASSERT(orderEntryCount() == 1);
 
     if (mGradingIsTotalDegree)
@@ -1122,7 +1124,7 @@ private:
   /// Returns how many Exponents are necessary to store a
   /// monomial. This can include other data than the exponents, so
   /// this number can be larger than varCount().
-  size_t entryCount() const {return mOrderIndexEnd + 1;}
+  size_t entryCount() const {return mOrderIndexEnd + StoreHash;}
 
   /// Returns how many Exponents are necessary to store the extra data
   /// used to compare monomials quickly.

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