Merge pull request #17642 from pemmanuelviel:pev--fixes-and-clean
* Clean: make the use of the indices array length consistent Either we don't want this method to be used in the future for any other node than the root node, and so we replace indices_length by size_ and remove it as argument, or we want to be able to use it potentially for other nodes, and so using size_ instead of indices_length would have lead to a bug. * Fix: b was not an address * Fix: transpose the Flann repo commit "Fixes in accum_dist methods" from Adil Ibragimov Avoids trying to compute log(ratio) with ratio = 0 * Fix: transpose the Flann repo commit "result_set bugfix" from Jack Rae * Fix Jack Rae commit as the initial i - 1 index was decremented before entering the loop body * Clean: transpose the Flann repo commit "Updated comments in lsh_index" from Richard McPherson * Fix: Transpose the Flann repo commit "Fixing unreachable code in lsh_table.h" from hypevr * Fix warning the same way it was done in flann standalone repo * Change the return value in case of unsupported type
This commit is contained in:
parent
e45d74c8f9
commit
daa88c6b9e
@ -708,7 +708,7 @@ struct KL_Divergence
|
|||||||
Iterator1 last = a + size;
|
Iterator1 last = a + size;
|
||||||
|
|
||||||
while (a < last) {
|
while (a < last) {
|
||||||
if (* b != 0) {
|
if ( *a != 0 && *b != 0 ) {
|
||||||
ResultType ratio = (ResultType)(*a / *b);
|
ResultType ratio = (ResultType)(*a / *b);
|
||||||
if (ratio>0) {
|
if (ratio>0) {
|
||||||
result += *a * log(ratio);
|
result += *a * log(ratio);
|
||||||
@ -731,7 +731,7 @@ struct KL_Divergence
|
|||||||
inline ResultType accum_dist(const U& a, const V& b, int) const
|
inline ResultType accum_dist(const U& a, const V& b, int) const
|
||||||
{
|
{
|
||||||
ResultType result = ResultType();
|
ResultType result = ResultType();
|
||||||
if( *b != 0 ) {
|
if( a != 0 && b != 0 ) {
|
||||||
ResultType ratio = (ResultType)(a / b);
|
ResultType ratio = (ResultType)(a / b);
|
||||||
if (ratio>0) {
|
if (ratio>0) {
|
||||||
result = a * log(ratio);
|
result = a * log(ratio);
|
||||||
|
|||||||
@ -650,7 +650,8 @@ private:
|
|||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* node = the node to use
|
* node = the node to use
|
||||||
* indices = the indices of the points belonging to the node
|
* indices = array of indices of the points belonging to the node
|
||||||
|
* indices_length = number of indices in the array
|
||||||
*/
|
*/
|
||||||
void computeNodeStatistics(KMeansNodePtr node, int* indices, int indices_length)
|
void computeNodeStatistics(KMeansNodePtr node, int* indices, int indices_length)
|
||||||
{
|
{
|
||||||
@ -662,7 +663,7 @@ private:
|
|||||||
|
|
||||||
memset(mean,0,veclen_*sizeof(DistanceType));
|
memset(mean,0,veclen_*sizeof(DistanceType));
|
||||||
|
|
||||||
for (size_t i=0; i<size_; ++i) {
|
for (size_t i=0; i<(size_t)indices_length; ++i) {
|
||||||
ElementType* vec = dataset_[indices[i]];
|
ElementType* vec = dataset_[indices[i]];
|
||||||
for (size_t j=0; j<veclen_; ++j) {
|
for (size_t j=0; j<veclen_; ++j) {
|
||||||
mean[j] += vec[j];
|
mean[j] += vec[j];
|
||||||
|
|||||||
@ -71,9 +71,9 @@ struct LshIndexParams : public IndexParams
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomized kd-tree index
|
* Locality-sensitive hashing index
|
||||||
*
|
*
|
||||||
* Contains the k-d trees and other information for indexing a set of points
|
* Contains the tables and other information for indexing a set of points
|
||||||
* for nearest-neighbor matching.
|
* for nearest-neighbor matching.
|
||||||
*/
|
*/
|
||||||
template<typename Distance>
|
template<typename Distance>
|
||||||
|
|||||||
@ -245,7 +245,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::cerr << "LSH is not implemented for that type" << std::endl;
|
std::cerr << "LSH is not implemented for that type" << std::endl;
|
||||||
assert(0);
|
assert(0);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get statistics about the table
|
/** Get statistics about the table
|
||||||
|
|||||||
@ -196,12 +196,10 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Check for duplicate indices
|
// Check for duplicate indices
|
||||||
int j = i - 1;
|
for (int j = i; dists[j] == dist && j--;) {
|
||||||
while ((j >= 0) && (dists[j] == dist)) {
|
|
||||||
if (indices[j] == index) {
|
if (indices[j] == index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--j;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user