[mathicgb] 263/393: Reduced the interface and state of 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 dda2af64f8bd4acab6ba0df8cca57a283e704c4b
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Tue Apr 16 17:37:17 2013 -0400
Reduced the interface and state of PolyRing.
---
src/mathicgb/F4MatrixBuilder.cpp | 6 ------
src/mathicgb/F4MatrixBuilder2.cpp | 6 ------
src/mathicgb/MonomialHashTable.hpp | 3 +--
src/mathicgb/Poly.cpp | 1 -
src/mathicgb/PolyRing.cpp | 30 ++++++++++--------------------
src/mathicgb/PolyRing.hpp | 20 +++-----------------
src/test/F4MatrixReducer.cpp | 2 --
7 files changed, 14 insertions(+), 54 deletions(-)
diff --git a/src/mathicgb/F4MatrixBuilder.cpp b/src/mathicgb/F4MatrixBuilder.cpp
index 793a40a..a23b43e 100755
--- a/src/mathicgb/F4MatrixBuilder.cpp
+++ b/src/mathicgb/F4MatrixBuilder.cpp
@@ -100,7 +100,6 @@ void F4MatrixBuilder::addPolynomialToMatrix(const Poly& poly) {
void F4MatrixBuilder::addPolynomialToMatrix
(const_monomial multiple, const Poly& poly) {
- MATHICGB_ASSERT(ring().hashValid(multiple));
if (poly.isZero())
return;
@@ -109,7 +108,6 @@ void F4MatrixBuilder::addPolynomialToMatrix
task.poly = &poly;
task.desiredLead = ring().allocMonomial();
ring().monomialMult(poly.getLeadMonomial(), multiple, task.desiredLead);
- MATHICGB_ASSERT(ring().hashValid(task.desiredLead));
MATHICGB_ASSERT(task.sPairPoly == 0);
mTodo.push_back(task);
@@ -172,7 +170,6 @@ void F4MatrixBuilder::buildMatrixAndClear(QuadMatrix& matrix) {
else
ring().monomialDivide
(task.desiredLead, poly.getLeadMonomial(), data.tmp1);
- MATHICGB_ASSERT(ring().hashValid(data.tmp1));
if (task.addToTop)
appendRowTop(data.tmp1, *task.poly, builder, feeder);
else
@@ -250,7 +247,6 @@ F4MatrixBuilder::createColumn(
ring().monomialMult(monoA, monoB, mTmp);
if (!ring().monomialHasAmpleCapacity(mTmp))
mathic::reportError("Monomial exponent overflow in F4MatrixBuilder.");
- MATHICGB_ASSERT(ring().hashValid(mTmp));
// look for a reducer of mTmp
const size_t reducerIndex = mBasis.classicReducer(mTmp);
@@ -374,14 +370,12 @@ void F4MatrixBuilder::appendRowBottom(
) {
MATHICGB_ASSERT(!poly->isZero());
MATHICGB_ASSERT(!multiply.isNull());
- MATHICGB_ASSERT(ring().hashValid(multiply));
MATHICGB_ASSERT(sPairPoly != 0);
Poly::const_iterator itA = poly->begin();
const Poly::const_iterator endA = poly->end();
MATHICGB_ASSERT(!sPairPoly->isZero());
MATHICGB_ASSERT(!sPairMultiply.isNull());
- MATHICGB_ASSERT(ring().hashValid(sPairMultiply));
Poly::const_iterator itB = sPairPoly->begin();
Poly::const_iterator endB = sPairPoly->end();
diff --git a/src/mathicgb/F4MatrixBuilder2.cpp b/src/mathicgb/F4MatrixBuilder2.cpp
index fe16282..484332a 100755
--- a/src/mathicgb/F4MatrixBuilder2.cpp
+++ b/src/mathicgb/F4MatrixBuilder2.cpp
@@ -104,7 +104,6 @@ void F4MatrixBuilder2::addPolynomialToMatrix(const Poly& poly) {
void F4MatrixBuilder2::addPolynomialToMatrix
(const_monomial multiple, const Poly& poly) {
- MATHICGB_ASSERT(ring().hashValid(multiple));
if (poly.isZero())
return;
@@ -112,7 +111,6 @@ void F4MatrixBuilder2::addPolynomialToMatrix
task.poly = &poly;
task.desiredLead = ring().allocMonomial();
ring().monomialMult(poly.getLeadMonomial(), multiple, task.desiredLead);
- MATHICGB_ASSERT(ring().hashValid(task.desiredLead));
MATHICGB_ASSERT(task.sPairPoly == 0);
mTodo.push_back(task);
@@ -242,7 +240,6 @@ void F4MatrixBuilder2::buildMatrixAndClear(QuadMatrix& quadMatrix) {
else
ring().monomialDivide
(task.desiredLead, poly.getLeadMonomial(), data.tmp1);
- MATHICGB_ASSERT(ring().hashValid(data.tmp1));
appendRow(data.tmp1, *task.poly, data.block, feeder);
});
MATHICGB_ASSERT(!threadData.empty()); // as mTodo empty causes early return
@@ -327,7 +324,6 @@ F4MatrixBuilder2::createColumn(
ring().monomialMult(monoA, monoB, mTmp);
if (!ring().monomialHasAmpleCapacity(mTmp))
mathic::reportError("Monomial exponent overflow in F4MatrixBuilder2.");
- MATHICGB_ASSERT(ring().hashValid(mTmp));
// look for a reducer of mTmp
const size_t reducerIndex = mBasis.classicReducer(mTmp);
@@ -429,14 +425,12 @@ void F4MatrixBuilder2::appendRowSPair(
) {
MATHICGB_ASSERT(!poly->isZero());
MATHICGB_ASSERT(!multiply.isNull());
- MATHICGB_ASSERT(ring().hashValid(multiply));
MATHICGB_ASSERT(sPairPoly != 0);
Poly::const_iterator itA = poly->begin();
const Poly::const_iterator endA = poly->end();
MATHICGB_ASSERT(!sPairPoly->isZero());
MATHICGB_ASSERT(!sPairMultiply.isNull());
- MATHICGB_ASSERT(ring().hashValid(sPairMultiply));
Poly::const_iterator itB = sPairPoly->begin();
Poly::const_iterator endB = sPairPoly->end();
diff --git a/src/mathicgb/MonomialHashTable.hpp b/src/mathicgb/MonomialHashTable.hpp
old mode 100644
new mode 100755
index 3e0e22e..1d2f33d
--- a/src/mathicgb/MonomialHashTable.hpp
+++ b/src/mathicgb/MonomialHashTable.hpp
@@ -13,7 +13,7 @@ public:
typedef const_monomial KeyType;
typedef int ValueType;
- MonomialHashControl(const PolyRing *R) : R_(R), hash_index_(R->monomialHashIndex()) {}
+ MonomialHashControl(const PolyRing *R) : R_(R) {}
size_t hash_value(KeyType k) const { return R_->monomialHashValue(k); }
bool is_equal(KeyType k1, KeyType k2) const { return R_->monomialEQ(k1, k2); }
void combine(ValueType &, ValueType) const { }
@@ -24,7 +24,6 @@ public:
}
private:
const PolyRing *R_;
- size_t hash_index_;
};
typedef ChainedHashTable<MonomialHashControl> MonomialHashTableBasic;
diff --git a/src/mathicgb/Poly.cpp b/src/mathicgb/Poly.cpp
index 56dd8ac..5a8dcf8 100755
--- a/src/mathicgb/Poly.cpp
+++ b/src/mathicgb/Poly.cpp
@@ -282,7 +282,6 @@ void Poly::parseDoNotOrder(std::istream& i)
R->monomialParse(i, m);
else
R->monomialSetIdentity(m); // have to do this to set hash value
- MATHICGB_ASSERT(ring().hashValid(m));
next = i.peek();
if (next == '>')
i.get();
diff --git a/src/mathicgb/PolyRing.cpp b/src/mathicgb/PolyRing.cpp
index 1d423b9..84d765d 100755
--- a/src/mathicgb/PolyRing.cpp
+++ b/src/mathicgb/PolyRing.cpp
@@ -11,20 +11,14 @@
#include <cstdlib>
#include <limits>
-bool PolyRing::hashValid(const_monomial m) const {
- return monomialHashValue(m) == computeHashValue(m);
-}
-
PolyRing::PolyRing(const Field& field, const Monoid& monoid):
- mCharac(field.charac()),
+ mField(field),
+ mMonoid(monoid),
mNumWeights(monoid.gradingCount()),
mTopIndex(monoid.varCount() + mNumWeights),
- mHashIndex(monoid.varCount() + mNumWeights + 1),
mMaxMonomialSize(monoid.varCount() + mNumWeights + 2),
mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
- mMonomialPool(mMaxMonomialByteSize),
- mMonoid(monoid),
- mField(field)
+ mMonomialPool(mMaxMonomialByteSize)
{
}
@@ -33,30 +27,26 @@ PolyRing::PolyRing(
int nvars,
const std::vector<exponent>& weights
):
- mCharac(p0),
+ mField(p0),
+ mMonoid(nvars, weights),
mNumWeights(nvars == 0 ? 0 : weights.size() / nvars),
mTopIndex(nvars + mNumWeights),
- mHashIndex(nvars + mNumWeights + 1),
mMaxMonomialSize(nvars + mNumWeights + 2),
mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
- mMonomialPool(mMaxMonomialByteSize),
- mMonoid(nvars, weights),
- mField(p0)
+ mMonomialPool(mMaxMonomialByteSize)
{
}
PolyRing::PolyRing(coefficient p0,
int nvars,
- int nweights)
- : mCharac(p0),
+ int nweights):
+ mField(p0),
+ mMonoid(nvars),
mNumWeights(nweights),
mTopIndex(nvars + nweights),
- mHashIndex(nvars + nweights + 1),
mMaxMonomialSize(nvars + nweights + 2),
mMaxMonomialByteSize(mMaxMonomialSize * sizeof(exponent)),
- mMonomialPool(mMaxMonomialByteSize),
- mMonoid(nvars),
- mField(p0)
+ mMonomialPool(mMaxMonomialByteSize)
{
}
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index c523b0d..0275d5c 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -210,7 +210,7 @@ public:
return mMonomialPool.getMemoryUse();
}
- coefficient charac() const { return mCharac; }
+ coefficient charac() const { return mField.charac(); }
size_t getNumVars() const { return varCount();}
size_t varCount() const {return monoid().varCount();}
// const std::vector<int> °s,
@@ -309,8 +309,6 @@ public:
size_t maxMonomialSize() const { return mMaxMonomialSize; }
- size_t monomialHashIndex() const { return mHashIndex; }
-
///////////////////////////////////////////
// Monomial Routines //////////////////////
///////////////////////////////////////////
@@ -349,8 +347,6 @@ public:
inline void setHashOnly(Monomial& a) const;
- bool hashValid(const_monomial m) const;
-
// returns LT, EQ, or GT, depending on sig ? (m2 * sig2).
int monomialCompare(ConstMonomial a,
ConstMonomial b) const;
@@ -489,23 +485,17 @@ public:
const Field field() const {return mField;}
private:
- inline HashValue computeHashValue(const_monomial a1) const;
+ Field mField;
+ Monoid mMonoid;
- coefficient mCharac; // p=mCharac: ring is ZZ/p
size_t mNumWeights;
size_t mTopIndex;
- size_t mHashIndex; // 1 more than mTopIndex. Where the has value is stored.
size_t mMaxMonomialSize;
size_t mMaxMonomialByteSize;
- std::vector<HashValue> mHashVals; // one for each variable 0..mNumVars-1
- // stored as weightvec1 weightvec2 ...
-
mutable memt::BufferPool mMonomialPool;
mutable coefficientStats mStats;
- Monoid mMonoid;
- Field mField;
};
inline exponent PolyRing::weight(ConstMonomial a) const {
@@ -566,10 +556,6 @@ inline void PolyRing::setWeightsOnly(Monomial& a1) const
monoid().setOrderData(a1);
}
-inline HashValue PolyRing::computeHashValue(const_monomial a1) const {
- return monoid().computeHash(a1);
-}
-
inline void PolyRing::setHashOnly(Monomial& a1) const
{
monoid().setHash(a1);
diff --git a/src/test/F4MatrixReducer.cpp b/src/test/F4MatrixReducer.cpp
index 9d24f00..dcf7a4d 100755
--- a/src/test/F4MatrixReducer.cpp
+++ b/src/test/F4MatrixReducer.cpp
@@ -20,7 +20,6 @@ TEST(F4MatrixReducer, Reduce) {
size_t count = 0;
for (Poly::iterator it = p.begin(); it != p.end(); ++it) {
monomial mono = it.getMonomial();
- MATHICGB_ASSERT(ring->hashValid(mono));
if (count < 4)
m.leftColumnMonomials.push_back(mono);
else
@@ -125,4 +124,3 @@ TEST(F4MatrixReducer, Reduce) {
reduced.sortRowsByIncreasingPivots();
ASSERT_EQ(redStr, reduced.toString()) << "Printed reduced:\n" << reduced;
}
-
--
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