Fixed ~20 potential errors identified by the MS complier.

This commit is contained in:
Andrey Kamaev
2012-03-31 11:09:16 +00:00
parent 1e5a600d13
commit 72f2523d0f
15 changed files with 150 additions and 133 deletions

View File

@@ -46,8 +46,8 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
typedef typename Distance::ResultType DistanceType;
int n = nn + skip;
int* match = new int[n];
DistanceType* dists = new DistanceType[n];
std::vector<int> match(n);
std::vector<DistanceType> dists(n);
dists[0] = distance(dataset[0], query, dataset.cols);
match[0] = 0;
@@ -77,9 +77,6 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
for (int i=0; i<nn; ++i) {
matches[i] = match[i+skip];
}
delete[] match;
delete[] dists;
}

View File

@@ -98,9 +98,9 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
KNNResultSet<DistanceType> resultSet(nn+skipMatches);
SearchParams searchParams(checks);
int* indices = new int[nn+skipMatches];
DistanceType* dists = new DistanceType[nn+skipMatches];
int* neighbors = indices + skipMatches;
std::vector<int> indices(nn+skipMatches);
std::vector<DistanceType> dists(nn+skipMatches);
int* neighbors = &indices[skipMatches];
int correct = 0;
DistanceType distR = 0;
@@ -112,7 +112,7 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
correct = 0;
distR = 0;
for (size_t i = 0; i < testData.rows; i++) {
resultSet.init(indices, dists);
resultSet.init(&indices[0], &dists[0]);
index.findNeighbors(resultSet, testData[i], searchParams);
correct += countCorrectMatches(neighbors,matches[i], nn);
@@ -122,9 +122,6 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
}
time = float(t.value/repeats);
delete[] indices;
delete[] dists;
float precicion = (float)correct/(nn*testData.rows);
dist = distR/(testData.rows*nn);

View File

@@ -674,7 +674,7 @@ private:
}
delete[] centers_idx;
DistanceType* radiuses = new DistanceType[branching];
std::vector<DistanceType> radiuses(branching);
int* count = new int[branching];
for (int i=0; i<branching; ++i) {
radiuses[i] = 0;
@@ -817,7 +817,6 @@ private:
delete[] dcenters.data;
delete[] centers;
delete[] radiuses;
delete[] count;
delete[] belongs_to;
}