[mathicgb] 127/393: Non-working version, but closer to correct.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:46 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 9924fa721860b36397e9751bec6bc7e81aa06e10
Author: Sharwan Kumar Tiwari <stiwari at mumin.mathematik.uni-kl.de>
Date:   Thu Dec 13 19:07:34 2012 +0100

    Non-working version, but closer to correct.
---
 src/mathicgb/F4MatrixReducer.cpp | 42 +++++++++++++++++++---------------------
 src/test/F4MatrixReducer.cpp     |  1 +
 2 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/mathicgb/F4MatrixReducer.cpp b/src/mathicgb/F4MatrixReducer.cpp
index 019bd00..2164938 100644
--- a/src/mathicgb/F4MatrixReducer.cpp
+++ b/src/mathicgb/F4MatrixReducer.cpp
@@ -382,13 +382,7 @@ namespace {
 //typedef SparseMatrix::ColIndex ColIndex; // todo: same  						:: DONE
 
 //Scalar modPrime = 11; // todo: remove this variable 							:: DONE
-
-const SharwanMatrix m1;
-int x = m1[2,3];
-
-SharwanMatrix m2;
-m2[2,3] = 5;
-
+/*
 class SharwanMatrix {
 public:
 // typedefs for scalar, row index and col index
@@ -410,7 +404,7 @@ private:
   int mX; // todo: remove, just example
   // all member variables go here. member x is written mX.
 };
-
+*/
 void addRowMultipleInplace(
   std::vector<std::vector<SparseMatrix::Scalar> >& matrix,
   const SparseMatrix::RowIndex addRow,
@@ -498,11 +492,12 @@ void rowReducedEchelonMatrix(
   }  
 }   
 
-void reduceToEchelonFormShrawan
-  (SparseMatrix& toReduce, SparseMatrix::Scalar modulus, int threadCount)
-{
+SparseMatrix reduceToEchelonFormShrawan(
+  const SparseMatrix& toReduce,
+  SparseMatrix::Scalar modulus
+) {
   const SparseMatrix::RowIndex rowCount = toReduce.rowCount();
-  const SparseMatrix::ColIndex colCount = toReduce.colCount();
+  const auto colCount = toReduce.computeColCount();
 
   // Convert input matrix to dense format
   std::vector<std::vector<SparseMatrix::Scalar>> matrix(rowCount);
@@ -521,26 +516,28 @@ void reduceToEchelonFormShrawan
   rowReducedEchelonMatrix(matrix, colCount,  modulus);
 
   // convert reduced matrix to SparseMatrix.
-  toReduce.clear(colCount);
+  SparseMatrix reduced;
   for (size_t row = 0; row < rowCount; ++row) {
     bool rowIsZero = true;
     for (size_t col = 0; col < colCount; ++col) {
       if (matrix[row][col] != 0) {
         rowIsZero = false;
-        toReduce.appendEntry(col, matrix[row][col]);
+        reduced.appendEntry(col, matrix[row][col]);
       }
     }
     if (!rowIsZero)
-      toReduce.rowDone();
+      reduced.rowDone();
   }
+  return std::move(reduced);
 }
 
-void reduceToEchelonFormShrawanDelayedModulus
-  (SparseMatrix& toReduce, SparseMatrix::Scalar modulus, int threadCount)
-{
+SparseMatrix reduceToEchelonFormShrawanDelayedModulus(
+  const SparseMatrix& toReduce,
+  SparseMatrix::Scalar modulus
+) {
   // todo: implement delayed modulus
   const SparseMatrix::RowIndex rowCount = toReduce.rowCount();
-  const SparseMatrix::ColIndex colCount = toReduce.colCount();
+  const auto colCount = toReduce.computeColCount();
 
   // Convert input matrix to dense format
   std::vector<std::vector<SparseMatrix::Scalar>> matrix(rowCount);
@@ -557,18 +554,19 @@ void reduceToEchelonFormShrawanDelayedModulus
   rowReducedEchelonMatrix(matrix, colCount, modulus);
 
   // convert reduced matrix to SparseMatrix.
-  toReduce.clear(colCount);
+  SparseMatrix reduced;
   for (size_t row = 0; row < rowCount; ++row) {
     bool rowIsZero = true;
     for (size_t col = 0; col < colCount; ++col) {
       if (matrix[row][col] != 0) {
         rowIsZero = false;
-        toReduce.appendEntry(col, matrix[row][col]);
+        reduced.appendEntry(col, matrix[row][col]);
       }
     }
     if (!rowIsZero)
-      toReduce.rowDone();
+      reduced.rowDone();
   }
+  return std::move(reduced);
 }
 
 SparseMatrix F4MatrixReducer::reduceToBottomRight(const QuadMatrix& matrix) {
diff --git a/src/test/F4MatrixReducer.cpp b/src/test/F4MatrixReducer.cpp
index 4b44f26..9d24f00 100755
--- a/src/test/F4MatrixReducer.cpp
+++ b/src/test/F4MatrixReducer.cpp
@@ -125,3 +125,4 @@ 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