fixed multiple warnings from VS2010.
This commit is contained in:
@@ -176,7 +176,7 @@ public:
|
||||
template <typename T>
|
||||
T* allocate(size_t count = 1)
|
||||
{
|
||||
T* mem = (T*) this->allocateBytes(sizeof(T)*count);
|
||||
T* mem = (T*) this->allocateBytes((int)(sizeof(T)*count));
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
@@ -240,12 +240,12 @@ private:
|
||||
t.start();
|
||||
kmeans.buildIndex();
|
||||
t.stop();
|
||||
float buildTime = t.value;
|
||||
float buildTime = (float)t.value;
|
||||
|
||||
// measure search time
|
||||
float searchTime = test_index_precision(kmeans, sampledDataset, testDataset, gt_matches, index_params.target_precision, checks, nn);;
|
||||
|
||||
float datasetMemory = sampledDataset.rows*sampledDataset.cols*sizeof(float);
|
||||
float datasetMemory = (float)(sampledDataset.rows*sampledDataset.cols*sizeof(float));
|
||||
cost.memoryCost = (kmeans.usedMemory()+datasetMemory)/datasetMemory;
|
||||
cost.searchTimeCost = searchTime;
|
||||
cost.buildTimeCost = buildTime;
|
||||
@@ -266,12 +266,12 @@ private:
|
||||
t.start();
|
||||
kdtree.buildIndex();
|
||||
t.stop();
|
||||
float buildTime = t.value;
|
||||
float buildTime = (float)t.value;
|
||||
|
||||
//measure search time
|
||||
float searchTime = test_index_precision(kdtree, sampledDataset, testDataset, gt_matches, index_params.target_precision, checks, nn);
|
||||
|
||||
float datasetMemory = sampledDataset.rows*sampledDataset.cols*sizeof(float);
|
||||
float datasetMemory = (float)(sampledDataset.rows*sampledDataset.cols*sizeof(float));
|
||||
cost.memoryCost = (kdtree.usedMemory()+datasetMemory)/datasetMemory;
|
||||
cost.searchTimeCost = searchTime;
|
||||
cost.buildTimeCost = buildTime;
|
||||
@@ -459,7 +459,7 @@ private:
|
||||
for (size_t i=0;i<kdtreeParamSpaceSize;++i) {
|
||||
kdtreeCosts[i].first.totalCost = (kdtreeCosts[i].first.timeCost/optTimeCost + index_params.memory_weight * kdtreeCosts[i].first.memoryCost);
|
||||
|
||||
int k = i;
|
||||
int k = (int)i;
|
||||
while (k>0 && kdtreeCosts[k].first.totalCost < kdtreeCosts[k-1].first.totalCost) {
|
||||
swap(kdtreeCosts[k],kdtreeCosts[k-1]);
|
||||
k--;
|
||||
@@ -502,12 +502,12 @@ private:
|
||||
|
||||
// We compute the ground truth using linear search
|
||||
logger().info("Computing ground truth... \n");
|
||||
gt_matches = Matrix<int>(new int[testDataset.rows],testDataset.rows, 1);
|
||||
gt_matches = Matrix<int>(new int[testDataset.rows],(long)testDataset.rows, 1);
|
||||
StartStopTimer t;
|
||||
t.start();
|
||||
compute_ground_truth(sampledDataset, testDataset, gt_matches, 0);
|
||||
t.stop();
|
||||
float bestCost = t.value;
|
||||
float bestCost = (float)t.value;
|
||||
IndexParams* bestParams = new LinearIndexParams();
|
||||
|
||||
// Start parameter autotune process
|
||||
@@ -550,19 +550,19 @@ private:
|
||||
|
||||
float speedup = 0;
|
||||
|
||||
int samples = min(dataset.rows/10, SAMPLE_COUNT);
|
||||
int samples = (int)min(dataset.rows/10, SAMPLE_COUNT);
|
||||
if (samples>0) {
|
||||
Matrix<ELEM_TYPE> testDataset = random_sample(dataset,samples);
|
||||
|
||||
logger().info("Computing ground truth\n");
|
||||
|
||||
// we need to compute the ground truth first
|
||||
Matrix<int> gt_matches(new int[testDataset.rows],testDataset.rows,1);
|
||||
Matrix<int> gt_matches(new int[testDataset.rows],(long)testDataset.rows,1);
|
||||
StartStopTimer t;
|
||||
t.start();
|
||||
compute_ground_truth(dataset, testDataset, gt_matches,1);
|
||||
t.stop();
|
||||
float linear = t.value;
|
||||
float linear = (float)t.value;
|
||||
|
||||
int checks;
|
||||
logger().info("Estimating number of checks\n");
|
||||
@@ -575,7 +575,7 @@ private:
|
||||
float bestSearchTime = -1;
|
||||
float best_cb_index = -1;
|
||||
int best_checks = -1;
|
||||
for (cb_index = 0;cb_index<1.1; cb_index+=0.2) {
|
||||
for (cb_index = 0;cb_index<1.1f; cb_index+=0.2f) {
|
||||
kmeans->set_cb_index(cb_index);
|
||||
searchTime = test_index_precision(*kmeans, dataset, testDataset, gt_matches, index_params.target_precision, checks, nn, 1);
|
||||
if (searchTime<bestSearchTime || bestSearchTime == -1) {
|
||||
|
@@ -340,7 +340,7 @@ struct ZeroIterator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
T operator[](int index) {
|
||||
T operator[](int) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -47,20 +47,20 @@ void find_nearest(const Matrix<T>& dataset, T* query, int* matches, int nn, int
|
||||
long* match = new long[n];
|
||||
T* dists = new T[n];
|
||||
|
||||
dists[0] = flann_dist(query, query_end, dataset[0]);
|
||||
dists[0] = (float)flann_dist(query, query_end, dataset[0]);
|
||||
match[0] = 0;
|
||||
int dcnt = 1;
|
||||
|
||||
for (size_t i=1;i<dataset.rows;++i) {
|
||||
T tmp = flann_dist(query, query_end, dataset[i]);
|
||||
T tmp = (T)flann_dist(query, query_end, dataset[i]);
|
||||
|
||||
if (dcnt<n) {
|
||||
match[dcnt] = i;
|
||||
match[dcnt] = (long)i;
|
||||
dists[dcnt++] = tmp;
|
||||
}
|
||||
else if (tmp < dists[dcnt-1]) {
|
||||
dists[dcnt-1] = tmp;
|
||||
match[dcnt-1] = i;
|
||||
match[dcnt-1] = (long)i;
|
||||
}
|
||||
|
||||
int j = dcnt-1;
|
||||
@@ -85,7 +85,7 @@ template <typename T>
|
||||
void compute_ground_truth(const Matrix<T>& dataset, const Matrix<T>& testset, Matrix<int>& matches, int skip=0)
|
||||
{
|
||||
for (size_t i=0;i<testset.rows;++i) {
|
||||
find_nearest(dataset, testset[i], matches[i], matches.cols, skip);
|
||||
find_nearest(dataset, testset[i], matches[i], (int)matches.cols, skip);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -55,8 +55,8 @@ float computeDistanceRaport(const Matrix<ELEM_TYPE>& inputData, ELEM_TYPE* targe
|
||||
ELEM_TYPE* target_end = target + veclen;
|
||||
float ret = 0;
|
||||
for (int i=0;i<n;++i) {
|
||||
float den = flann_dist(target,target_end, inputData[groundTruth[i]]);
|
||||
float num = flann_dist(target,target_end, inputData[neighbors[i]]);
|
||||
float den = (float)flann_dist(target,target_end, inputData[groundTruth[i]]);
|
||||
float num = (float)flann_dist(target,target_end, inputData[neighbors[i]]);
|
||||
|
||||
if (den==0 && num==0) {
|
||||
ret += 1;
|
||||
@@ -81,8 +81,8 @@ float search_with_ground_truth(NNIndex<ELEM_TYPE>& index, const Matrix<ELEM_TYPE
|
||||
KNNResultSet<ELEM_TYPE> resultSet(nn+skipMatches);
|
||||
SearchParams searchParams(checks);
|
||||
|
||||
int correct;
|
||||
float distR;
|
||||
int correct = 0;
|
||||
float distR = 0;
|
||||
StartStopTimer t;
|
||||
int repeats = 0;
|
||||
while (t.value<0.2) {
|
||||
@@ -92,17 +92,17 @@ float search_with_ground_truth(NNIndex<ELEM_TYPE>& index, const Matrix<ELEM_TYPE
|
||||
distR = 0;
|
||||
for (size_t i = 0; i < testData.rows; i++) {
|
||||
ELEM_TYPE* target = testData[i];
|
||||
resultSet.init(target, testData.cols);
|
||||
resultSet.init(target, (int)testData.cols);
|
||||
index.findNeighbors(resultSet,target, searchParams);
|
||||
int* neighbors = resultSet.getNeighbors();
|
||||
neighbors = neighbors+skipMatches;
|
||||
|
||||
correct += countCorrectMatches(neighbors,matches[i], nn);
|
||||
distR += computeDistanceRaport(inputData, target,neighbors,matches[i], testData.cols, nn);
|
||||
distR += computeDistanceRaport(inputData, target,neighbors,matches[i], (int)testData.cols, nn);
|
||||
}
|
||||
t.stop();
|
||||
}
|
||||
time = t.value/repeats;
|
||||
time = (float)(t.value/repeats);
|
||||
|
||||
|
||||
float precicion = (float)correct/(nn*testData.rows);
|
||||
@@ -134,7 +134,7 @@ template <typename ELEM_TYPE>
|
||||
float test_index_precision(NNIndex<ELEM_TYPE>& index, const Matrix<ELEM_TYPE>& inputData, const Matrix<ELEM_TYPE>& testData, const Matrix<int>& matches,
|
||||
float precision, int& checks, int nn = 1, int skipMatches = 0)
|
||||
{
|
||||
const float SEARCH_EPS = 0.001;
|
||||
const float SEARCH_EPS = 0.001f;
|
||||
|
||||
logger().info(" Nodes Precision(%) Time(s) Time/vec(ms) Mean dist\n");
|
||||
logger().info("---------------------------------------------------------\n");
|
||||
|
@@ -201,7 +201,7 @@ public:
|
||||
// Create a permutable array of indices to the input vectors.
|
||||
vind = new int[size_];
|
||||
for (size_t i = 0; i < size_; i++) {
|
||||
vind[i] = i;
|
||||
vind[i] = (int)i;
|
||||
}
|
||||
|
||||
mean = new DIST_TYPE[veclen_];
|
||||
@@ -230,11 +230,11 @@ public:
|
||||
/* Construct the randomized trees. */
|
||||
for (int i = 0; i < numTrees; i++) {
|
||||
/* Randomize the order of vectors to allow for unbiased sampling. */
|
||||
for (int j = size_; j > 0; --j) {
|
||||
for (int j = (int)size_; j > 0; --j) {
|
||||
int rnd = rand_int(j);
|
||||
swap(vind[j-1], vind[rnd]);
|
||||
}
|
||||
trees[i] = divideTree(0, size_ - 1);
|
||||
trees[i] = divideTree(0, (int)size_ - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ public:
|
||||
*/
|
||||
int usedMemory() const
|
||||
{
|
||||
return pool.usedMemory+pool.wastedMemory+dataset.rows*sizeof(int); // pool memory and vind array memory
|
||||
return (int)(pool.usedMemory+pool.wastedMemory+dataset.rows*sizeof(int)); // pool memory and vind array memory
|
||||
}
|
||||
|
||||
|
||||
@@ -424,10 +424,10 @@ private:
|
||||
if (num < RAND_DIM || v[i] > v[topind[num-1]]) {
|
||||
/* Put this element at end of topind. */
|
||||
if (num < RAND_DIM) {
|
||||
topind[num++] = i; /* Add to list. */
|
||||
topind[num++] = (int)i; /* Add to list. */
|
||||
}
|
||||
else {
|
||||
topind[num-1] = i; /* Replace last element. */
|
||||
topind[num-1] = (int)i; /* Replace last element. */
|
||||
}
|
||||
/* Bubble end value down to right location by repeated swapping. */
|
||||
int j = num - 1;
|
||||
@@ -505,7 +505,7 @@ private:
|
||||
BranchSt branch;
|
||||
|
||||
int checkCount = 0;
|
||||
Heap<BranchSt>* heap = new Heap<BranchSt>(size_);
|
||||
Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
|
||||
vector<bool> checked(size_,false);
|
||||
|
||||
/* Search once through each tree down to root. */
|
||||
@@ -568,7 +568,7 @@ private:
|
||||
adding exceeds their value.
|
||||
*/
|
||||
|
||||
DIST_TYPE new_distsq = flann_dist(&val, &val+1, &node->divval, mindistsq);
|
||||
DIST_TYPE new_distsq = (DIST_TYPE)flann_dist(&val, &val+1, &node->divval, mindistsq);
|
||||
// if (2 * checkCount < maxCheck || !result.full()) {
|
||||
if (new_distsq < result.worstDist() || !result.full()) {
|
||||
heap->insert( BranchSt::make_branch(otherChild, new_distsq) );
|
||||
@@ -611,7 +611,7 @@ private:
|
||||
|
||||
/* Call recursively to search next level down. */
|
||||
searchLevelExact(result, vec, bestChild, mindistsq);
|
||||
DIST_TYPE new_distsq = flann_dist(&val, &val+1, &node->divval, mindistsq);
|
||||
DIST_TYPE new_distsq = (DIST_TYPE)flann_dist(&val, &val+1, &node->divval, mindistsq);
|
||||
searchLevelExact(result, vec, otherChild, new_distsq);
|
||||
}
|
||||
|
||||
|
@@ -238,7 +238,7 @@ class KMeansIndex : public NNIndex<ELEM_TYPE>
|
||||
centers[index] = indices[rnd];
|
||||
|
||||
for (int j=0;j<index;++j) {
|
||||
float sq = flann_dist(dataset[centers[index]],dataset[centers[index]]+dataset.cols,dataset[centers[j]]);
|
||||
float sq = (float)flann_dist(dataset[centers[index]],dataset[centers[index]]+dataset.cols,dataset[centers[j]]);
|
||||
if (sq<1e-16) {
|
||||
duplicate = true;
|
||||
}
|
||||
@@ -275,9 +275,9 @@ class KMeansIndex : public NNIndex<ELEM_TYPE>
|
||||
int best_index = -1;
|
||||
float best_val = 0;
|
||||
for (int j=0;j<n;++j) {
|
||||
float dist = flann_dist(dataset[centers[0]],dataset[centers[0]]+dataset.cols,dataset[indices[j]]);
|
||||
float dist = (float)flann_dist(dataset[centers[0]],dataset[centers[0]]+dataset.cols,dataset[indices[j]]);
|
||||
for (int i=1;i<index;++i) {
|
||||
float tmp_dist = flann_dist(dataset[centers[i]],dataset[centers[i]]+dataset.cols,dataset[indices[j]]);
|
||||
float tmp_dist = (float)flann_dist(dataset[centers[i]],dataset[centers[i]]+dataset.cols,dataset[indices[j]]);
|
||||
if (tmp_dist<dist) {
|
||||
dist = tmp_dist;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ class KMeansIndex : public NNIndex<ELEM_TYPE>
|
||||
|
||||
// Repeat several trials
|
||||
double bestNewPot = -1;
|
||||
int bestNewIndex;
|
||||
int bestNewIndex = -1;
|
||||
for (int localTrial = 0; localTrial < numLocalTries; localTrial++) {
|
||||
|
||||
// Choose our center - have to be slightly careful to return a valid answer even accounting
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
else {
|
||||
throw FLANNException("Unknown algorithm for choosing initial centers.");
|
||||
}
|
||||
cb_index = 0.4;
|
||||
cb_index = 0.4f;
|
||||
|
||||
}
|
||||
|
||||
@@ -481,12 +481,12 @@ public:
|
||||
|
||||
indices = new int[size_];
|
||||
for (size_t i=0;i<size_;++i) {
|
||||
indices[i] = i;
|
||||
indices[i] = (int)i;
|
||||
}
|
||||
|
||||
root = pool.allocate<KMeansNodeSt>();
|
||||
computeNodeStatistics(root, indices, size_);
|
||||
computeClustering(root, indices, size_, branching,0);
|
||||
computeNodeStatistics(root, indices, (int)size_);
|
||||
computeClustering(root, indices, (int)size_, branching,0);
|
||||
}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ public:
|
||||
save_value(stream, max_iter);
|
||||
save_value(stream, memoryCounter);
|
||||
save_value(stream, cb_index);
|
||||
save_value(stream, *indices, size_);
|
||||
save_value(stream, *indices, (int)size_);
|
||||
|
||||
save_tree(stream, root);
|
||||
}
|
||||
@@ -512,7 +512,7 @@ public:
|
||||
delete[] indices;
|
||||
}
|
||||
indices = new int[size_];
|
||||
load_value(stream, *indices, size_);
|
||||
load_value(stream, *indices, (int)size_);
|
||||
|
||||
if (root!=NULL) {
|
||||
free_centers(root);
|
||||
@@ -540,7 +540,7 @@ public:
|
||||
}
|
||||
else {
|
||||
// Priority queue storing intermediate branches in the best-bin-first search
|
||||
Heap<BranchSt>* heap = new Heap<BranchSt>(size_);
|
||||
Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
|
||||
|
||||
int checks = 0;
|
||||
|
||||
@@ -604,9 +604,9 @@ private:
|
||||
void save_tree(FILE* stream, KMeansNode node)
|
||||
{
|
||||
save_value(stream, *node);
|
||||
save_value(stream, *(node->pivot), veclen_);
|
||||
save_value(stream, *(node->pivot), (int)veclen_);
|
||||
if (node->childs==NULL) {
|
||||
int indices_offset = node->indices - indices;
|
||||
int indices_offset = (int)(node->indices - indices);
|
||||
save_value(stream, indices_offset);
|
||||
}
|
||||
else {
|
||||
@@ -622,7 +622,7 @@ private:
|
||||
node = pool.allocate<KMeansNodeSt>();
|
||||
load_value(stream, *node);
|
||||
node->pivot = new DIST_TYPE[veclen_];
|
||||
load_value(stream, *(node->pivot), veclen_);
|
||||
load_value(stream, *(node->pivot), (int)veclen_);
|
||||
if (node->childs==NULL) {
|
||||
int indices_offset;
|
||||
load_value(stream, indices_offset);
|
||||
@@ -659,10 +659,10 @@ private:
|
||||
*/
|
||||
void computeNodeStatistics(KMeansNode node, int* indices, int indices_length) {
|
||||
|
||||
DIST_TYPE radius = 0;
|
||||
DIST_TYPE variance = 0;
|
||||
double radius = 0;
|
||||
double variance = 0;
|
||||
DIST_TYPE* mean = new DIST_TYPE[veclen_];
|
||||
memoryCounter += veclen_*sizeof(DIST_TYPE);
|
||||
memoryCounter += (int)(veclen_*sizeof(DIST_TYPE));
|
||||
|
||||
memset(mean,0,veclen_*sizeof(float));
|
||||
|
||||
@@ -679,7 +679,7 @@ private:
|
||||
variance /= size_;
|
||||
variance -= flann_dist(mean,mean+veclen_,zero());
|
||||
|
||||
DIST_TYPE tmp = 0;
|
||||
double tmp = 0;
|
||||
for (int i=0;i<indices_length;++i) {
|
||||
tmp = flann_dist(mean, mean + veclen_, dataset[indices[i]]);
|
||||
if (tmp>radius) {
|
||||
@@ -687,8 +687,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
node->variance = variance;
|
||||
node->radius = radius;
|
||||
node->variance = (DIST_TYPE)variance;
|
||||
node->radius = (DIST_TYPE)radius;
|
||||
node->pivot = mean;
|
||||
}
|
||||
|
||||
@@ -728,7 +728,7 @@ private:
|
||||
}
|
||||
|
||||
|
||||
Matrix<double> dcenters(new double[branching*veclen_],branching,veclen_);
|
||||
Matrix<double> dcenters(new double[branching*veclen_],branching,(long)veclen_);
|
||||
for (int i=0; i<centers_length; ++i) {
|
||||
ELEM_TYPE* vec = dataset[centers_idx[i]];
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
@@ -748,17 +748,17 @@ private:
|
||||
int* belongs_to = new int[indices_length];
|
||||
for (int i=0;i<indices_length;++i) {
|
||||
|
||||
float sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]] + veclen_ ,dcenters[0]);
|
||||
double sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]] + veclen_ ,dcenters[0]);
|
||||
belongs_to[i] = 0;
|
||||
for (int j=1;j<branching;++j) {
|
||||
float new_sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_, dcenters[j]);
|
||||
double new_sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_, dcenters[j]);
|
||||
if (sq_dist>new_sq_dist) {
|
||||
belongs_to[i] = j;
|
||||
sq_dist = new_sq_dist;
|
||||
}
|
||||
}
|
||||
if (sq_dist>radiuses[belongs_to[i]]) {
|
||||
radiuses[belongs_to[i]] = sq_dist;
|
||||
radiuses[belongs_to[i]] = (float)sq_dist;
|
||||
}
|
||||
count[belongs_to[i]]++;
|
||||
}
|
||||
@@ -790,10 +790,10 @@ private:
|
||||
|
||||
// reassign points to clusters
|
||||
for (int i=0;i<indices_length;++i) {
|
||||
float sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_ ,dcenters[0]);
|
||||
float sq_dist = (float)flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_ ,dcenters[0]);
|
||||
int new_centroid = 0;
|
||||
for (int j=1;j<branching;++j) {
|
||||
float new_sq_dist = flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_,dcenters[j]);
|
||||
float new_sq_dist = (float)flann_dist(dataset[indices[i]], dataset[indices[i]]+veclen_,dcenters[j]);
|
||||
if (sq_dist>new_sq_dist) {
|
||||
new_centroid = j;
|
||||
sq_dist = new_sq_dist;
|
||||
@@ -838,9 +838,9 @@ private:
|
||||
|
||||
for (int i=0; i<branching; ++i) {
|
||||
centers[i] = new DIST_TYPE[veclen_];
|
||||
memoryCounter += veclen_*sizeof(DIST_TYPE);
|
||||
memoryCounter += (int)(veclen_*sizeof(DIST_TYPE));
|
||||
for (size_t k=0; k<veclen_; ++k) {
|
||||
centers[i][k] = dcenters[i][k];
|
||||
centers[i][k] = (DIST_TYPE)dcenters[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,11 +852,11 @@ private:
|
||||
for (int c=0;c<branching;++c) {
|
||||
int s = count[c];
|
||||
|
||||
float variance = 0;
|
||||
float mean_radius =0;
|
||||
double variance = 0;
|
||||
double mean_radius =0;
|
||||
for (int i=0;i<indices_length;++i) {
|
||||
if (belongs_to[i]==c) {
|
||||
float d = flann_dist(dataset[indices[i]],dataset[indices[i]]+veclen_,zero());
|
||||
double d = flann_dist(dataset[indices[i]],dataset[indices[i]]+veclen_,zero());
|
||||
variance += d;
|
||||
mean_radius += sqrt(d);
|
||||
swap(indices[i],indices[end]);
|
||||
@@ -871,8 +871,8 @@ private:
|
||||
node->childs[c] = pool.allocate<KMeansNodeSt>();
|
||||
node->childs[c]->radius = radiuses[c];
|
||||
node->childs[c]->pivot = centers[c];
|
||||
node->childs[c]->variance = variance;
|
||||
node->childs[c]->mean_radius = mean_radius;
|
||||
node->childs[c]->variance = (float)variance;
|
||||
node->childs[c]->mean_radius = (float)mean_radius;
|
||||
node->childs[c]->indices = NULL;
|
||||
computeClustering(node->childs[c],indices+start, end-start, branching, level+1);
|
||||
start=end;
|
||||
@@ -905,7 +905,7 @@ private:
|
||||
{
|
||||
// Ignore those clusters that are too far away
|
||||
{
|
||||
DIST_TYPE bsq = flann_dist(vec, vec+veclen_, node->pivot);
|
||||
DIST_TYPE bsq = (DIST_TYPE)flann_dist(vec, vec+veclen_, node->pivot);
|
||||
DIST_TYPE rsq = node->radius;
|
||||
DIST_TYPE wsq = result.worstDist();
|
||||
|
||||
@@ -947,9 +947,9 @@ private:
|
||||
{
|
||||
|
||||
int best_index = 0;
|
||||
domain_distances[best_index] = flann_dist(q,q+veclen_,node->childs[best_index]->pivot);
|
||||
domain_distances[best_index] = (float)flann_dist(q,q+veclen_,node->childs[best_index]->pivot);
|
||||
for (int i=1;i<branching;++i) {
|
||||
domain_distances[i] = flann_dist(q,q+veclen_,node->childs[i]->pivot);
|
||||
domain_distances[i] = (float)flann_dist(q,q+veclen_,node->childs[i]->pivot);
|
||||
if (domain_distances[i]<domain_distances[best_index]) {
|
||||
best_index = i;
|
||||
}
|
||||
@@ -979,7 +979,7 @@ private:
|
||||
{
|
||||
// Ignore those clusters that are too far away
|
||||
{
|
||||
float bsq = flann_dist(vec, vec+veclen_, node->pivot);
|
||||
float bsq = (float)flann_dist(vec, vec+veclen_, node->pivot);
|
||||
float rsq = node->radius;
|
||||
float wsq = result.worstDist();
|
||||
|
||||
@@ -1021,7 +1021,7 @@ private:
|
||||
{
|
||||
float* domain_distances = new float[branching];
|
||||
for (int i=0;i<branching;++i) {
|
||||
float dist = flann_dist(q, q+veclen_, node->childs[i]->pivot);
|
||||
float dist = (float)flann_dist(q, q+veclen_, node->childs[i]->pivot);
|
||||
|
||||
int j=0;
|
||||
while (domain_distances[j]<dist && j<i) j++;
|
||||
|
@@ -90,21 +90,21 @@ public:
|
||||
/* nothing to do here for linear search */
|
||||
}
|
||||
|
||||
void saveIndex(FILE* stream)
|
||||
void saveIndex(FILE*)
|
||||
{
|
||||
/* nothing to do here for linear search */
|
||||
}
|
||||
|
||||
|
||||
void loadIndex(FILE* stream)
|
||||
void loadIndex(FILE*)
|
||||
{
|
||||
/* nothing to do here for linear search */
|
||||
}
|
||||
|
||||
void findNeighbors(ResultSet<ELEM_TYPE>& resultSet, const ELEM_TYPE* vec, const SearchParams& searchParams)
|
||||
void findNeighbors(ResultSet<ELEM_TYPE>& resultSet, const ELEM_TYPE*, const SearchParams&)
|
||||
{
|
||||
for (size_t i=0;i<dataset.rows;++i) {
|
||||
resultSet.addPoint(dataset[i],i);
|
||||
resultSet.addPoint(dataset[i],(int)i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -299,7 +299,7 @@ public:
|
||||
{
|
||||
Item it;
|
||||
it.index = index;
|
||||
it.dist = flann_dist(target, target_end, point);
|
||||
it.dist = (float)flann_dist(target, target_end, point);
|
||||
if (it.dist<=radius) {
|
||||
items.push_back(it);
|
||||
push_heap(items.begin(), items.end());
|
||||
|
@@ -41,8 +41,8 @@ namespace cvflann
|
||||
template<typename T>
|
||||
Matrix<T> random_sample(Matrix<T>& srcMatrix, long size, bool remove = false)
|
||||
{
|
||||
UniqueRandom rand(srcMatrix.rows);
|
||||
Matrix<T> newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols);
|
||||
UniqueRandom rand((int)srcMatrix.rows);
|
||||
Matrix<T> newSet(new T[size * srcMatrix.cols], size, (long)srcMatrix.cols);
|
||||
|
||||
T *src,*dest;
|
||||
for (long i=0;i<size;++i) {
|
||||
@@ -73,8 +73,8 @@ Matrix<T> random_sample(Matrix<T>& srcMatrix, long size, bool remove = false)
|
||||
template<typename T>
|
||||
Matrix<T> random_sample(const Matrix<T>& srcMatrix, size_t size)
|
||||
{
|
||||
UniqueRandom rand(srcMatrix.rows);
|
||||
Matrix<T> newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols);
|
||||
UniqueRandom rand((int)srcMatrix.rows);
|
||||
Matrix<T> newSet(new T[size * srcMatrix.cols], (long)size, (long)srcMatrix.cols);
|
||||
|
||||
T *src,*dest;
|
||||
for (size_t i=0;i<size;++i) {
|
||||
|
@@ -104,7 +104,7 @@ void save_value(FILE* stream, const T& value, int count = 1)
|
||||
template<typename T>
|
||||
void load_value(FILE* stream, T& value, int count = 1)
|
||||
{
|
||||
int read_cnt = fread(&value, sizeof(value),count, stream);
|
||||
int read_cnt = (int)fread(&value, sizeof(value),count, stream);
|
||||
if (read_cnt!=count) {
|
||||
throw FLANNException("Cannot read from file");
|
||||
}
|
||||
|
Reference in New Issue
Block a user