[mlpack-git] master: Fix furthest neighbor sort policy. (41878d2)
gitdub at mlpack.org
gitdub at mlpack.org
Fri Aug 19 11:12:51 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/31fe55d4c7d7cd6516b5d6c7d98ed93c5f0347fa...20f4eacd1b082d04d9aab1fc2f61ef3edaac3f33
>---------------------------------------------------------------
commit 41878d2171595c3acd682bad35cf4c105165d16d
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Fri Aug 19 12:12:51 2016 -0300
Fix furthest neighbor sort policy.
>---------------------------------------------------------------
41878d2171595c3acd682bad35cf4c105165d16d
.../neighbor_search/sort_policies/furthest_neighbor_sort.hpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort.hpp b/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort.hpp
index 943bcc5..bb1cf11 100644
--- a/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort.hpp
+++ b/src/mlpack/methods/neighbor_search/sort_policies/furthest_neighbor_sort.hpp
@@ -152,7 +152,12 @@ class FurthestNeighborSort
*/
static inline double ConvertToScore(const double distance)
{
- return DBL_MAX - distance;
+ if (distance == DBL_MAX)
+ return 0.0;
+ else if (distance == 0.0)
+ return DBL_MAX;
+ else
+ return (1.0 / distance);
}
/**
@@ -162,7 +167,7 @@ class FurthestNeighborSort
*/
static inline double ConvertToDistance(const double score)
{
- return DBL_MAX - score;
+ return ConvertToScore(score);
}
};
More information about the mlpack-git
mailing list