From 68f6cb0605852eeff0232f64fa37d34babaaaed8 Mon Sep 17 00:00:00 2001 From: CJ Carey Date: Wed, 5 Feb 2014 14:23:34 -0500 Subject: [PATCH 1/2] fixing compile warnings, adding .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After this patch, clang doesn’t emit any warnings or errors --- .gitignore | 5 +++++ src/BipartiteFunctionOracle.cpp | 11 ++++++----- src/BipartiteMatrixOracle.cpp | 9 +++++---- src/BipartiteMatrixOracle.h | 2 -- src/FunctionOracle.cpp | 3 +-- src/IntDoubleMap.h | 2 -- src/MatrixOracle.cpp | 3 +-- src/utils.h | 2 -- 8 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aadb3c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +Release/BMatchingSolver +Release/src/*.d +Shared\ Library/src/*.d +Shared\ Library/libBMatchingSolver.* diff --git a/src/BipartiteFunctionOracle.cpp b/src/BipartiteFunctionOracle.cpp index df83961..80ebef0 100644 --- a/src/BipartiteFunctionOracle.cpp +++ b/src/BipartiteFunctionOracle.cpp @@ -16,7 +16,7 @@ BipartiteFunctionOracle::BipartiteFunctionOracle(double **dataX, double **dataY, rows = r; cols = c; dimension = d; - setCacheSize(max(rows, cols)); + setCacheSize(std::max(rows, cols)); } BipartiteFunctionOracle::~BipartiteFunctionOracle() { @@ -27,12 +27,13 @@ int BipartiteFunctionOracle::getSize() { } double BipartiteFunctionOracle::computeWeight(int row, int col) { - if (row < rows && col < rows || - row >= rows && col >= rows || - row - rows >= cols || col - rows >= cols) { + if ((row < rows && col < rows) || + (row >= rows && col >= rows) || + row - rows >= cols || col - rows >= cols) { return -INFINITY; - } else if (row < rows) + } else if (row < rows) { return weightFunction->getWeight(X[row], Y[col - rows], dimension); + } return weightFunction->getWeight(X[col], Y[row-rows], dimension); } diff --git a/src/BipartiteMatrixOracle.cpp b/src/BipartiteMatrixOracle.cpp index 812ade3..6b50238 100644 --- a/src/BipartiteMatrixOracle.cpp +++ b/src/BipartiteMatrixOracle.cpp @@ -27,12 +27,13 @@ int BipartiteMatrixOracle::getSize() { } double BipartiteMatrixOracle::computeWeight(int row, int col) { - if (row < rows && col < rows || - row >= rows && col >= rows || - row - rows >= cols || col - rows >= cols) + if ((row < rows && col < rows) || + (row >= rows && col >= rows) || + row - rows >= cols || col - rows >= cols) { return -INFINITY; - else if (row < rows) + }else if (row < rows) { return K[row][col - rows]; + } return K[col][row - rows]; } diff --git a/src/BipartiteMatrixOracle.h b/src/BipartiteMatrixOracle.h index 9497483..374b81f 100644 --- a/src/BipartiteMatrixOracle.h +++ b/src/BipartiteMatrixOracle.h @@ -40,8 +40,6 @@ class BipartiteMatrixOracle: public WeightOracle { int rows; int cols; double **K; - int **index; - double **cache; }; #endif /* KERNELMATRIXORACLE_H_ */ diff --git a/src/FunctionOracle.cpp b/src/FunctionOracle.cpp index a8f5c59..d762b2d 100644 --- a/src/FunctionOracle.cpp +++ b/src/FunctionOracle.cpp @@ -20,8 +20,7 @@ FunctionOracle::~FunctionOracle() { } double FunctionOracle::computeWeight(int row, int col) { - if (!selfLoops && row == col || - row >= size || col >= size) + if ((!selfLoops && row == col) || row >= size || col >= size) return -INFINITY; return weightFunction->getWeight(data[row], data[col], dimension); } diff --git a/src/IntDoubleMap.h b/src/IntDoubleMap.h index f1da36e..ca66285 100644 --- a/src/IntDoubleMap.h +++ b/src/IntDoubleMap.h @@ -59,9 +59,7 @@ class IntDoubleMap { double * value; bool * filled; int size; - int lastIndex; int tableSize; - int maxSize; double hits; double misses; diff --git a/src/MatrixOracle.cpp b/src/MatrixOracle.cpp index 910c679..aaca070 100644 --- a/src/MatrixOracle.cpp +++ b/src/MatrixOracle.cpp @@ -22,8 +22,7 @@ int MatrixOracle::getSize() { } double MatrixOracle::computeWeight(int row, int col) { - if (!selfLoops && row == col || - row >= size || col >= size) + if ((!selfLoops && row == col) || row >= size || col >= size) return -INFINITY; return weights[row][col]; } diff --git a/src/utils.h b/src/utils.h index 987c1ad..98ad015 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,8 +10,6 @@ #ifndef UTILS_H_ #define UTILS_H_ -using namespace std; - namespace utils { // Takes a file and reads the input as a matrix of values From e3e3ebd795f4b3d40ddc506b6efafffcad495264 Mon Sep 17 00:00:00 2001 From: CJ Carey Date: Wed, 5 Feb 2014 14:36:58 -0500 Subject: [PATCH 2/2] Fixing Linux build issues --- Shared Library/objects.mk | 2 +- src/BMatchingSolver.cpp | 1 + src/BeliefPropagator.cpp | 1 + src/IntSet.cpp | 1 + src/OscillationDetector.cpp | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Shared Library/objects.mk b/Shared Library/objects.mk index 742c2da..159e27c 100644 --- a/Shared Library/objects.mk +++ b/Shared Library/objects.mk @@ -4,5 +4,5 @@ USER_OBJS := -LIBS := +LIBS := -lm -lpthread diff --git a/src/BMatchingSolver.cpp b/src/BMatchingSolver.cpp index 9f30c02..31f93fd 100644 --- a/src/BMatchingSolver.cpp +++ b/src/BMatchingSolver.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "BMatchingLibrary.h" #include "utils.h" #include "SparseMatrix.h" diff --git a/src/BeliefPropagator.cpp b/src/BeliefPropagator.cpp index 70caa52..c7fe361 100644 --- a/src/BeliefPropagator.cpp +++ b/src/BeliefPropagator.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "BeliefPropagator.h" #include "BMatchingSolution.h" using namespace std; diff --git a/src/IntSet.cpp b/src/IntSet.cpp index f9aaf9f..2201228 100644 --- a/src/IntSet.cpp +++ b/src/IntSet.cpp @@ -7,6 +7,7 @@ #include "IntSet.h" #include +#include using namespace std; IntSet::IntSet() { diff --git a/src/OscillationDetector.cpp b/src/OscillationDetector.cpp index e45c038..5380881 100644 --- a/src/OscillationDetector.cpp +++ b/src/OscillationDetector.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "OscillationDetector.h"