14 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 15 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 25 template<
typename MetricType,
26 typename StatisticType,
28 template<
typename BoundMetricType,
typename...>
class BoundType,
29 template<
typename SplitBoundType,
typename SplitMatType>
31 template<
typename RuleType>
38 template<
typename MetricType,
39 typename StatisticType,
41 template<
typename BoundMetricType,
typename...>
class BoundType,
42 template<
typename SplitBoundType,
typename SplitMatType>
44 template<
typename RuleType>
47 const size_t queryIndex,
52 if (referenceNode.
IsLeaf())
54 const size_t refEnd = referenceNode.
Begin() + referenceNode.
Count();
55 for (
size_t i = referenceNode.
Begin(); i < refEnd; ++i)
56 rule.BaseCase(queryIndex, i);
61 if (referenceNode.
Parent() == NULL)
63 const double rootScore = rule.Score(queryIndex, referenceNode);
65 if (rootScore == DBL_MAX)
73 double leftScore = rule.Score(queryIndex, *referenceNode.
Left());
74 double rightScore = rule.Score(queryIndex, *referenceNode.
Right());
76 if (leftScore < rightScore)
82 rightScore = rule.Rescore(queryIndex, *referenceNode.
Right(), rightScore);
84 if (rightScore != DBL_MAX)
89 else if (rightScore < leftScore)
95 leftScore = rule.Rescore(queryIndex, *referenceNode.
Left(), leftScore);
97 if (leftScore != DBL_MAX)
104 if (leftScore == DBL_MAX)
114 rightScore = rule.Rescore(queryIndex, *referenceNode.
Right(),
117 if (rightScore != DBL_MAX)
BinarySpaceTree * Parent() const
Gets the parent of this node.
Definition: binary_space_tree.hpp:342
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
size_t Count() const
Return the number of points in this subset.
Definition: binary_space_tree.hpp:503
BinarySpaceTree * Right() const
Gets the right child of this node.
Definition: binary_space_tree.hpp:337
A binary space partitioning tree, such as a KD-tree or a ball tree.
Definition: binary_space_tree.hpp:54
BinarySpaceTree * Left() const
Gets the left child of this node.
Definition: binary_space_tree.hpp:332
bool IsLeaf() const
Return whether or not this node is a leaf (true if it has no children).
Definition: binary_space_tree_impl.hpp:594
size_t Begin() const
Return the index of the beginning point of this subset.
Definition: binary_space_tree.hpp:498
void Traverse(const size_t queryIndex, BinarySpaceTree &referenceNode)
Traverse the tree with the given point.
Definition: single_tree_traverser_impl.hpp:46
SingleTreeTraverser(RuleType &rule)
Instantiate the single tree traverser with the given rule set.
Definition: single_tree_traverser_impl.hpp:33