mlpack
furthest_neighbor_sort_impl.hpp
1 /***
2  * @file methods/neighbor_search/sort_policies/furthest_neighbor_sort_impl.hpp
3  * @author Ryan Curtin
4  *
5  * Implementation of templated methods for the FurthestNeighborSort SortPolicy
6  * class for the NeighborSearch class.
7  *
8  * mlpack is free software; you may redistribute it and/or modify it under the
9  * terms of the 3-clause BSD license. You should have received a copy of the
10  * 3-clause BSD license along with mlpack. If not, see
11  * http://www.opensource.org/licenses/BSD-3-Clause for more information.
12  */
13 #ifndef MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_IMPL_HPP
14 #define MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_IMPL_HPP
15 
16 namespace mlpack {
17 namespace neighbor {
18 
19 template<typename TreeType>
21  const TreeType* queryNode,
22  const TreeType* referenceNode)
23 {
24  // This is not implemented yet for the general case because the trees do not
25  // accept arbitrary distance metrics.
26  return queryNode->MaxDistance(*referenceNode);
27 }
28 
29 template<typename TreeType>
31  const TreeType* queryNode,
32  const TreeType* referenceNode,
33  const double centerToCenterDistance)
34 {
35  return queryNode->MaxDistance(*referenceNode, centerToCenterDistance);
36 }
37 
38 template<typename TreeType>
40  const TreeType* queryNode,
41  const TreeType* referenceNode,
42  const TreeType* referenceChildNode,
43  const double centerToCenterDistance)
44 {
45  return queryNode->MaxDistance(*referenceNode, centerToCenterDistance) +
46  referenceChildNode->ParentDistance();
47 }
48 
49 template<typename VecType, typename TreeType>
51  const VecType& point,
52  const TreeType* referenceNode)
53 {
54  // This is not implemented yet for the general case because the trees do not
55  // accept arbitrary distance metrics.
56  return referenceNode->MaxDistance(point);
57 }
58 
59 template<typename VecType, typename TreeType>
61  const VecType& point,
62  const TreeType* referenceNode,
63  const double pointToCenterDistance)
64 {
65  return referenceNode->MaxDistance(point, pointToCenterDistance);
66 }
67 
68 } // namespace neighbor
69 } // namespace mlpack
70 
71 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static double BestPointToNodeDistance(const VecType &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.
Definition: furthest_neighbor_sort_impl.hpp:50
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
Definition: furthest_neighbor_sort_impl.hpp:20