[mlpack-git] master: Add a new method GetBestChild() to SortPolicies. (5c338ee)
gitdub at mlpack.org
gitdub at mlpack.org
Sat Aug 20 14:56:07 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/3274b05fcc545c3b36f783316fea2e22f79c3d03...1c77230c7d3b9c45fb102cd3c632d9c7248e085e
>---------------------------------------------------------------
commit 5c338ee54844cecd7ad1f0d8f9d88aeeee1164c4
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Tue Aug 16 02:01:43 2016 -0300
Add a new method GetBestChild() to SortPolicies.
>---------------------------------------------------------------
5c338ee54844cecd7ad1f0d8f9d88aeeee1164c4
src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp | 4 ++--
.../core/tree/binary_space_tree/binary_space_tree_impl.hpp | 4 ++--
src/mlpack/core/tree/cover_tree/cover_tree.hpp | 4 ++--
src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp | 4 ++--
src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp | 4 ++--
src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp | 4 ++--
.../neighbor_search/sort_policies/furthest_neighbor_sort.hpp | 11 +++++++++++
.../neighbor_search/sort_policies/nearest_neighbor_sort.hpp | 12 ++++++++++++
8 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
index d7aceca..3be4fe1 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
@@ -339,7 +339,7 @@ class BinarySpaceTree
template<typename VecType>
BinarySpaceTree& GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
/**
* Return the furthest child node to the given query point. If this is a leaf
@@ -348,7 +348,7 @@ class BinarySpaceTree
template<typename VecType>
BinarySpaceTree& GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
/**
* Return the furthest distance to a point held in this node. If this is not
diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
index 825d6c0..e1f77a8 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
@@ -499,7 +499,7 @@ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
@@ -523,7 +523,7 @@ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
diff --git a/src/mlpack/core/tree/cover_tree/cover_tree.hpp b/src/mlpack/core/tree/cover_tree/cover_tree.hpp
index 736d432..75fab6a 100644
--- a/src/mlpack/core/tree/cover_tree/cover_tree.hpp
+++ b/src/mlpack/core/tree/cover_tree/cover_tree.hpp
@@ -301,7 +301,7 @@ class CoverTree
template<typename VecType>
CoverTree& GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
/**
* Return the furthest child node to the given query point. If this is a leaf
@@ -310,7 +310,7 @@ class CoverTree
template<typename VecType>
CoverTree& GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
//! Return the minimum distance to another node.
ElemType MinDistance(const CoverTree* other) const;
diff --git a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
index 36ee310..c39263a 100644
--- a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
+++ b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
@@ -618,7 +618,7 @@ template<typename VecType>
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>&
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
@@ -650,7 +650,7 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>&
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::
GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index b00b572..2e2c053 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -349,7 +349,7 @@ class RectangleTree
template<typename VecType>
RectangleTree& GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
/**
* Return the furthest child node to the given query point. If this is a leaf
@@ -358,7 +358,7 @@ class RectangleTree
template<typename VecType>
RectangleTree& GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type* = 0) const;
+ typename boost::enable_if<IsVector<VecType> >::type* = 0);
/**
* Return the furthest distance to a point held in this node. If this is not
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index 6d408d0..257bc18 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -579,7 +579,7 @@ RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
AuxiliaryInformationType>::GetNearestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
@@ -614,7 +614,7 @@ RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
AuxiliaryInformationType>::GetFurthestChild(
const VecType& point,
- typename boost::enable_if<IsVector<VecType> >::type*) const
+ typename boost::enable_if<IsVector<VecType> >::type*)
{
if (IsLeaf())
return *this;
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 bb1cf11..2c55a75 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
@@ -95,6 +95,17 @@ class FurthestNeighborSort
const double pointToCenterDistance);
/**
+ * Return the best child according to this sort policy. In this case it will
+ * return the one with the maximum distance.
+ */
+ template<typename VecType, typename TreeType>
+ static TreeType& GetBestChild(const VecType& queryPoint,
+ TreeType& referenceNode)
+ {
+ return referenceNode.GetFurthestChild(queryPoint);
+ };
+
+ /**
* Return what should represent the worst possible distance with this
* particular sort policy. In our case, this should be the minimum possible
* distance, 0.
diff --git a/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp b/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp
index a36fca2..90837ce 100644
--- a/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp
+++ b/src/mlpack/methods/neighbor_search/sort_policies/nearest_neighbor_sort.hpp
@@ -77,6 +77,7 @@ class NearestNeighborSort
const TreeType* referenceNode,
const TreeType* referenceChildNode,
const double centerToCenterDistance);
+
/**
* Return the best possible distance between a node and a point. In our case,
* this is the minimum distance between the tree node and the point using the
@@ -98,6 +99,17 @@ class NearestNeighborSort
const double pointToCenterDistance);
/**
+ * Return the best child according to this sort policy. In this case it will
+ * return the one with the minimum distance.
+ */
+ template<typename VecType, typename TreeType>
+ static TreeType& GetBestChild(const VecType& queryPoint,
+ TreeType& referenceNode)
+ {
+ return referenceNode.GetNearestChild(queryPoint);
+ };
+
+ /**
* Return what should represent the worst possible distance with this
* particular sort policy. In our case, this should be the maximum possible
* distance, DBL_MAX.
More information about the mlpack-git
mailing list