[mathicgb] 53/393: Changes to remove some errors and warnings when compiling with MS V++ 2012.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:31 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 9544aed935c845a41cd3484f3dbdbfc7f1d556a5
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date:   Mon Oct 8 12:34:39 2012 +0200

    Changes to remove some errors and warnings when compiling with MS V++ 2012.
---
 src/mathicgb/BjarkeGeobucket2.cpp  |  1 -
 src/mathicgb/F4MatrixBuilder.cpp   | 12 ++++++++----
 src/mathicgb/F4MatrixReducer.cpp   | 30 +++++++++++++++++++-----------
 src/mathicgb/FreeModuleOrder.cpp   |  4 ++--
 src/mathicgb/Poly.cpp              |  1 +
 src/mathicgb/PolyRing.hpp          |  5 +++--
 src/mathicgb/QuadMatrixBuilder.cpp |  2 +-
 src/mathicgb/SPairs.hpp            |  3 ++-
 src/mathicgb/SparseMatrix.hpp      | 31 +++++++++++++++++--------------
 9 files changed, 53 insertions(+), 36 deletions(-)

diff --git a/src/mathicgb/BjarkeGeobucket2.cpp b/src/mathicgb/BjarkeGeobucket2.cpp
index 36ecf3a..726fa5c 100755
--- a/src/mathicgb/BjarkeGeobucket2.cpp
+++ b/src/mathicgb/BjarkeGeobucket2.cpp
@@ -21,7 +21,6 @@ void BjarkeGeobucket2::insert(Poly::const_iterator first,
   for (Poly::const_iterator i = first; i != last; ++i)
     {
       monomial monomspace = mRing.allocMonomial(mArena);
-      node *p;
       mRing.monomialCopy(i.getMonomial(), monomspace);
       std::pair<bool, node*> found = mHashTable.insert(monomspace, i.getCoefficient());
       if (found.first)
diff --git a/src/mathicgb/F4MatrixBuilder.cpp b/src/mathicgb/F4MatrixBuilder.cpp
index 98fda78..2828aeb 100755
--- a/src/mathicgb/F4MatrixBuilder.cpp
+++ b/src/mathicgb/F4MatrixBuilder.cpp
@@ -137,8 +137,10 @@ void F4MatrixBuilder::buildMatrixAndClear(QuadMatrix& matrix) {
         if (itB != endB)
           ring().monomialMult(itB.getMonomial(), it->multiplyB, monoB);
       }
-      if (c != 0)
-        mBuilder.appendEntryBottom(createOrFindColumnOf(mono), c);
+      if (c != 0) {
+	    MATHICGB_ASSERT(c < std::numeric_limits<QuadMatrixBuilder::Scalar>::max());
+        mBuilder.appendEntryBottom(createOrFindColumnOf(mono), static_cast<QuadMatrixBuilder::Scalar>(c));
+	  }
     }
     ring().freeMonomial(monoA);
     ring().freeMonomial(monoB);
@@ -192,7 +194,8 @@ void F4MatrixBuilder::appendRowTop(const_monomial multiple, const Poly& poly) {
   Poly::const_iterator end = poly.end();
   for (Poly::const_iterator it = poly.begin(); it != end; ++it) {
     ring().monomialMult(it.getMonomial(), multiple, mono);
-    mBuilder.appendEntryTop(createOrFindColumnOf(mono), it.getCoefficient());
+	MATHICGB_ASSERT(it.getCoefficient() < std::numeric_limits<QuadMatrixBuilder::Scalar>::max());
+    mBuilder.appendEntryTop(createOrFindColumnOf(mono), static_cast<QuadMatrixBuilder::Scalar>(it.getCoefficient()));
   }
   mBuilder.rowDoneTopLeftAndRight();
   ring().freeMonomial(mono);
@@ -204,8 +207,9 @@ void F4MatrixBuilder::appendRowBottom
   Poly::const_iterator end = poly.end();
   for (Poly::const_iterator it = poly.begin(); it != end; ++it) {
     ring().monomialMult(it.getMonomial(), multiple, mono);
+	MATHICGB_ASSERT(it.getCoefficient() < std::numeric_limits<QuadMatrixBuilder::Scalar>::max());
     mBuilder.appendEntryBottom
-      (createOrFindColumnOf(mono), it.getCoefficient());
+      (createOrFindColumnOf(mono), static_cast<QuadMatrixBuilder::Scalar>(it.getCoefficient()));
   }
   mBuilder.rowDoneBottomLeftAndRight();
   ring().freeMonomial(mono);
diff --git a/src/mathicgb/F4MatrixReducer.cpp b/src/mathicgb/F4MatrixReducer.cpp
index 88258cd..3f9b242 100755
--- a/src/mathicgb/F4MatrixReducer.cpp
+++ b/src/mathicgb/F4MatrixReducer.cpp
@@ -464,14 +464,17 @@ void myReduce
       MATHICGB_ASSERT(row < pivotCount);
       MATHICGB_ASSERT(!reduceByLeft.emptyRow(row));
       MATHICGB_ASSERT(reduceByLeft.leadCol(row) == pivot);
-      denseRow.addRowMultiple(entry, ++reduceByLeft.rowBegin(row), reduceByLeft.rowEnd(row));
+      MATHICGB_ASSERT(entry < std::numeric_limits<SparseMatrix::Scalar>::max());
+      denseRow.addRowMultiple(static_cast<SparseMatrix::Scalar>(entry), ++reduceByLeft.rowBegin(row), reduceByLeft.rowEnd(row));
       denseRow[pivot] = entry;
     }
 #pragma omp critical
     {
-      for (size_t pivot = 0; pivot < pivotCount; ++pivot)
+      for (size_t pivot = 0; pivot < pivotCount; ++pivot) {
+		MATHICGB_ASSERT(denseRow[pivot] < std::numeric_limits<Scalar>::max());
         if (denseRow[pivot] != 0)
-          tmp.appendEntry(rowThatReducesCol[pivot], denseRow[pivot]);
+          tmp.appendEntry(rowThatReducesCol[pivot], static_cast<SparseMatrix::Scalar>(denseRow[pivot]));
+	  }
       tmp.rowDone();
       rowOrder[tmp.rowCount() - 1] = row;
     }
@@ -496,7 +499,7 @@ void myReduce
 #pragma omp critical
     {
       bool zero = true;
-      for (size_t col = 0; col < colCountRight; ++col) {
+	  for (SparseMatrix::ColIndex col = 0; col < colCountRight; ++col) {
         SparseMatrix::Scalar entry = static_cast<SparseMatrix::Scalar>(denseRowX[col] % modulus);
         if (entry != 0)
           reduced.appendEntry(col, entry), zero = false;
@@ -691,9 +694,13 @@ void readMany(FILE* file, size_t count, std::vector<T>& v) {
 // Writes an SparseMatrix
 void writeSparseMatrix
 (const SparseMatrix& matrix, SparseMatrix::Scalar modulus, const std::string& fileName) {
-  const uint32 rowCount = matrix.rowCount();
-  const uint32 colCount = matrix.colCount();
-  const uint64 entryCount = matrix.entryCount();
+  MATHICGB_ASSERT(rowCount <= std::numeric_limits<uint32>::max());
+  MATHICGB_ASSERT(colCount <= std::numeric_limits<uint32>::max());
+  MATHICGB_ASSERT(entryCount <= std::numeric_limits<uint64>::max());
+
+  const uint32 rowCount = static_cast<uint32>(matrix.rowCount());
+  const uint32 colCount = static_cast<uint32>(matrix.colCount());
+  const uint64 entryCount = static_cast<uint32>(matrix.entryCount());
 
   FILE* file = fopen(fileName.c_str(), "w");
   if (file == NULL)
@@ -709,7 +716,7 @@ void writeSparseMatrix
 
   std::vector<uint32> sizes;
   for (size_t row = 0; row < rowCount; ++row)
-    sizes.push_back(matrix.entryCountInRow(row));
+    sizes.push_back(static_cast<uint32>(matrix.entryCountInRow(row)));
   writeMany<uint32>(sizes, file);
 
   // todo: don't leak file on exception.
@@ -729,10 +736,10 @@ SparseMatrix::Scalar readSparseMatrix(const std::string& fileName, SparseMatrix&
   uint64 const entryCount = readOne<uint64>(file);
 
   std::vector<uint16> entries;
-  readMany(file, entryCount, entries);
+  readMany(file, static_cast<size_t>(entryCount), entries);
 
   std::vector<uint32> indices;
-  readMany(file, entryCount, indices);
+  readMany(file, static_cast<size_t>(entryCount), indices);
 
   std::vector<uint32> sizes;
   readMany(file, rowCount, sizes);
@@ -981,7 +988,8 @@ void F4MatrixReducer::reduce
   if (ring.charac() > std::numeric_limits<SparseMatrix::Scalar>::max())
     throw std::overflow_error("Too large modulus in F4 matrix computation.");
 
-  SparseMatrix::Scalar modulus = ring.charac();
+  MATHICGB_ASSERT(ring.charac() <= std::numeric_limits<SparseMatrix::Scalar>::max());
+  SparseMatrix::Scalar modulus = static_cast<SparseMatrix::Scalar>(ring.charac());
 
   {
 
diff --git a/src/mathicgb/FreeModuleOrder.cpp b/src/mathicgb/FreeModuleOrder.cpp
index 8e5dc39..3125ac2 100755
--- a/src/mathicgb/FreeModuleOrder.cpp
+++ b/src/mathicgb/FreeModuleOrder.cpp
@@ -184,8 +184,8 @@ namespace {
 
     typedef SigPTConfiguration<Cmp> PC;
     mathic::PairQueue<PC> mPairQueue;
-    friend class mathic::PairQueueNamespace::ConstructPairDataFunction<PC>;
-    friend class mathic::PairQueueNamespace::DestructPairDataFunction<PC>;
+    friend struct mathic::PairQueueNamespace::ConstructPairDataFunction<PC>;
+    friend struct mathic::PairQueueNamespace::DestructPairDataFunction<PC>;
   };
 }
 
diff --git a/src/mathicgb/Poly.cpp b/src/mathicgb/Poly.cpp
index 708cec6..0c16514 100755
--- a/src/mathicgb/Poly.cpp
+++ b/src/mathicgb/Poly.cpp
@@ -339,6 +339,7 @@ void Poly::see(bool print_comp) const
 
 std::ostream& operator<<(std::ostream& out, const Poly& p) {
   p.see(false);
+  return out;
 }
 
 bool Poly::termsAreInDescendingOrder() const {
diff --git a/src/mathicgb/PolyRing.hpp b/src/mathicgb/PolyRing.hpp
index f00f4a6..023a429 100755
--- a/src/mathicgb/PolyRing.hpp
+++ b/src/mathicgb/PolyRing.hpp
@@ -68,8 +68,9 @@ template<> struct ModularProdType<int16> {typedef int32 type;};
 template<> struct ModularProdType<int32> {typedef int64 type;};
 
 /** Returns a*b mod modulus.  It is required that 0 <= a, b < modulus. */
-template<class T, class BigT = typename ModularProdType<T>::type>
+template<class T>
 T modularProduct(T a, T b, T modulus) {
+  typedef typename ModularProdType<T>::type BigT;
   MATHICGB_ASSERT(0 <= a);
   MATHICGB_ASSERT(a < modulus);
   MATHICGB_ASSERT(0 <= b);
@@ -314,7 +315,7 @@ public:
 
   void displayHashValues() const;
 
-  exponent monomialHashIndex() const { return mHashIndex; }
+  size_t monomialHashIndex() const { return mHashIndex; }
 
   ///////////////////////////////////////////
   // Monomial Routines //////////////////////
diff --git a/src/mathicgb/QuadMatrixBuilder.cpp b/src/mathicgb/QuadMatrixBuilder.cpp
index 3c4e57d..4243b4d 100755
--- a/src/mathicgb/QuadMatrixBuilder.cpp
+++ b/src/mathicgb/QuadMatrixBuilder.cpp
@@ -11,7 +11,7 @@ QuadMatrixBuilder::QuadMatrixBuilder(const PolyRing& ring):
   mMonomialToCol(ArbitraryOrdering(ring)) {}
 #else
 mMonomialToCol(100, Hash(ring), Equal(ring)) {
-  mMonomialToCol.max_load_factor(0.3);
+  mMonomialToCol.max_load_factor(0.3f);
 }
 #endif
 
diff --git a/src/mathicgb/SPairs.hpp b/src/mathicgb/SPairs.hpp
index 6da2bc2..4587e2d 100755
--- a/src/mathicgb/SPairs.hpp
+++ b/src/mathicgb/SPairs.hpp
@@ -4,6 +4,7 @@
 #include "PairTriangle.hpp"
 #include <utility>
 #include <mathic.h>
+#include <memory>
 
 class PolyBasis;
 
@@ -14,7 +15,7 @@ public:
   SPairs(const PolyBasis& basis, size_t queueType);
 
   // Returns the number of S-pairs in the data structure.
-  size_t pairCount() const {mTri.pairCount();}
+  size_t pairCount() const {return mTri.pairCount();}
 
   // Returns true if there all S-pairs have been eliminated or popped.
   bool empty() const {return mTri.empty();}
diff --git a/src/mathicgb/SparseMatrix.hpp b/src/mathicgb/SparseMatrix.hpp
index f56cfee..3ccf16e 100755
--- a/src/mathicgb/SparseMatrix.hpp
+++ b/src/mathicgb/SparseMatrix.hpp
@@ -173,7 +173,7 @@ class SparseMatrix {
     }
     rowDone();
   }
-
+  
   void appendRow(const SparseMatrix& matrix, RowIndex row) {
     MATHICGB_ASSERT(row < matrix.rowCount());
     RowIterator it = matrix.rowBegin(row);
@@ -213,7 +213,7 @@ class SparseMatrix {
 
     std::vector<ColIndex>().swap(sizes); // deallocate old memory
   }
-
+  
   void swap(SparseMatrix& matrix) {
     mColIndices.swap(matrix.mColIndices);
     mEntries.swap(matrix.mEntries);
@@ -228,8 +228,9 @@ class SparseMatrix {
     mRowOffsets.push_back(0);
     mColCount = newColCount;
   }
-
-  struct RowIterator {
+  
+  class RowIterator {
+  public:
     RowIterator& operator++() {
       ++mOffset;
       return *this;
@@ -246,7 +247,7 @@ class SparseMatrix {
     const SparseMatrix& mMatrix;
     size_t mOffset;      
   };
-
+  
   RowIndex rowCount() const {
     MATHICGB_ASSERT(!mRowOffsets.empty());
     return mRowOffsets.size() - 1;
@@ -255,7 +256,7 @@ class SparseMatrix {
   ColIndex colCount() const {
     return mColCount;
   }
-
+  
   RowIterator rowBegin(RowIndex row) const {
     MATHICGB_ASSERT(row < rowCount());
     return RowIterator(*this, mRowOffsets[row]);
@@ -265,7 +266,7 @@ class SparseMatrix {
     MATHICGB_ASSERT(row < rowCount());
     return RowIterator(*this, mRowOffsets[row + 1]);
   }
-
+  
   void ensureAtLeastThisManyColumns(ColIndex count) {
     if (count > colCount())
       mColCount = count;
@@ -281,8 +282,8 @@ class SparseMatrix {
     }
     rowDone();
   }
-
-  void appendRow(std::vector<uint64> const& v, size_t leadCol = 0) {
+  
+  void appendRow(std::vector<uint64> const& v, ColIndex leadCol = 0) {
     MATHICGB_ASSERT(v.size() == colCount());
 #ifdef MATHICGB_DEBUG
     for (ColIndex col = leadCol; col < leadCol; ++col) {
@@ -291,12 +292,14 @@ class SparseMatrix {
 #endif
 
     ColIndex count = colCount();
-    for (ColIndex col = leadCol; col < count; ++col)
+    for (ColIndex col = leadCol; col < count; ++col) {
+	  MATHICGB_ASSERT(v[col] < std::numeric_limits<Scalar>::max());
       if (v[col] != 0)
-        appendEntry(col, v[col]);
+        appendEntry(col, static_cast<Scalar>(v[col]));
+	}
     rowDone();
   }
-  
+
   void appendRowWithModulusNormalized(std::vector<uint64> const& v, Scalar modulus) {
     MATHICGB_ASSERT(v.size() == colCount());
     ColIndex count = colCount();
@@ -354,7 +357,7 @@ class SparseMatrix {
   const std::vector<ColIndex>& colIndices() const {
     return mColIndices;
   }
-
+  
   typedef std::vector<ColIndex>::iterator AllColIndicesIterator;
   AllColIndicesIterator allColIndicesBegin() {return mColIndices.begin();}
   AllColIndicesIterator allColIndicesEnd() {return mColIndices.end();}
@@ -367,7 +370,7 @@ class SparseMatrix {
   /// each row is weakly increasing going from top to bottom. Quite
   /// slow and it makes a copy internally.
   void sortRowsByIncreasingPivots();
-
+  
 private:
   friend class RowIterator;
 

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