mlpack
nearest_neighbor_sort_impl.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_NEIGHBOR_NEAREST_NEIGHBOR_SORT_IMPL_HPP
14 #define MLPACK_NEIGHBOR_NEAREST_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->MinDistance(*referenceNode);
27 }
28 
29 template<typename TreeType>
31  const TreeType* queryNode,
32  const TreeType* referenceNode,
33  const double centerToCenterDistance)
34 {
35  return queryNode->MinDistance(*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->MinDistance(*referenceChildNode, 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->MinDistance(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->MinDistance(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: nearest_neighbor_sort_impl.hpp:50
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
Definition: nearest_neighbor_sort_impl.hpp:20