[mathicgb] 167/393: Moved PreBlock code out of F4MatrixBuilder2 into its own file and renamed it to ProtoMatrix.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:54 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 cc9dfbf3bb0f0b6600063bf008f225605f45f29b
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Thu Feb 14 12:58:58 2013 +0100
Moved PreBlock code out of F4MatrixBuilder2 into its own file and renamed it to ProtoMatrix.
---
Makefile.am | 3 +-
build/vs12/mathicgb-lib/mathicgb-lib.vcxproj | 2 +
.../vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters | 6 ++
src/mathicgb/F4MatrixBuilder2.cpp | 115 +++------------------
src/mathicgb/F4MatrixBuilder2.hpp | 7 +-
src/mathicgb/F4ProtoMatrix.cpp | 47 +++++++++
src/mathicgb/F4ProtoMatrix.hpp | 59 +++++++++++
7 files changed, 131 insertions(+), 108 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index a953ce5..62cea64 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,8 @@ libmathicgb_la_SOURCES = src/mathicgb/BjarkeGeobucket2.cpp \
src/mathicgb/CFile.cpp src/mathicgb/LogDomain.hpp \
src/mathicgb/LogDomain.cpp src/mathicgb/LogDomainSet.hpp \
src/mathicgb/F4MatrixBuilder2.hpp src/mathicgb/F4MatrixBuilder2.cpp \
- src/mathicgb/LogDomainSet.cpp
+ src/mathicgb/LogDomainSet.cpp src/mathicgb/ProtoMatrix.hpp \
+ src/mathicgb/ProtoMatrix.cpp
# When making a distribution file, Automake knows to include all files
# that are necessary to build the project. EXTRA_DIST specifies files
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
index 103365a..cf850b9 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj
@@ -448,6 +448,7 @@
<ClCompile Include="..\..\..\src\mathicgb\F4MatrixBuilder.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\F4MatrixBuilder2.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\F4MatrixReducer.cpp" />
+ <ClCompile Include="..\..\..\src\mathicgb\F4ProtoMatrix.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\F4Reducer.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\FreeModuleOrder.cpp" />
<ClCompile Include="..\..\..\src\mathicgb\GroebnerBasis.cpp" />
@@ -491,6 +492,7 @@
<ClInclude Include="..\..\..\src\mathicgb\F4MatrixBuilder.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\F4MatrixBuilder2.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\F4MatrixReducer.hpp" />
+ <ClInclude Include="..\..\..\src\mathicgb\F4ProtoMatrix.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\F4Reducer.hpp" />
<ClInclude Include="..\..\..\src\mathicgb\FixedSizeMonomialMap.h" />
<ClInclude Include="..\..\..\src\mathicgb\FreeModuleOrder.hpp" />
diff --git a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
index 54c4492..ff019b2 100755
--- a/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
+++ b/build/vs12/mathicgb-lib/mathicgb-lib.vcxproj.filters
@@ -132,6 +132,9 @@
<ClCompile Include="..\..\..\src\mathicgb\LogDomainSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\src\mathicgb\F4ProtoMatrix.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\mathicgb\BjarkeGeobucket.hpp">
@@ -299,5 +302,8 @@
<ClInclude Include="..\..\..\src\mathicgb\F4MatrixBuilder2.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\src\mathicgb\F4ProtoMatrix.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/mathicgb/F4MatrixBuilder2.cpp b/src/mathicgb/F4MatrixBuilder2.cpp
index d1b45ab..03e7ab6 100755
--- a/src/mathicgb/F4MatrixBuilder2.cpp
+++ b/src/mathicgb/F4MatrixBuilder2.cpp
@@ -9,96 +9,6 @@ MATHICGB_DEFINE_LOG_DOMAIN(
"Displays statistics about F4 matrix construction."
);
-class F4MatrixBuilder2::F4PreBlock {
-public:
- typedef uint32 RowIndex;
- typedef uint32 ColIndex;
- typedef coefficient ExternalScalar;
- typedef SparseMatrix::Scalar Scalar;
-
- struct Row {
- const ColIndex* indices;
- const Scalar* scalars;
- const ExternalScalar* externalScalars;
- ColIndex entryCount;
- };
-
- RowIndex rowCount() const {return static_cast<RowIndex>(mRows.size());}
-
- Row row(const RowIndex row) const {
- MATHICGB_ASSERT(row < mRows.size());
- const auto& r = mRows[row];
- Row rr;
- rr.indices = mIndices.data() + r.indicesBegin;
- rr.entryCount = r.entryCount;
- if (r.externalScalars == 0) {
- rr.scalars = mScalars.data() + r.scalarsBegin;
- rr.externalScalars = 0;
- } else {
- rr.scalars = 0;
- rr.externalScalars = r.externalScalars;
- }
- return rr;
- }
-
- ColIndex* makeRowWithTheseScalars(const Poly& scalars) {
- MATHICGB_ASSERT(rowCount() < std::numeric_limits<RowIndex>::max());
- MATHICGB_ASSERT
- (scalars.termCount() < std::numeric_limits<ColIndex>::max());
-
- InternalRow row;
- row.indicesBegin = mIndices.size();
- row.scalarsBegin = std::numeric_limits<decltype(row.scalarsBegin)>::max();
- row.entryCount = static_cast<ColIndex>(scalars.termCount());
- row.externalScalars = scalars.coefficientBegin();
- mRows.push_back(row);
-
- mIndices.resize(mIndices.size() + row.entryCount);
- return mIndices.data() + row.indicesBegin;
- }
-
- std::pair<ColIndex*, Scalar*> makeRow(ColIndex entryCount) {
- MATHICGB_ASSERT(rowCount() < std::numeric_limits<RowIndex>::max());
-
- InternalRow row;
- row.indicesBegin = mIndices.size();
- row.scalarsBegin = mScalars.size();
- row.entryCount = entryCount;
- row.externalScalars = 0;
- mRows.push_back(row);
-
- mIndices.resize(mIndices.size() + entryCount);
- mScalars.resize(mScalars.size() + entryCount);
- return std::make_pair(
- mIndices.data() + row.indicesBegin,
- mScalars.data() + row.scalarsBegin
- );
- }
-
- void removeLastEntries(const RowIndex row, const ColIndex count) {
- MATHICGB_ASSERT(row < rowCount());
- MATHICGB_ASSERT(mRows[row].entryCount >= count);
- mRows[row].entryCount -= count;
- if (row != rowCount() - 1)
- return;
- mIndices.resize(mIndices.size() - count);
- if (mRows[row].externalScalars == 0)
- mScalars.resize(mScalars.size() - count);
- }
-
-private:
- struct InternalRow {
- size_t indicesBegin;
- size_t scalarsBegin;
- ColIndex entryCount;
- const ExternalScalar* externalScalars;
- };
-
- std::vector<ColIndex> mIndices;
- std::vector<Scalar> mScalars;
- std::vector<InternalRow> mRows;
-};
-
MATHICGB_NO_INLINE
std::pair<F4MatrixBuilder2::ColIndex, ConstMonomial>
F4MatrixBuilder2::findOrCreateColumn(
@@ -304,7 +214,7 @@ namespace {
}
void project(
- const std::vector<F4MatrixBuilder2::F4PreBlock*>& preBlocks,
+ const std::vector<F4ProtoMatrix*>& preBlocks,
SparseMatrix& left,
SparseMatrix& right,
const PolyRing& ring
@@ -358,7 +268,7 @@ namespace {
}
void project(
- const std::vector<std::pair<SparseMatrix::Scalar,F4MatrixBuilder2::F4PreBlock::Row>>& from,
+ const std::vector<std::pair<SparseMatrix::Scalar, F4ProtoMatrix::Row>>& from,
SparseMatrix& left,
SparseMatrix& right,
const PolyRing& ring
@@ -534,7 +444,7 @@ namespace {
class TopBottomProjection {
public:
TopBottomProjection(
- const std::vector<F4MatrixBuilder2::F4PreBlock*>& blocks,
+ const std::vector<F4ProtoMatrix*>& blocks,
const LeftRightProjection& leftRight,
const PolyRing& ring
):
@@ -542,7 +452,7 @@ namespace {
{
typedef SparseMatrix::RowIndex RowIndex;
const auto noReducer = std::numeric_limits<RowIndex>::max();
- F4PreBlock::Row noRow = {};
+ F4ProtoMatrix::Row noRow = {};
noRow.indices = 0;
const auto noCol = std::numeric_limits<SparseMatrix::ColIndex>::max();
@@ -618,18 +528,17 @@ namespace {
#endif
}
- typedef F4MatrixBuilder2::F4PreBlock F4PreBlock;
- const std::vector<std::pair<SparseMatrix::Scalar,F4MatrixBuilder2::F4PreBlock::Row>>& reducerRows() const {
+ const std::vector<std::pair<SparseMatrix::Scalar, F4ProtoMatrix::Row>>& reducerRows() const {
return mReducerRows;
}
- const std::vector<std::pair<SparseMatrix::Scalar,F4MatrixBuilder2::F4PreBlock::Row>>& reduceeRows() const {
+ const std::vector<std::pair<SparseMatrix::Scalar, F4ProtoMatrix::Row>>& reduceeRows() const {
return mReduceeRows;
}
private:
- std::vector<std::pair<SparseMatrix::Scalar,F4MatrixBuilder2::F4PreBlock::Row>> mReducerRows;
- std::vector<std::pair<SparseMatrix::Scalar,F4MatrixBuilder2::F4PreBlock::Row>> mReduceeRows;
+ std::vector<std::pair<SparseMatrix::Scalar, F4ProtoMatrix::Row>> mReducerRows;
+ std::vector<std::pair<SparseMatrix::Scalar, F4ProtoMatrix::Row>> mReduceeRows;
};
}
@@ -647,7 +556,7 @@ void F4MatrixBuilder2::buildMatrixAndClear(QuadMatrix& quadMatrix) {
// we are calling here can add more pending items.
struct ThreadData {
- F4PreBlock block;
+ F4ProtoMatrix block;
monomial tmp1;
monomial tmp2;
};
@@ -698,7 +607,7 @@ void F4MatrixBuilder2::buildMatrixAndClear(QuadMatrix& quadMatrix) {
mTodo.clear();
// Collect pre-blocks from each thread
- std::vector<F4PreBlock*> blocks;
+ std::vector<F4ProtoMatrix*> blocks;
blocks.reserve(threadData.size());
const auto end = threadData.end();
for (auto it = threadData.begin(); it != end; ++it) {
@@ -796,7 +705,7 @@ F4MatrixBuilder2::createColumn(
void F4MatrixBuilder2::appendRow(
const const_monomial multiple,
const Poly& poly,
- F4PreBlock& block,
+ F4ProtoMatrix& block,
TaskFeeder& feeder
) {
MATHICGB_ASSERT(!multiple.isNull());
@@ -866,7 +775,7 @@ void F4MatrixBuilder2::appendRowSPair(
monomial multiply,
const Poly* sPairPoly,
monomial sPairMultiply,
- F4PreBlock& block,
+ F4ProtoMatrix& block,
TaskFeeder& feeder
) {
MATHICGB_ASSERT(!poly->isZero());
diff --git a/src/mathicgb/F4MatrixBuilder2.hpp b/src/mathicgb/F4MatrixBuilder2.hpp
index 90521d8..15a1bab 100755
--- a/src/mathicgb/F4MatrixBuilder2.hpp
+++ b/src/mathicgb/F4MatrixBuilder2.hpp
@@ -7,6 +7,7 @@
#include "PolyBasis.hpp"
#include "QuadMatrix.hpp"
#include "MonomialMap.hpp"
+#include "F4ProtoMatrix.hpp"
#include <tbb/mutex.h>
#include <vector>
@@ -65,8 +66,6 @@ public:
const PolyRing& ring() const {return mBasis.ring();}
- class F4PreBlock;
-
private:
typedef const Map::Reader ColReader;
typedef std::vector<monomial> Monomials;
@@ -96,7 +95,7 @@ private:
void appendRow(
const_monomial multiple,
const Poly& poly,
- F4PreBlock& block,
+ F4ProtoMatrix& block,
TaskFeeder& feeder
);
void appendRowSPair(
@@ -104,7 +103,7 @@ private:
monomial multiply,
const Poly* sPairPoly,
monomial sPairMultiply,
- F4PreBlock& block,
+ F4ProtoMatrix& block,
TaskFeeder& feeder
);
diff --git a/src/mathicgb/F4ProtoMatrix.cpp b/src/mathicgb/F4ProtoMatrix.cpp
new file mode 100644
index 0000000..599ac0d
--- /dev/null
+++ b/src/mathicgb/F4ProtoMatrix.cpp
@@ -0,0 +1,47 @@
+#include "stdinc.h"
+#include "F4ProtoMatrix.hpp"
+
+auto F4ProtoMatrix::makeRowWithTheseScalars(const Poly& scalars) -> ColIndex*
+{
+ MATHICGB_ASSERT(rowCount() < std::numeric_limits<RowIndex>::max());
+ MATHICGB_ASSERT(scalars.termCount() < std::numeric_limits<ColIndex>::max());
+
+ InternalRow row;
+ row.indicesBegin = mIndices.size();
+ row.scalarsBegin = std::numeric_limits<decltype(row.scalarsBegin)>::max();
+ row.entryCount = static_cast<ColIndex>(scalars.termCount());
+ row.externalScalars = scalars.coefficientBegin();
+ mRows.push_back(row);
+
+ mIndices.resize(mIndices.size() + row.entryCount);
+ return mIndices.data() + row.indicesBegin;
+}
+
+auto F4ProtoMatrix::makeRow(ColIndex entryCount) -> std::pair<ColIndex*, Scalar*> {
+ MATHICGB_ASSERT(rowCount() < std::numeric_limits<RowIndex>::max());
+
+ InternalRow row;
+ row.indicesBegin = mIndices.size();
+ row.scalarsBegin = mScalars.size();
+ row.entryCount = entryCount;
+ row.externalScalars = 0;
+ mRows.push_back(row);
+
+ mIndices.resize(mIndices.size() + entryCount);
+ mScalars.resize(mScalars.size() + entryCount);
+ return std::make_pair(
+ mIndices.data() + row.indicesBegin,
+ mScalars.data() + row.scalarsBegin
+ );
+}
+
+void F4ProtoMatrix::removeLastEntries(const RowIndex row, const ColIndex count) {
+ MATHICGB_ASSERT(row < rowCount());
+ MATHICGB_ASSERT(mRows[row].entryCount >= count);
+ mRows[row].entryCount -= count;
+ if (row != rowCount() - 1)
+ return;
+ mIndices.resize(mIndices.size() - count);
+ if (mRows[row].externalScalars == 0)
+ mScalars.resize(mScalars.size() - count);
+}
diff --git a/src/mathicgb/F4ProtoMatrix.hpp b/src/mathicgb/F4ProtoMatrix.hpp
new file mode 100644
index 0000000..29a0bb0
--- /dev/null
+++ b/src/mathicgb/F4ProtoMatrix.hpp
@@ -0,0 +1,59 @@
+#ifndef MATHICGB_F4_PROTO_MATRIX_GUARD
+#define MATHICGB_F4_PROTO_MATRIX_GUARD
+
+#include "PolyRing.hpp"
+#include "SparseMatrix.hpp"
+#include "Poly.hpp"
+
+class F4ProtoMatrix {
+public:
+ typedef uint32 RowIndex;
+ typedef uint32 ColIndex;
+ typedef coefficient ExternalScalar;
+ typedef SparseMatrix::Scalar Scalar;
+
+ struct Row {
+ const ColIndex* indices;
+ const Scalar* scalars;
+ const ExternalScalar* externalScalars;
+ ColIndex entryCount;
+ };
+
+ RowIndex rowCount() const {return static_cast<RowIndex>(mRows.size());}
+
+ Row row(const RowIndex row) const {
+ MATHICGB_ASSERT(row < mRows.size());
+ const auto& r = mRows[row];
+ Row rr;
+ rr.indices = mIndices.data() + r.indicesBegin;
+ rr.entryCount = r.entryCount;
+ if (r.externalScalars == 0) {
+ rr.scalars = mScalars.data() + r.scalarsBegin;
+ rr.externalScalars = 0;
+ } else {
+ rr.scalars = 0;
+ rr.externalScalars = r.externalScalars;
+ }
+ return rr;
+ }
+
+ ColIndex* makeRowWithTheseScalars(const Poly& scalars);
+
+ std::pair<ColIndex*, Scalar*> makeRow(ColIndex entryCount);
+
+ void removeLastEntries(const RowIndex row, const ColIndex count);
+
+private:
+ struct InternalRow {
+ size_t indicesBegin;
+ size_t scalarsBegin;
+ ColIndex entryCount;
+ const ExternalScalar* externalScalars;
+ };
+
+ std::vector<ColIndex> mIndices;
+ std::vector<Scalar> mScalars;
+ std::vector<InternalRow> mRows;
+};
+
+#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