[mathicgb] 58/393: Miscellaneous code improvements. Removed many MSVC warnings, changed pointers to references or unique_ptr.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:32 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 73b5e4e1e40892256bad8a4a27e12715b9d232cd
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Thu Oct 11 19:02:51 2012 +0200
Miscellaneous code improvements. Removed many MSVC warnings, changed pointers to references or unique_ptr.
---
src/cli/GBMain.cpp | 6 ++--
src/mathicgb/BjarkeGeobucket.cpp | 3 --
src/mathicgb/BjarkeGeobucket2.cpp | 3 --
src/mathicgb/BuchbergerAlg.cpp | 2 --
src/mathicgb/BuchbergerAlg.hpp | 4 +--
src/mathicgb/DivLookup.hpp | 2 --
src/mathicgb/F4MatrixReducer.cpp | 10 +++---
src/mathicgb/F4MatrixReducer.hpp | 7 ++--
src/mathicgb/F4Reducer.cpp | 10 +++---
src/mathicgb/F4Reducer.hpp | 4 +--
src/mathicgb/FreeModuleOrder.cpp | 27 +++++++--------
src/mathicgb/FreeModuleOrder.hpp | 6 ++--
src/mathicgb/HashTourReducer.cpp | 2 --
src/mathicgb/Ideal.cpp | 10 +++---
src/mathicgb/Ideal.hpp | 7 ++--
src/mathicgb/MTArray.cpp | 16 ++++-----
src/mathicgb/MTArray.hpp | 3 +-
src/mathicgb/Poly.cpp | 6 ++--
src/mathicgb/Poly.hpp | 2 +-
src/mathicgb/PolyBasis.cpp | 2 +-
src/mathicgb/PolyHashReducer.cpp | 26 +++++---------
src/mathicgb/PolyHashTable.cpp | 9 +++--
src/mathicgb/PolyHeap.cpp | 3 --
src/mathicgb/PolyReducer.cpp | 7 ++--
src/mathicgb/Reducer.cpp | 2 --
src/mathicgb/Reducer.hpp | 2 +-
src/mathicgb/ReducerPack.hpp | 2 --
src/mathicgb/ReducerPackDedup.hpp | 2 --
src/mathicgb/SigSPairs.cpp | 3 --
src/mathicgb/SignatureGB.cpp | 35 ++++++-------------
src/mathicgb/SignatureGB.hpp | 23 ++++++++-----
src/mathicgb/TournamentReducer.cpp | 2 --
src/mathicgb/TypicalReducer.cpp | 11 +++---
src/mathicgb/TypicalReducer.hpp | 2 +-
src/mathicgb/io-util.cpp | 2 +-
src/mathicgb/stdinc.h | 69 ++++++++++++++++++++++++++++++++++++--
src/test/F4MatrixBuilder.cpp | 6 ++--
src/test/F4MatrixReducer.cpp | 2 +-
src/test/QuadMatrixBuilder.cpp | 6 ++--
src/test/SparseMatrix.cpp | 4 +--
src/test/gb-test.cpp | 3 --
src/test/poly-test.cpp | 16 ++++-----
42 files changed, 190 insertions(+), 179 deletions(-)
diff --git a/src/cli/GBMain.cpp b/src/cli/GBMain.cpp
index 6de45ee..bf9e0e7 100755
--- a/src/cli/GBMain.cpp
+++ b/src/cli/GBMain.cpp
@@ -13,8 +13,6 @@
#include <istream>
#include <cctype>
-extern int tracingLevel;
-
class CliActionSignature : public mic::Action {
public:
CliActionSignature():
@@ -181,8 +179,8 @@ public:
std::string const inputIdealFile = mProjectName.value() + ".ideal";
std::ifstream inputFile(inputIdealFile.c_str());
if (inputFile.fail())
- mic::reportError("Could not read input file " + inputIdealFile);
- ideal.reset(Ideal::parse(inputFile));
+ mic::reportError("Could not read input file \"" + inputIdealFile + '\n');
+ ideal = Ideal::parse(inputFile);
}
std::unique_ptr<PolyRing const> ring(&(ideal->ring()));
diff --git a/src/mathicgb/BjarkeGeobucket.cpp b/src/mathicgb/BjarkeGeobucket.cpp
index 7d89d79..e359692 100644
--- a/src/mathicgb/BjarkeGeobucket.cpp
+++ b/src/mathicgb/BjarkeGeobucket.cpp
@@ -1,11 +1,8 @@
// Copyright 2011 Michael E. Stillman
-#include <iostream>
#include "stdinc.h"
#include "BjarkeGeobucket.hpp"
-extern int tracingLevel;
-
BjarkeGeobucket::BjarkeGeobucket(const PolyRing *R0)
: Reducer(),
R_(R0),
diff --git a/src/mathicgb/BjarkeGeobucket2.cpp b/src/mathicgb/BjarkeGeobucket2.cpp
index 726fa5c..abdc866 100755
--- a/src/mathicgb/BjarkeGeobucket2.cpp
+++ b/src/mathicgb/BjarkeGeobucket2.cpp
@@ -4,9 +4,6 @@
#include <iostream>
-
-extern int tracingLevel;
-
BjarkeGeobucket2::BjarkeGeobucket2(const PolyRing *R0):
mRing(*R0),
mHashTableOLD(R0, 10),
diff --git a/src/mathicgb/BuchbergerAlg.cpp b/src/mathicgb/BuchbergerAlg.cpp
index 4e353e6..2a9f8d4 100755
--- a/src/mathicgb/BuchbergerAlg.cpp
+++ b/src/mathicgb/BuchbergerAlg.cpp
@@ -4,8 +4,6 @@
#include <iostream>
-extern int tracingLevel;
-
BuchbergerAlg::BuchbergerAlg(
const Ideal& ideal,
FreeModuleOrderType orderType,
diff --git a/src/mathicgb/BuchbergerAlg.hpp b/src/mathicgb/BuchbergerAlg.hpp
index f4d79e8..771969e 100755
--- a/src/mathicgb/BuchbergerAlg.hpp
+++ b/src/mathicgb/BuchbergerAlg.hpp
@@ -50,7 +50,7 @@ public:
mSPairGroupSize = groupSize;
}
- void setThreadCount(size_t threadCount) {
+ void setThreadCount(int threadCount) {
mThreadCount = threadCount;
}
@@ -66,7 +66,7 @@ private:
unsigned int mBreakAfter;
unsigned int mPrintInterval;
unsigned int mSPairGroupSize;
- size_t mThreadCount;
+ int mThreadCount;
bool mUseAutoTopReduction;
bool mUseAutoTailReduction;
diff --git a/src/mathicgb/DivLookup.hpp b/src/mathicgb/DivLookup.hpp
index 30de634..366a569 100644
--- a/src/mathicgb/DivLookup.hpp
+++ b/src/mathicgb/DivLookup.hpp
@@ -14,8 +14,6 @@
/* As such, it has entries that both will expect */
/* It also contains enough for the Naive monomial table use */
-extern int tracingLevel;
-
template<bool AllowRemovals, bool UseDivMask>
class DivLookupConfiguration;
diff --git a/src/mathicgb/F4MatrixReducer.cpp b/src/mathicgb/F4MatrixReducer.cpp
index 0f5a967..4af072e 100755
--- a/src/mathicgb/F4MatrixReducer.cpp
+++ b/src/mathicgb/F4MatrixReducer.cpp
@@ -16,8 +16,6 @@
#include <omp.h>
#endif
-extern int tracingLevel;
-
template<class T>
class DenseRow {
public:
@@ -264,7 +262,7 @@ void myReduce
SparseMatrix const& reduceByRight,
SparseMatrix::Scalar modulus,
SparseMatrix& reduced,
- size_t threadCount) {
+ int threadCount) {
MATHICGB_ASSERT(reduceByLeft.colCount() == reduceByLeft.rowCount());
const auto pivotCount = reduceByLeft.colCount();
const auto rowCount = toReduceLeft.rowCount();
@@ -397,7 +395,7 @@ void myReduce
}
void myReduceToEchelonForm5
-(SparseMatrix& toReduce, SparseMatrix::Scalar modulus, size_t threadCount) {
+(SparseMatrix& toReduce, SparseMatrix::Scalar modulus, int threadCount) {
// making no assumptions on toReduce except no zero rows
SparseMatrix::RowIndex const rowCount = toReduce.rowCount();
@@ -863,5 +861,5 @@ void F4MatrixReducer::reduce
myReduceToEchelonForm5(newPivots, modulus, mThreadCount);
}
-F4MatrixReducer::F4MatrixReducer(size_t threadCount):
- mThreadCount(std::max(threadCount, static_cast<size_t>(1))) {}
+F4MatrixReducer::F4MatrixReducer(int threadCount):
+ mThreadCount(std::max(threadCount, 1)) {}
diff --git a/src/mathicgb/F4MatrixReducer.hpp b/src/mathicgb/F4MatrixReducer.hpp
index 97941c8..e61356f 100755
--- a/src/mathicgb/F4MatrixReducer.hpp
+++ b/src/mathicgb/F4MatrixReducer.hpp
@@ -9,13 +9,16 @@ class PolyRing;
answer you get is the submatrix that contains new pivots. */
class F4MatrixReducer {
public:
- F4MatrixReducer(size_t threadCount);
+ F4MatrixReducer(int threadCount);
void reduce
(const PolyRing& ring, QuadMatrix& matrix, SparseMatrix& newPivots);
private:
- size_t mThreadCount;
+ /// this is forced to be signed to avoid warnings about signed/unsigned
+ /// conversion because, perversely, MSVC 2012 does not allow unsigned
+ /// for-loop indices in OpenMP.
+ int mThreadCount;
};
#endif
diff --git a/src/mathicgb/F4Reducer.cpp b/src/mathicgb/F4Reducer.cpp
index d747cb2..bfe9b36 100755
--- a/src/mathicgb/F4Reducer.cpp
+++ b/src/mathicgb/F4Reducer.cpp
@@ -5,8 +5,6 @@
#include "F4MatrixReducer.hpp"
#include <iostream>
-extern int tracingLevel;
-
F4Reducer::F4Reducer(
const PolyRing& ring,
std::unique_ptr<Reducer> fallback
@@ -63,7 +61,7 @@ std::unique_ptr<Poly> F4Reducer::classicReduceSPoly
red.reduce(basis.ring(), qm, reduced);
}
- auto p = make_unique<Poly>(&basis.ring());
+ auto p = make_unique<Poly>(basis.ring());
if (reduced.rowCount() > 0) {
MATHICGB_ASSERT(reduced.rowCount() == 1);
reduced.rowToPolynomial(0, qm.rightColumnMonomials, *p);
@@ -115,7 +113,7 @@ void F4Reducer::classicReduceSPolySet
<< " non-zero rows\n";
for (SparseMatrix::RowIndex row = 0; row < reduced.rowCount(); ++row) {
- auto p = make_unique<Poly>(&basis.ring());
+ auto p = make_unique<Poly>(basis.ring());
reduced.rowToPolynomial(row, monomials, *p);
reducedOut.push_back(std::move(p));
}
@@ -163,7 +161,7 @@ void F4Reducer::classicReducePolySet
<< " non-zero rows\n";
for (SparseMatrix::RowIndex row = 0; row < reduced.rowCount(); ++row) {
- auto p = make_unique<Poly>(&basis.ring());
+ auto p = make_unique<Poly>(basis.ring());
reduced.rowToPolynomial(row, monomials, *p);
reducedOut.push_back(std::move(p));
}
@@ -180,7 +178,7 @@ Poly* F4Reducer::regularReduce
return p;
}
-void F4Reducer::setThreadCount(size_t threadCount) {
+void F4Reducer::setThreadCount(int threadCount) {
mThreadCount = threadCount;
}
diff --git a/src/mathicgb/F4Reducer.hpp b/src/mathicgb/F4Reducer.hpp
index bbbb3d2..238f1d8 100755
--- a/src/mathicgb/F4Reducer.hpp
+++ b/src/mathicgb/F4Reducer.hpp
@@ -34,7 +34,7 @@ public:
size_t basisElement,
const GroebnerBasis& basis);
- virtual void setThreadCount(size_t threadCount);
+ virtual void setThreadCount(int threadCount);
virtual std::string description() const;
virtual size_t getMemoryUse() const;
@@ -42,7 +42,7 @@ public:
private:
std::unique_ptr<Reducer> mFallback;
const PolyRing& mRing;
- size_t mThreadCount;
+ int mThreadCount;
};
#endif
diff --git a/src/mathicgb/FreeModuleOrder.cpp b/src/mathicgb/FreeModuleOrder.cpp
index 451a58f..a3541d9 100755
--- a/src/mathicgb/FreeModuleOrder.cpp
+++ b/src/mathicgb/FreeModuleOrder.cpp
@@ -279,7 +279,6 @@ private:
// rule: a[i] < b[i] then a > b
//
// also applies to component, which is considered last.
-extern int tracingLevel;
class OrderA {
public:
OrderA(const PolyRing* ring): mRing(ring) {}
@@ -698,37 +697,35 @@ void FreeModuleOrder::displayOrderTypes(std::ostream &o)
o << " 7 IndexDown SchreyerGrevLex" << std::endl;
}
-FreeModuleOrder* FreeModuleOrder::makeOrder(FreeModuleOrderType type, const Ideal* I)
+std::unique_ptr<FreeModuleOrder> FreeModuleOrder::makeOrder(FreeModuleOrderType type, const Ideal* I)
{
- int i;
if (type == 0)
type = 1; // Set the default
switch (type) {
case 1:
- return new ConcreteOrder<OrderA>(OrderA(I->getPolyRing()));
+ return make_unique<ConcreteOrder<OrderA>>(OrderA(I->getPolyRing()));
case 2:
- return new ConcreteOrder<OrderB>(OrderB(I));
+ return make_unique<ConcreteOrder<OrderB>>(OrderB(I));
case 3:
- return new ConcreteOrder<OrderC>(OrderC(I));
+ return make_unique<ConcreteOrder<OrderC>>(OrderC(I));
case 4:
- return new ConcreteOrder<OrderD>(OrderD(I, true));
+ return make_unique<ConcreteOrder<OrderD>>(OrderD(I, true));
case 5:
- return new ConcreteOrder<OrderD>(OrderD(I, false));
+ return make_unique<ConcreteOrder<OrderD>>(OrderD(I, false));
case 6:
- return new ConcreteOrder<OrderE>(OrderE(I, true));
+ return make_unique<ConcreteOrder<OrderE>>(OrderE(I, true));
case 7:
- return new ConcreteOrder<OrderE>(OrderE(I, false));
+ return make_unique<ConcreteOrder<OrderE>>(OrderE(I, false));
default: break;
}
std::cerr << "unknown free module order type" << std::endl;
std::cerr << "possible orders are: " << std::endl;
- for (i=1; i<=5; i++)
- {
- FreeModuleOrder* F = makeOrder(i,I);
- std::cerr << " " << i << ": " << F->description() << std::endl;
- }
+ for (size_t i = 1; i <= 7; ++i) {
+ auto order = makeOrder(static_cast<FreeModuleOrderType>(i), I);
+ std::cerr << " " << i << ": " << order->description() << std::endl;
+ }
exit(1);
}
diff --git a/src/mathicgb/FreeModuleOrder.hpp b/src/mathicgb/FreeModuleOrder.hpp
index 9059885..f4fa3c5 100755
--- a/src/mathicgb/FreeModuleOrder.hpp
+++ b/src/mathicgb/FreeModuleOrder.hpp
@@ -43,10 +43,8 @@ public:
virtual std::unique_ptr<SigSPairQueue>
createSigSPairQueue(GroebnerBasis const& basis) const = 0;
- /// @todo: We need at least an enum to make this clearer and the return type
- /// should be a smart pointer since the client needs to deallocate
- /// that memory.
- static FreeModuleOrder* makeOrder(FreeModuleOrderType type, const Ideal* I);
+ /// @todo: We need at least an enum to make this clearer
+ static std::unique_ptr<FreeModuleOrder> makeOrder(FreeModuleOrderType type, const Ideal* I);
static void displayOrderTypes(std::ostream &o);
diff --git a/src/mathicgb/HashTourReducer.cpp b/src/mathicgb/HashTourReducer.cpp
index 032e576..01a272b 100755
--- a/src/mathicgb/HashTourReducer.cpp
+++ b/src/mathicgb/HashTourReducer.cpp
@@ -5,8 +5,6 @@
#include <utility>
-extern int tracingLevel;
-
HashTourReducer::HashTourReducer(const PolyRing& ring):
mRing(ring),
mLeadTerm(0, mRing.allocMonomial()),
diff --git a/src/mathicgb/Ideal.cpp b/src/mathicgb/Ideal.cpp
index 1f388e4..2f868da 100755
--- a/src/mathicgb/Ideal.cpp
+++ b/src/mathicgb/Ideal.cpp
@@ -42,14 +42,14 @@ void Ideal::sort(FreeModuleOrder& order) {
std::sort(mGenerators.begin(), mGenerators.end(), cmp);
}
-Ideal *Ideal::parse(std::istream& in)
+std::unique_ptr<Ideal> Ideal::parse(std::istream& in)
{
- PolyRing *R = PolyRing::read(in);
+ PolyRing *R = PolyRing::read(in); // todo: fix this leak
size_t npolys;
in >> npolys;
- Ideal *result = new Ideal(*R);
- for (size_t j= 0; j < npolys; j++) {
- auto g = make_unique<Poly>(R);
+ auto result = make_unique<Ideal>(*R);
+ for (size_t j = 0; j < npolys; ++j) {
+ auto g = make_unique<Poly>(*R);
while (std::isspace(in.peek()))
in.get();
g->parse(in);
diff --git a/src/mathicgb/Ideal.hpp b/src/mathicgb/Ideal.hpp
index 2b2ed62..9aa84c4 100755
--- a/src/mathicgb/Ideal.hpp
+++ b/src/mathicgb/Ideal.hpp
@@ -19,8 +19,11 @@ public:
void insert(std::unique_ptr<Poly> p);
- static Ideal *parse(std::istream &i); // reads ring, #gens, each generator in turn
- void display(std::ostream &o, bool print_comp) const; // inverse operation
+ /// reads ring, #gens, each generator in turn
+ static std::unique_ptr<Ideal> parse(std::istream &i);
+
+ /// inverse operation to parse().
+ void display(std::ostream &o, bool print_comp) const;
const PolyRing& ring() const { return mRing; }
diff --git a/src/mathicgb/MTArray.cpp b/src/mathicgb/MTArray.cpp
index 92377d7..f17c797 100644
--- a/src/mathicgb/MTArray.cpp
+++ b/src/mathicgb/MTArray.cpp
@@ -206,42 +206,42 @@ int MonomialTableArray::displayMTTypes(std::ostream &o)
return 5;
}
-MonomialTableArray * MonomialTableArray::make(const PolyRing *R, int typ, size_t components, bool allowRemovals)
+std::unique_ptr<MonomialTableArray> MonomialTableArray::make(const PolyRing *R, int typ, size_t components, bool allowRemovals)
{
switch (typ) {
case 0:
- return new MTArrayT<MonTableNaive>(components, R);
+ return make_unique<MTArrayT<MonTableNaive>>(components, R);
case 1: {
typedef MonTableDivList<false,true> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 500));
}
case 2: {
if (allowRemovals) {
typedef MonTableKDTree<true,true,1,true> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 50));
} else {
typedef MonTableKDTree<true,true,1,false> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 50));
}
}
case 3: {
typedef MonTableDivList<false,false> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 500));
}
case 4: // fall through
default: {
if (allowRemovals) {
typedef MonTableKDTree<false,false,1,true> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 50));
} else {
typedef MonTableKDTree<false,false,1,false> MT;
- return new MTArrayT<MT>(components, MT::Configuration
+ return make_unique<MTArrayT<MT>>(components, MT::Configuration
(R, true, false, true, .5, 50));
}
}
diff --git a/src/mathicgb/MTArray.hpp b/src/mathicgb/MTArray.hpp
index 2ba2d98..a04e8f9 100644
--- a/src/mathicgb/MTArray.hpp
+++ b/src/mathicgb/MTArray.hpp
@@ -80,7 +80,8 @@ public:
// Choosing one
static int displayMTTypes(std::ostream &o); // returns n s.t. 0..n-1 are valid types
- static MonomialTableArray* make(const PolyRing *R, int typ, size_t components, bool allowRemovals);
+ static std::unique_ptr<MonomialTableArray>
+ make(const PolyRing *R, int typ, size_t components, bool allowRemovals);
protected:
class MonomialCompare {
diff --git a/src/mathicgb/Poly.cpp b/src/mathicgb/Poly.cpp
index 3a4a745..e719d89 100755
--- a/src/mathicgb/Poly.cpp
+++ b/src/mathicgb/Poly.cpp
@@ -45,7 +45,7 @@ void Poly::sortTermsDescending() {
std::sort(ordered.begin(), ordered.end(), Cmp(*this));
- Poly poly(R);
+ Poly poly(*R);
for (size_t i = 0; i < count; ++i)
poly.appendTerm(coefficientAt(ordered[i]), monomialAt(ordered[i]));
*this = std::move(poly);
@@ -82,7 +82,7 @@ void Poly::append(iterator &first, iterator &last)
Poly *Poly::copy() const
{
Poly *const_this = const_cast<Poly *>(this);
- Poly *result = new Poly(R);
+ Poly *result = new Poly(*R);
iterator a = const_this->begin();
iterator b = const_this->end();
result->append(a,b);
@@ -139,7 +139,7 @@ Poly * Poly::add(const PolyRing *R,
{
coefficient c;
n_compares = 0;
- Poly *result = new Poly(R);
+ Poly *result = new Poly(*R);
if (i == iend)
result->append(j, jend);
diff --git a/src/mathicgb/Poly.hpp b/src/mathicgb/Poly.hpp
index 82912b8..e14ea28 100755
--- a/src/mathicgb/Poly.hpp
+++ b/src/mathicgb/Poly.hpp
@@ -10,7 +10,7 @@
class Poly {
public:
- Poly(const PolyRing *R0) : R(R0) {MATHICGB_ASSERT(R != 0);}
+ Poly(const PolyRing& ring) : R(&ring) {MATHICGB_ASSERT(R != 0);}
void parse(std::istream &i); // reads into this, sorts terms
void parseDoNotOrder(std::istream &i); // reads into this, does not sort terms
diff --git a/src/mathicgb/PolyBasis.cpp b/src/mathicgb/PolyBasis.cpp
index 64d76f7..5bbe2dc 100755
--- a/src/mathicgb/PolyBasis.cpp
+++ b/src/mathicgb/PolyBasis.cpp
@@ -32,7 +32,7 @@ std::unique_ptr<Ideal> PolyBasis::initialIdeal() const {
size_t const idealSize = size();
for (size_t gen = 0; gen != idealSize; ++gen) {
if (!retired(gen) && leadMinimal(gen)) {
- std::unique_ptr<Poly> p(new Poly(&mRing));
+ std::unique_ptr<Poly> p(new Poly(mRing));
p->appendTerm(1, leadMonomial(gen));
ideal->insert(std::move(p));
}
diff --git a/src/mathicgb/PolyHashReducer.cpp b/src/mathicgb/PolyHashReducer.cpp
index 076c916..3e97193 100755
--- a/src/mathicgb/PolyHashReducer.cpp
+++ b/src/mathicgb/PolyHashReducer.cpp
@@ -1,7 +1,5 @@
// Copyright 2011 Michael E. Stillman
-#include <iostream>
-
#include "stdinc.h"
#include "PolyHashReducer.hpp"
@@ -34,12 +32,11 @@ void PolyHashReducer::merge(const HashPoly::const_iterator &fbegin, const HashPo
result.insert(result.end(), f, fend);
else {
bool done = false;
- while (!done)
- {
+ while (!done) {
int cmp = R_->monomialCompare((*f)->monom, (*g)->monom);
n_compares++;
- switch (cmp) {
- case LT:
+ MATHICGB_ASSERT(cmp != EQ);
+ if (cmp == LT) {
result.push_back(*g);
++g;
if (g == gend)
@@ -47,19 +44,14 @@ void PolyHashReducer::merge(const HashPoly::const_iterator &fbegin, const HashPo
result.insert(result.end(), f, fend);
done = true;
}
- break;
- case GT:
+ } else {
+ MATHICGB_ASSERT(cmp == GT);
result.push_back(*f);
++f;
- if (f == fend)
- {
- result.insert(result.end(), g, gend);
- done = true;
- }
- break;
- case EQ:
- std::cout << "Error: found equal monomials in PolyHashReducer::merge!" << std::endl;
- break;
+ if (f == fend) {
+ result.insert(result.end(), g, gend);
+ done = true;
+ }
}
}
}
diff --git a/src/mathicgb/PolyHashTable.cpp b/src/mathicgb/PolyHashTable.cpp
index 34cc696..71a79c8 100755
--- a/src/mathicgb/PolyHashTable.cpp
+++ b/src/mathicgb/PolyHashTable.cpp
@@ -1,12 +1,11 @@
// Copyright 2011 Michael E. Stillman
+#include "stdinc.h"
+#include "PolyHashTable.hpp"
+#include <mathic.h>
#include <iostream>
#include <cmath>
-#include "stdinc.h"
-#include <mathic.h>
-
-#include "PolyHashTable.hpp"
const double PolyHashTable::threshold = 0.1;
const bool AlwaysInsertAtEnd = true;
@@ -451,7 +450,7 @@ void PolyHashTable::dump(int level) const
{
if (mHashTable[i] == 0) continue;
std::cout << "bin " << i << ": ";
- Poly f(&mRing);
+ Poly f(mRing);
for (node *p = mHashTable[i]; p != 0; p = p->next)
f.appendTerm(p->coeff, p->monom);
f.display(std::cout);
diff --git a/src/mathicgb/PolyHeap.cpp b/src/mathicgb/PolyHeap.cpp
index d904c06..3d5f3af 100755
--- a/src/mathicgb/PolyHeap.cpp
+++ b/src/mathicgb/PolyHeap.cpp
@@ -1,13 +1,10 @@
// Copyright 2011 Michael E. Stillman
-
#include "stdinc.h"
#include "PolyHeap.hpp"
#include <iostream>
#include <algorithm>
-extern int tracingLevel;
-
size_t PolyHeap::stats_static_n_compares = 0;
PolyHeap::PolyHeap(const PolyRing *R_):
diff --git a/src/mathicgb/PolyReducer.cpp b/src/mathicgb/PolyReducer.cpp
index a5431f1..50a189d 100755
--- a/src/mathicgb/PolyReducer.cpp
+++ b/src/mathicgb/PolyReducer.cpp
@@ -1,12 +1,11 @@
// Copyright 2011 Michael E. Stillman
-
#include "stdinc.h"
#include "PolyReducer.hpp"
PolyReducer::PolyReducer(const PolyRing *R0):
R(R0), mMemUsage(0)
{
- f = new Poly(R);
+ f = new Poly(*R);
f_iter = f->begin();
}
@@ -90,14 +89,14 @@ void PolyReducer::value(Poly &result)
Poly::iterator fend = f->end();
result.append(f_iter, fend);
delete f;
- f = new Poly(R);
+ f = new Poly(*R);
f_iter = f->begin();
}
void PolyReducer::resetReducer()
{
delete f;
- f = new Poly(R);
+ f = new Poly(*R);
f_iter = f->begin();
}
diff --git a/src/mathicgb/Reducer.cpp b/src/mathicgb/Reducer.cpp
index 1cd6057..cc6db0d 100755
--- a/src/mathicgb/Reducer.cpp
+++ b/src/mathicgb/Reducer.cpp
@@ -20,8 +20,6 @@
#include <iostream>
#include <algorithm>
-extern int tracingLevel;
-
Reducer::Reducer():
stats_maxsize(0),
stats_maxsize_live(0),
diff --git a/src/mathicgb/Reducer.hpp b/src/mathicgb/Reducer.hpp
index f17fdc3..0e4aac4 100755
--- a/src/mathicgb/Reducer.hpp
+++ b/src/mathicgb/Reducer.hpp
@@ -64,7 +64,7 @@ public:
/** Sets how many parallel threads to use for reduction - if the
reducer supports it. */
- virtual void setThreadCount(size_t threadCount) = 0;
+ virtual void setThreadCount(int threadCount) = 0;
// ***** Kinds of reducers and creating a Reducer
diff --git a/src/mathicgb/ReducerPack.hpp b/src/mathicgb/ReducerPack.hpp
index ae497ee..a1d7c3c 100755
--- a/src/mathicgb/ReducerPack.hpp
+++ b/src/mathicgb/ReducerPack.hpp
@@ -71,8 +71,6 @@ private:
memt::BufferPool mPool;
};
-extern int tracingLevel;
-
template<template<typename> class Q>
ReducerPack<Q>::ReducerPack(const PolyRing& ring):
mRing(ring),
diff --git a/src/mathicgb/ReducerPackDedup.hpp b/src/mathicgb/ReducerPackDedup.hpp
index 6594e93..3c4b472 100755
--- a/src/mathicgb/ReducerPackDedup.hpp
+++ b/src/mathicgb/ReducerPackDedup.hpp
@@ -86,8 +86,6 @@ private:
memt::BufferPool mPool;
};
-extern int tracingLevel;
-
template<template<typename> class Q>
ReducerPackDedup<Q>::ReducerPackDedup(const PolyRing& ring):
mRing(ring),
diff --git a/src/mathicgb/SigSPairs.cpp b/src/mathicgb/SigSPairs.cpp
index b2d9a85..0c9eb44 100755
--- a/src/mathicgb/SigSPairs.cpp
+++ b/src/mathicgb/SigSPairs.cpp
@@ -1,5 +1,4 @@
// Copyright 2011 Michael E. Stillman
-
#include "stdinc.h"
#include "SigSPairs.hpp"
@@ -11,8 +10,6 @@
#include <stdexcept>
#include <iostream>
-extern int tracingLevel;
-
SigSPairs::SigSPairs(
const PolyRing *R0,
FreeModuleOrder *F0,
diff --git a/src/mathicgb/SignatureGB.cpp b/src/mathicgb/SignatureGB.cpp
index 99eb3a4..c8a78cc 100755
--- a/src/mathicgb/SignatureGB.cpp
+++ b/src/mathicgb/SignatureGB.cpp
@@ -1,15 +1,14 @@
// Copyright 2011 Michael E. Stillman
-
#include "stdinc.h"
-
-#include <mathic.h>
#include "SignatureGB.hpp"
+
#include "FreeModuleOrder.hpp"
#include "Ideal.hpp"
#include "DivisorLookup.hpp"
#include "SigSPairs.hpp"
#include "PolyHeap.hpp"
#include "MTArray.hpp"
+#include <mathic.h>
int tracingLevel = 0;
@@ -91,20 +90,16 @@ SignatureGB::SignatureGB(
stats_SignatureCriterionLate(0),
stats_relativelyPrimeEliminated(0),
stats_pairsReduced(0),
- stats_nsecs(0.0)
+ stats_nsecs(0.0),
+ GB(make_unique<GroebnerBasis>(R, F.get(), divlookup_type, montable_type, preferSparseReducers)),
+ mKoszuls(make_unique<KoszulQueue>(F.get(), R->getMonomialPool())),
+ Hsyz(MonomialTableArray::make(R, montable_type, ideal.size(), !mPostponeKoszul)),
+ reducer(Reducer::makeReducer(reductiontyp, *R)),
+ SP(make_unique<SigSPairs>(R, F.get(), GB.get(), Hsyz.get(), reducer.get(), mPostponeKoszul, mUseBaseDivisors, useSingularCriterionEarly, queueType))
{
- GB = new GroebnerBasis(R, F, divlookup_type, montable_type, preferSparseReducers);
- mKoszuls = new KoszulQueue(F, R->getMonomialPool());
-
- const bool allowRemovals = !mPostponeKoszul;
- Hsyz = MonomialTableArray::make(R, montable_type, ideal.size(), allowRemovals);
-
- reducer = Reducer::makeReducer(reductiontyp, *R).release();
- SP = new SigSPairs(R, F, GB, Hsyz, reducer, mPostponeKoszul, mUseBaseDivisors, useSingularCriterionEarly, queueType);
-
// Populate GB
for (size_t i = 0; i < ideal.size(); i++) {
- Poly *g = new Poly(R);
+ Poly *g = new Poly(*R);
ideal.getPoly(i)->copy(*g);
g->makeMonic();
@@ -127,15 +122,7 @@ SignatureGB::SignatureGB(
}
}
-SignatureGB::~SignatureGB()
-{
- delete reducer;
- delete SP;
- delete Hsyz;
- delete mKoszuls;
- delete GB;
- delete F;
-}
+SignatureGB::~SignatureGB() {}
bool SignatureGB::processSPair
(monomial sig, const SigSPairs::PairContainer& pairs)
@@ -296,7 +283,7 @@ size_t SignatureGB::getMemoryUse() const {
mSpairTmp.capacity() * sizeof(mSpairTmp.front());
sum += SP->getMemoryUse();
- if (mKoszuls != 0)
+ if (mKoszuls.get() != 0)
mKoszuls->getMemoryUse();
return sum;
}
diff --git a/src/mathicgb/SignatureGB.hpp b/src/mathicgb/SignatureGB.hpp
index 610dd8e..a2b1f8a 100755
--- a/src/mathicgb/SignatureGB.hpp
+++ b/src/mathicgb/SignatureGB.hpp
@@ -43,9 +43,9 @@ public:
// How many reductions were singular
unsigned long long getSingularReductionCount() const;
- GroebnerBasis* getGB() { return GB; }
- MonomialTableArray* getSyzTable() { return Hsyz; }
- SigSPairs* getSigSPairs() { return SP; }
+ GroebnerBasis* getGB() { return GB.get(); }
+ MonomialTableArray* getSyzTable() { return Hsyz.get(); }
+ SigSPairs* getSigSPairs() { return SP.get(); }
size_t getMemoryUse() const;
void displayStats(std::ostream& out) const;
@@ -65,18 +65,17 @@ private:
unsigned int mBreakAfter;
unsigned int mPrintInterval;
+
+
+
bool processSPair(monomial sig, const SigSPairs::PairContainer& pairs);
bool step();
const PolyRing *R;
- FreeModuleOrder *F;
+ std::unique_ptr<FreeModuleOrder> F;
- SigSPairs *SP;
- MonomialTableArray *Hsyz;
- GroebnerBasis *GB;
- KoszulQueue *mKoszuls;
+
- Reducer* reducer;
bool const mPostponeKoszul;
@@ -98,6 +97,12 @@ private:
mic::Timer mTimer;
double stats_nsecs;
+
+ std::unique_ptr<GroebnerBasis> GB;
+ std::unique_ptr<KoszulQueue> mKoszuls;
+ std::unique_ptr<MonomialTableArray> Hsyz;
+ std::unique_ptr<Reducer> reducer;
+ std::unique_ptr<SigSPairs> SP;
};
#endif
diff --git a/src/mathicgb/TournamentReducer.cpp b/src/mathicgb/TournamentReducer.cpp
index a244698..745063e 100755
--- a/src/mathicgb/TournamentReducer.cpp
+++ b/src/mathicgb/TournamentReducer.cpp
@@ -5,8 +5,6 @@
#include <utility>
-extern int tracingLevel;
-
TournamentReducer::TournamentReducer(const PolyRing& ring):
mRing(ring),
mLeadTerm(0, mRing.allocMonomial()),
diff --git a/src/mathicgb/TypicalReducer.cpp b/src/mathicgb/TypicalReducer.cpp
index 95fe0b0..37c97a1 100755
--- a/src/mathicgb/TypicalReducer.cpp
+++ b/src/mathicgb/TypicalReducer.cpp
@@ -5,8 +5,6 @@
#include "PolyBasis.hpp"
#include <iostream>
-extern int tracingLevel;
-
void TypicalReducer::reset()
{
mArena.freeAllAllocs();
@@ -48,7 +46,7 @@ Poly* TypicalReducer::regularReduce(
insertTail(const_term(coef, u), &basis.poly(reducer));
basis.basis().usedAsReducer(reducer);
- Poly* result = new Poly(&ring);
+ Poly* result = new Poly(ring);
unsigned long long steps = 2; // number of steps in this reduction
for (const_term v; leadTerm(v); ++steps) {
@@ -95,7 +93,7 @@ std::unique_ptr<Poly> TypicalReducer::classicTailReduce(const Poly& poly, const
basis.ring().coefficientSetOne(identity.coeff);
insertTail(identity, &poly);
- std::unique_ptr<Poly> result(new Poly(&basis.ring()));
+ std::unique_ptr<Poly> result(new Poly(basis.ring()));
result->appendTerm(poly.getLeadCoefficient(), poly.getLeadMonomial());
return classicReduce(std::move(result), basis);
@@ -157,7 +155,7 @@ void TypicalReducer::classicReducePolySet
}
}
-void TypicalReducer::setThreadCount(size_t threadCount) {
+void TypicalReducer::setThreadCount(int threadCount) {
// multithreading not supported here (yet!)
}
@@ -219,6 +217,5 @@ std::unique_ptr<Poly> TypicalReducer::classicReduce
}
std::unique_ptr<Poly> TypicalReducer::classicReduce(const PolyBasis& basis) {
- std::unique_ptr<Poly> result(new Poly(&basis.ring()));
- return classicReduce(std::move(result), basis);
+ return classicReduce(make_unique<Poly>(basis.ring()), basis);
}
diff --git a/src/mathicgb/TypicalReducer.hpp b/src/mathicgb/TypicalReducer.hpp
index 15cb59c..65c27e8 100755
--- a/src/mathicgb/TypicalReducer.hpp
+++ b/src/mathicgb/TypicalReducer.hpp
@@ -43,7 +43,7 @@ public:
const PolyBasis& basis,
std::vector<std::unique_ptr<Poly> >& reducedOut);
- virtual void setThreadCount(size_t threadCount);
+ virtual void setThreadCount(int threadCount);
protected:
// These are the methods that sub-classes define in order to carry
diff --git a/src/mathicgb/io-util.cpp b/src/mathicgb/io-util.cpp
index 1574dab..5e995f7 100755
--- a/src/mathicgb/io-util.cpp
+++ b/src/mathicgb/io-util.cpp
@@ -20,7 +20,7 @@
std::unique_ptr<Poly> polyParseFromString(const PolyRing *R, const std::string &s)
{
- std::unique_ptr<Poly> f(new Poly(R));
+ std::unique_ptr<Poly> f(new Poly(*R));
std::istringstream in(s);
f->parse(in);
return f;
diff --git a/src/mathicgb/stdinc.h b/src/mathicgb/stdinc.h
index d364d08..c9114be 100755
--- a/src/mathicgb/stdinc.h
+++ b/src/mathicgb/stdinc.h
@@ -15,13 +15,14 @@
#ifdef _MSC_VER // For Microsoft Compiler in Visual Studio C++.
#define NO_INLINE __declspec(noinline)
-#pragma warning (disable: 4996) // std::copy is flagged as dangerous.
+#pragma warning (disable: 4996) // std::copy on pointers is flagged as dangerous
#pragma warning (disable: 4290) // VC++ ignores throw () specification.
#pragma warning (disable: 4127) // Warns about using "while (true)".
#pragma warning (disable: 4100) // Warns about unused parameters.
#pragma warning (disable: 4800) // Warns on int to bool conversion.
#pragma warning (disable: 4146) // Warns on unary minus on unsigned (bit trick)
+
// This warning warns about using the this pointer in base member
// initializer lists. This is a pretty good warning as that can
// obviously easily go wrong, but it is pretty useful to do as well,
@@ -95,7 +96,67 @@ template<class T, class A1, class A2, class A3, class A4>
std::unique_ptr<T> make_unique(A1&& a1, A2&& a2, A3&& a3, A4&& a4) {
return std::unique_ptr<T>
(new T(std::forward<A1>(a1), std::forward<A2>(a2),
- std::forward<A3>(a3), std::forward<A3>(a3)));
+ std::forward<A3>(a3), std::forward<A4>(a4)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5>
+ std::unique_ptr<T> make_unique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5, class A6>
+ std::unique_ptr<T> make_unique
+ (A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5), std::forward<A6>(a6)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5, class A6,
+class A7>
+ std::unique_ptr<T> make_unique
+ (A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5), std::forward<A6>(a6),
+ std::forward<A7>(a7)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5, class A6,
+class A7, class A8>
+ std::unique_ptr<T> make_unique
+ (A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7,
+ A8&& a8) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5), std::forward<A6>(a6),
+ std::forward<A7>(a7), std::forward<A8>(a8)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5, class A6,
+class A7, class A8, class A9>
+ std::unique_ptr<T> make_unique
+ (A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7,
+ A8&& a8, A9&& a9) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5), std::forward<A6>(a6),
+ std::forward<A7>(a7), std::forward<A8>(a8),
+ std::forward<A9>(a9)));
+}
+template<class T, class A1, class A2, class A3, class A4, class A5, class A6,
+class A7, class A8, class A9, class A10>
+ std::unique_ptr<T> make_unique
+ (A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7,
+ A8&& a8, A9&& a9, A10&& a10) {
+ return std::unique_ptr<T>
+ (new T(std::forward<A1>(a1), std::forward<A2>(a2),
+ std::forward<A3>(a3), std::forward<A4>(a4),
+ std::forward<A5>(a5), std::forward<A6>(a6),
+ std::forward<A7>(a7), std::forward<A8>(a8),
+ std::forward<A9>(a9), std::forward<A9>(a10)));
}
@@ -113,3 +174,7 @@ typedef signed char int8;
static const size_t BitsPerByte = 8;
static const size_t MemoryAlignment = sizeof(void*);
+
+/// The higher the value the more detailed output about what the program
+/// is doing.
+extern int tracingLevel;
diff --git a/src/test/F4MatrixBuilder.cpp b/src/test/F4MatrixBuilder.cpp
index 86a9eb2..2bdace6 100755
--- a/src/test/F4MatrixBuilder.cpp
+++ b/src/test/F4MatrixBuilder.cpp
@@ -26,7 +26,7 @@ namespace {
}
const Poly& addBasisElement(const std::string& str) {
- std::unique_ptr<Poly> p(new Poly(mRing.get()));
+ std::unique_ptr<Poly> p(new Poly(*mRing));
std::istringstream in(str);
p->parse(in);
mBasis.insert(std::move(p));
@@ -107,14 +107,14 @@ TEST(F4MatrixBuilder, DirectReducers) {
maker.addBasisElement("d2<0>"); // does not divide
F4MatrixBuilder& builder = maker.create();
- Poly p1(&builder.ring());
+ Poly p1(builder.ring());
{
std::istringstream in("a3<0>+b2+c+d");
p1.parse(in);
builder.addPolynomialToMatrix(p1.getLeadMonomial(), p1);
}
- Poly p2(&builder.ring());
+ Poly p2(builder.ring());
{
std::istringstream in("a3<0>+2b2+3c+4d");
p2.parse(in);
diff --git a/src/test/F4MatrixReducer.cpp b/src/test/F4MatrixReducer.cpp
index 7bd050c..9558dbf 100755
--- a/src/test/F4MatrixReducer.cpp
+++ b/src/test/F4MatrixReducer.cpp
@@ -14,7 +14,7 @@ TEST(F4MatrixReducer, Reduce) {
QuadMatrix m;
m.ring = ring.get();
- Poly p(ring.get());
+ Poly p(*ring);
std::istringstream in("a4+a3+a2+a1+b5+b4+b3+b2+b1");
p.parse(in);
size_t count = 0;
diff --git a/src/test/QuadMatrixBuilder.cpp b/src/test/QuadMatrixBuilder.cpp
index 4c0543a..7b42578 100755
--- a/src/test/QuadMatrixBuilder.cpp
+++ b/src/test/QuadMatrixBuilder.cpp
@@ -20,7 +20,7 @@ namespace {
{
const PolyRing& ring = b.ring();
{
- Poly p(&b.ring());
+ Poly p(b.ring());
std::istringstream in(left);
p.parseDoNotOrder(in);
size_t colCount = 0;
@@ -37,7 +37,7 @@ namespace {
ASSERT_EQ(colCount, b.leftColCount());
}
{
- Poly p(&b.ring());
+ Poly p(b.ring());
std::istringstream in(right);
p.parseDoNotOrder(in);
size_t colCount = 0;
@@ -110,7 +110,7 @@ TEST(QuadMatrixBuilder, ColumnQuery) {
QuadMatrixBuilder b(*ring);
createColumns("a<1>+<0>", "b<0>+c<0>+bc<0>", b);
- Poly p(&b.ring());
+ Poly p(b.ring());
// coefficient 1X=left, 2X=right, 30=not there, % 10 = column index
std::istringstream in
("10a<1>+11<0>+20b<0>+21c<0>+22bc<0>+30ab<0>+30e<0>+10a<1>");
diff --git a/src/test/SparseMatrix.cpp b/src/test/SparseMatrix.cpp
index b868137..073d3b0 100755
--- a/src/test/SparseMatrix.cpp
+++ b/src/test/SparseMatrix.cpp
@@ -9,7 +9,7 @@
namespace {
std::unique_ptr<Poly> parsePoly(const PolyRing& ring, std::string str) {
- auto p = make_unique<Poly>(&ring);
+ auto p = make_unique<Poly>(ring);
std::istringstream in(str);
p->parse(in);
return p;
@@ -75,7 +75,7 @@ TEST(SparseMatrix, toRow) {
mat.appendEntry(4,40);
mat.rowDone();
- Poly p(ring.get());
+ Poly p(*ring);
mat.rowToPolynomial(0, monomials, p);
ASSERT_EQ(*parsePoly(*ring, "0"), p);
mat.rowToPolynomial(1, monomials, p);
diff --git a/src/test/gb-test.cpp b/src/test/gb-test.cpp
index 5267a53..ea5a465 100755
--- a/src/test/gb-test.cpp
+++ b/src/test/gb-test.cpp
@@ -20,8 +20,6 @@
#include <memory>
#include <gtest/gtest.h>
-extern int tracingLevel;
-
TEST(IO, ideal) {
const char* idealA_fromStr_format =
"32003 6 \
@@ -315,7 +313,6 @@ spairQueue reducerType divLookup monTable buchberger postponeKoszul useBaseDivis
}
}
-extern int tracingLevel;
TEST(GB, small) {
testGB(0, idealSmall, idealSmallBasis, idealSmallSyzygies, idealSmallInitial, 7);
}
diff --git a/src/test/poly-test.cpp b/src/test/poly-test.cpp
index 953fa86..bbb6e88 100755
--- a/src/test/poly-test.cpp
+++ b/src/test/poly-test.cpp
@@ -55,7 +55,7 @@ TEST(PolyRing, read) {
TEST(Poly,readwrite) {
std::string f1 = "14ce2<72>+13adf<16>";
std::unique_ptr<PolyRing> R(ringFromString("32003 6 1\n1 1 1 1 1 1"));
- Poly f(R.get());
+ Poly f(*R);
std::stringstream ifil(f1);
f.parseDoNotOrder(ifil);
std::ostringstream o;
@@ -66,7 +66,7 @@ TEST(Poly,readwrite) {
bool testPolyParse(PolyRing* R, std::string s)
{
// parse poly, then see if it matches the orig string
- Poly f(R);
+ Poly f(*R);
std::istringstream i(s);
f.parseDoNotOrder(i);
std::ostringstream o;
@@ -78,7 +78,7 @@ bool testPolyParse(PolyRing* R, std::string s)
bool testPolyParse2(PolyRing* R, std::string s, std::string answer)
{
// parse poly, then see if it matches the orig string
- Poly f(R);
+ Poly f(*R);
std::istringstream i(s);
f.parseDoNotOrder(i);
std::ostringstream o;
@@ -546,7 +546,7 @@ TEST(MTArray,DivList1) {
// We create a table here
size_t not_used = 0;
std::unique_ptr<PolyRing> R(ringFromString("32003 6 1\n1 1 1 1 1 1"));
- MonomialTableArray* M(MonomialTableArray::make(R.get(), 1, 6, false));
+ auto M = MonomialTableArray::make(R.get(), 1, 6, false);
std::string mons[2] = {
"abc<1>",
"a2d<1>"
@@ -663,7 +663,7 @@ TEST(Ideal,readwrite) {
const Poly *f = I->getPoly(i);
std::ostringstream o;
f->display(o,false);
- Poly g(f->getRing());
+ Poly g(f->ring());
std::stringstream ifil(o.str());
g.parse(ifil);
EXPECT_TRUE(g == *f);
@@ -688,7 +688,7 @@ TEST(Poly,lead) {
std::unique_ptr<Poly> multIdealByPolyReducer(int typ, const Ideal& ideal, const Poly& g)
{
const PolyRing& R = ideal.ring();
- std::unique_ptr<Poly> poly(new Poly(&R));
+ auto poly = make_unique<Poly>(R);
std::unique_ptr<Reducer> H = Reducer::makeReducer(static_cast<Reducer::ReducerType>(typ), R);
for (Poly::const_iterator i = g.begin(); i != g.end(); ++i) {
monomial mon = R.allocMonomial();
@@ -777,7 +777,7 @@ TEST(PolyHashTable,test1) {
H.fromPoly(*f1, M1);
H.fromPoly(*f1, M2);
EXPECT_TRUE(M2.empty());
- Poly g(R.get());
+ Poly g(*R);
H.toPoly(M1,g);
// f1->display(std::cout);
// std::cout << std::endl;
@@ -790,7 +790,7 @@ TEST(PolyHashTable,test1) {
// H.dump();
M1.clear();
H.fromPoly(*f1, M1);
- Poly g2(R.get());
+ Poly g2(*R);
H.toPoly(M1,g2);
EXPECT_TRUE(g == g2);
}
--
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