dual_tree_traverser.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_DUAL_TREE_TRAVERSER_HPP
15 #define MLPACK_CORE_TREE_RECTANGLE_TREE_DUAL_TREE_TRAVERSER_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 #include "rectangle_tree.hpp"
20 
21 namespace mlpack {
22 namespace tree {
23 
24 template<typename MetricType,
25  typename StatisticType,
26  typename MatType,
27  typename SplitType,
28  typename DescentType,
29  template<typename> class AuxiliaryInformationType>
30 template<typename RuleType>
31 class RectangleTree<MetricType, StatisticType, MatType, SplitType,
32  DescentType, AuxiliaryInformationType>::DualTreeTraverser
33 {
34  public:
38  DualTreeTraverser(RuleType& rule);
39 
46  void Traverse(RectangleTree& queryNode, RectangleTree& referenceNode);
47 
49  size_t NumPrunes() const { return numPrunes; }
51  size_t& NumPrunes() { return numPrunes; }
52 
54  size_t NumVisited() const { return numVisited; }
56  size_t& NumVisited() { return numVisited; }
57 
59  size_t NumScores() const { return numScores; }
61  size_t& NumScores() { return numScores; }
62 
64  size_t NumBaseCases() const { return numBaseCases; }
66  size_t& NumBaseCases() { return numBaseCases; }
67 
68  private:
69  // We use this struct and this function to make the sorting and scoring easy
70  // and efficient:
71  struct NodeAndScore
72  {
73  RectangleTree* node;
74  double score;
75  typename RuleType::TraversalInfoType travInfo;
76  };
77 
78  static bool nodeComparator(const NodeAndScore& obj1,
79  const NodeAndScore& obj2)
80  {
81  return obj1.score < obj2.score;
82  }
83 
85  RuleType& rule;
86 
88  size_t numPrunes;
89 
91  size_t numVisited;
92 
94  size_t numScores;
95 
97  size_t numBaseCases;
98 
101  typename RuleType::TraversalInfoType traversalInfo;
102 };
103 
104 } // namespace tree
105 } // namespace mlpack
106 
107 // Include implementation.
108 #include "dual_tree_traverser_impl.hpp"
109 
110 #endif
size_t NumPrunes() const
Get the number of prunes.
Linear algebra utility functions, generally performed on matrices or vectors.
size_t & NumPrunes()
Modify the number of prunes.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t & NumVisited()
Modify the number of visited combinations.
size_t NumBaseCases() const
Get the number of times a base case was calculated.
size_t NumVisited() const
Get the number of visited combinations.
A rectangle type tree tree, such as an R-tree or X-tree.
size_t & NumScores()
Modify the number of times a node combination was scored.
A dual tree traverser for rectangle type trees.
size_t & NumBaseCases()
Modify the number of times a base case was calculated.
size_t NumScores() const
Get the number of times a node combination was scored.