[mathicgb] 368/393: Removed PairTriangle as it is no longer used (it's replaced by the mathic version). Also tiny amount of clean-up.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:35 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 28fb618d84f80f33c407fa1f46e25e1d3f8cc7fc
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Tue Sep 17 15:47:35 2013 +0200
Removed PairTriangle as it is no longer used (it's replaced by the mathic version). Also tiny amount of clean-up.
---
Makefile.am | 3 +-
build/vs12/mathicgb-lib/mathicgb-lib.vcxproj | 2 -
.../vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters | 6 -
src/mathicgb/F4MatrixBuilder2.cpp | 2 +-
src/mathicgb/F4MatrixProjection.cpp | 14 +--
src/mathicgb/F4MatrixProjection.hpp | 2 +-
src/mathicgb/PairTriangle.cpp | 112 -----------------
src/mathicgb/PairTriangle.hpp | 139 ---------------------
8 files changed, 9 insertions(+), 271 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index d68796f..f8273a8 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,8 +21,7 @@ libmathicgb_la_SOURCES = src/mathicgb/ReducerPack.hpp \
src/mathicgb/Basis.cpp src/mathicgb/Basis.hpp \
src/mathicgb/io-util.cpp src/mathicgb/io-util.hpp \
src/mathicgb/KoszulQueue.hpp src/mathicgb/ModuleMonoSet.cpp \
- src/mathicgb/ModuleMonoSet.hpp src/mathicgb/PairTriangle.cpp \
- src/mathicgb/PairTriangle.hpp src/mathicgb/Poly.cpp \
+ src/mathicgb/ModuleMonoSet.hpp src/mathicgb/Poly.cpp \
src/mathicgb/Poly.hpp src/mathicgb/PolyBasis.cpp \
src/mathicgb/PolyBasis.hpp src/mathicgb/PolyHashTable.cpp \
src/mathicgb/PolyHashTable.hpp src/mathicgb/PolyRing.cpp \
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
index b56418d..3236d3c 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
@@ -454,7 +454,6 @@
<ClCompile Include="..\..\..\src\mathicgb\LogDomainSet.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\ModuleMonoSet.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\MonoLookup.cpp" />
- <ClCompile Include="..\..\..\src\mathicgb\PairTriangle.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\Poly.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\PolyBasis.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\PolyHashTable.cpp" />
@@ -503,7 +502,6 @@
<ClInclude Include="..\..\..\src\mathicgb\MonoProcessor.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\mtbb.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\NonCopyable.hpp" />
- <ClInclude Include="..\..\..\src\mathicgb\PairTriangle.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\Poly.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\PolyBasis.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\PolyHashTable.hpp" />
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
index 4005f21..e8f37ab 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
@@ -23,9 +23,6 @@
<ClCompile Include="..\..\..\src\mathicgb\io-util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\mathicgb\PairTriangle.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\mathicgb\Poly.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -139,9 +136,6 @@
<ClInclude Include="..\..\..\src\mathicgb\KoszulQueue.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\src\mathicgb\PairTriangle.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\src\mathicgb\Poly.hpp">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/src/mathicgb/F4MatrixBuilder2.cpp b/src/mathicgb/F4MatrixBuilder2.cpp
index 1588abf..dcd4f40 100755
--- a/src/mathicgb/F4MatrixBuilder2.cpp
+++ b/src/mathicgb/F4MatrixBuilder2.cpp
@@ -227,7 +227,7 @@ public:
const auto colEnd = columns.end();
for (auto it = columns.begin(); it != colEnd; ++it) {
const auto p = *it;
- projection.addColumn(p.first, Monoid::toOld(*p.second), mIsColumnToLeft[p.first]);
+ projection.addColumn(p.first, *p.second, mIsColumnToLeft[p.first]);
}
quadMatrix = projection.makeAndClear(mMemoryQuantum);
diff --git a/src/mathicgb/F4MatrixProjection.cpp b/src/mathicgb/F4MatrixProjection.cpp
index 5e186a5..5f9ac15 100755
--- a/src/mathicgb/F4MatrixProjection.cpp
+++ b/src/mathicgb/F4MatrixProjection.cpp
@@ -17,29 +17,27 @@ F4MatrixProjection::F4MatrixProjection(
void F4MatrixProjection::addColumn(
const ColIndex projectFrom,
- const const_monomial mono,
+ ConstMonoRef mono,
const bool isLeft
) {
MATHICGB_ASSERT(projectFrom < mColProjectTo.size());
MATHICGB_ASSERT
(mLeftMonomials.size() + mRightMonomials.size() < mColProjectTo.size());
- auto monoCopy = mRing.allocMonomial();
- MATHICGB_SCOPE_EXIT(monoGuard) {mRing.freeMonomial(monoCopy);};
- mRing.monomialCopy(mono, monoCopy);
+ auto monoCopy = mRing.monoid().alloc();
+ mRing.monoid().copy(mono, *monoCopy);
auto& projected = mColProjectTo[projectFrom];
if (isLeft) {
projected.isLeft = true;
projected.index = static_cast<ColIndex>(mLeftMonomials.size());
- mLeftMonomials.push_back(monoCopy);
+ mLeftMonomials.push_back(monoCopy.ptr());
} else {
projected.isLeft = false;
projected.index = static_cast<ColIndex>(mRightMonomials.size());
- mRightMonomials.push_back(monoCopy);
+ mRightMonomials.push_back(monoCopy.ptr());
}
-
- monoGuard.dismiss();
+ monoCopy.release();
}
struct RowData : F4ProtoMatrix::Row {
diff --git a/src/mathicgb/F4MatrixProjection.hpp b/src/mathicgb/F4MatrixProjection.hpp
index cddcd2d..d6e790b 100755
--- a/src/mathicgb/F4MatrixProjection.hpp
+++ b/src/mathicgb/F4MatrixProjection.hpp
@@ -30,7 +30,7 @@ public:
void addProtoMatrix(F4ProtoMatrix&& matrix) {mMatrices.push_back(&matrix);}
// No reference to mono is retained.
- void addColumn(ColIndex index, const_monomial mono, const bool isLeft);
+ void addColumn(ColIndex index, ConstMonoRef mono, const bool isLeft);
QuadMatrix makeAndClear(const size_t quantum);
diff --git a/src/mathicgb/PairTriangle.cpp b/src/mathicgb/PairTriangle.cpp
deleted file mode 100755
index 715169c..0000000
--- a/src/mathicgb/PairTriangle.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// MathicGB copyright 2012 all rights reserved. MathicGB comes with ABSOLUTELY
-// NO WARRANTY and is licensed as GPL v2.0 or later - see LICENSE.txt.
-#include "stdinc.h"
-#include "PairTriangle.hpp"
-
-#include <limits>
-#include <stdexcept>
-
-MATHICGB_NAMESPACE_BEGIN
-
-PairTriangle::PairTriangle(const PolyRing& ring, size_t queueType):
- mColumnCount(0),
- mRing(ring),
- mPairQueue(*this) {
-}
-
-void PairTriangle::beginColumn() {
- MATHICGB_ASSERT(mPrePairs.empty());
- size_t const maxBigIndex = std::numeric_limits<BigIndex>::max();
- if (mColumnCount >= maxBigIndex)
- throw std::overflow_error
- ("Too large basis element index in constructing S-pairs.");
-}
-
-void PairTriangle::addPair(size_t index, monomial orderBy) {
- MATHICGB_ASSERT(index < mColumnCount);
-#ifdef DEBUG
- monomial tmp = mRing.allocMonomial();
- calculateOrderBy(mColumnCount, index, tmp);
- MATHICGB_ASSERT(mRing.monomialEQ(tmp, orderBy));
- mRing.freeMonomial(tmp);
-#endif
-
- PreSPair p;
- p.i = static_cast<BigIndex>(index);
- p.signature = orderBy;
- mPrePairs.push_back(p);
-}
-
-namespace {
- // Iterator that accesses the field i based on a passed-in iterator.
- template<class PairIterator>
- class IndexIterator {
- public:
- typedef typename PairIterator::iterator_category iterator_category;
- typedef decltype(reinterpret_cast<typename PairIterator::value_type*>(0)->i) value_type;
- typedef typename PairIterator::difference_type difference_type;
- typedef value_type* pointer;
- typedef value_type& reference;
-
- IndexIterator(PairIterator pairIterator): mIterator(pairIterator) {}
- IndexIterator& operator++() {++mIterator; return *this;}
- const value_type operator*() const {return mIterator->i;}
- difference_type operator-(const IndexIterator<PairIterator>& it) const {
- return mIterator - it.mIterator;
- }
- bool operator==(const IndexIterator<PairIterator>& it) const {
- return mIterator == it.mIterator;
- }
- bool operator!=(const IndexIterator<PairIterator>& it) const {
- return mIterator != it.mIterator;
- }
-
- private:
- PairIterator mIterator;
- };
-}
-
-void PairTriangle::endColumn() {
- const auto& monoid = mRing.monoid();
- const auto cmp = [&monoid](const PreSPair& a, const PreSPair& b) {
- return monoid.lessThan(a.signature, b.signature);
- };
- std::sort(mPrePairs.begin(), mPrePairs.end(), cmp);
-
- typedef IndexIterator<std::vector<PreSPair>::const_iterator> Iter;
- mPairQueue.addColumnDescending
- (Iter(mPrePairs.begin()), Iter(mPrePairs.end()));
-
- ++mColumnCount;
- MATHICGB_ASSERT(mColumnCount == columnCount());
- for (std::vector<PreSPair>::iterator it = mPrePairs.begin();
- it != mPrePairs.end(); ++it)
- mRing.freeMonomial(it->signature);
- mPrePairs.clear();
-}
-
-void PairTriangle::pop() {
- mPairQueue.pop();
-}
-
-size_t PairTriangle::getMemoryUse() const {
- return mPrePairs.capacity() * sizeof(mPrePairs.front()) +
- mPairQueue.getMemoryUse();
-}
-
-std::string PairTriangle::name() const {
- return "todo";
- // return mPairQueue.name();
-}
-
-std::pair<size_t, size_t> PairTriangle::topPair() const {
- return mPairQueue.topPair();
-}
-
-// Returns the minimal orderBy monomial along all pairs. This is the orderBy
-// monomial of topPair().
-const_monomial PairTriangle::topOrderBy() const {
- return mPairQueue.topPairData();
-}
-
-MATHICGB_NAMESPACE_END
diff --git a/src/mathicgb/PairTriangle.hpp b/src/mathicgb/PairTriangle.hpp
deleted file mode 100755
index 29a2aca..0000000
--- a/src/mathicgb/PairTriangle.hpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// MathicGB copyright 2012 all rights reserved. MathicGB comes with ABSOLUTELY
-// NO WARRANTY and is licensed as GPL v2.0 or later - see LICENSE.txt.
-#ifndef MATHICGB_PAIR_TRIANGLE_GUARD
-#define MATHICGB_PAIR_TRIANGLE_GUARD
-
-#include "PolyRing.hpp"
-#include "SigSPairQueue.hpp"
-#include <memtailor.h>
-#include <mathic.h>
-
-MATHICGB_NAMESPACE_BEGIN
-
-/*typedef unsigned short SmallIndex;
-typedef unsigned int BigIndex;
-
-// The following type is only used in the creation of SPairGroups
-struct PreSPair {
- BigIndex i;
- monomial signature;
- };*/
-
-// Object that stores S-pairs and orders them according to a monomial
-// or signature.
-class PairTriangle {
-public:
- PairTriangle(const PolyRing& ring, size_t queueType);
-
- // Returns how many columns the triangle has
- size_t columnCount() const {return mPairQueue.columnCount();}
-
- // Returns how many pairs are in the triangle
- size_t pairCount() const {return mPairQueue.pairCount();}
-
- // Returns true if there are no pairs in the triangle
- bool empty() const {return mPairQueue.empty();}
-
- // Adds a new column of the triangle and opens it for addition of pairs.
- // This increases columnCount() by one, and the index of the new column
- // is the previous value of columnCount(). Must call endColumn
- // before calling beginColumn again or using the new column.
- void beginColumn();
-
- // Adds a pair to the most recent column that must still be open for
- // addition of pairs. If a is the index of the new column, then
- // the added pair is (a,index). index must be less than a.
- // orderBy must have been allocated on the ring's pool of monomials,
- // and ownership of the memory is passed to the this triangle object.
- void addPair(size_t index, monomial orderBy);
-
- // Closes the new column for addition of pairs. Must be preceded by a call
- // to beginColumn(). This sorts the added pairs according to their orderBy
- // monomials.
- void endColumn();
-
- // Returns a pair with minimal orderBy monomial.
- std::pair<size_t, size_t> topPair() const;
-
- // Returns the minimal orderBy monomial along all pairs. This is the orderBy
- // monomial of topPair().
- const_monomial topOrderBy() const;
-
- // Removes topPair() from the triangle.
- void pop();
-
- size_t getMemoryUse() const;
-
- std::string name() const;
- size_t mColumnCount;
-
-protected:
- // Sub classes implement this to say what monomial each pair is ordered
- // according to. That monomial should be placed into orderBy.
- //
- // If false is returned, the requested S-pair is not valid and should be
- // skipped.
- virtual bool calculateOrderBy(size_t a, size_t b, monomial orderBy) const = 0;
-
-private:
- std::vector<PreSPair> mPrePairs;
- PolyRing const& mRing;
-
- class PC {
- public:
- PC(PairTriangle const& tri): mTri(tri) {}
-
- typedef monomial PairData;
- void computePairData(size_t col, size_t row, monomial m) {
- mTri.calculateOrderBy(col, row, m);
- }
-
- typedef bool CompareResult;
- bool compare(int colA, int rowA, const_monomial a,
- int colB, int rowB, const_monomial b) const {
- return mTri.mRing.monoid().lessThan(b, a);
- }
- bool cmpLessThan(bool v) const {return v;}
-
- // these are not required for a configuration but we will use
- // them from this code.
- monomial allocPairData() {return mTri.mRing.allocMonomial();}
- void freePairData(monomial m) {mTri.mRing.freeMonomial(m);}
-
- private:
- PairTriangle const& mTri;
- };
- mathic::PairQueue<PC> mPairQueue;
- friend void mathic::PairQueueNamespace::constructPairData<PC>(void*,Index,Index,PC&);
- friend void mathic::PairQueueNamespace::destructPairData<PC>(PC::PairData*,Index,Index, PC&);
-};
-
-MATHICGB_NAMESPACE_END
-
-namespace mathic {
- namespace PairQueueNamespace {
- template<>
- inline void constructPairData<mgb::PairTriangle::PC>
- (void* memory, Index col, Index row, mgb::PairTriangle::PC& conf) {
- MATHICGB_ASSERT(memory != 0);
- MATHICGB_ASSERT(col > row);
- auto pd = new (memory)
- mgb::PairTriangle::PC::PairData(conf.allocPairData());
- conf.computePairData(col, row, *pd);
- }
-
- template<>
- inline void destructPairData<mgb::PairTriangle::PC>(
- mgb::PairTriangle::PC::PairData* pd,
- Index col,
- Index row,
- mgb::PairTriangle::PC& conf
- ) {
- MATHICGB_ASSERT(pd != 0);
- MATHICGB_ASSERT(col > row);
- conf.freePairData(*pd);
- }
- }
-}
-
-#endif
--
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