14 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 15 #define MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 25 template<
typename MetricType,
26 typename StatisticType,
30 template<
typename>
class AuxiliaryInformationType>
31 template<
typename RuleType>
32 RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
33 AuxiliaryInformationType>::
34 SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
39 template<
typename MetricType,
40 typename StatisticType,
44 template<
typename>
class AuxiliaryInformationType>
45 template<
typename RuleType>
47 AuxiliaryInformationType>
:: 49 const size_t queryIndex,
53 if (referenceNode.
IsLeaf())
55 for (
size_t i = 0; i < referenceNode.
Count(); ++i)
56 rule.BaseCase(queryIndex, referenceNode.
Point(i));
63 std::vector<NodeAndScore> nodesAndScores(referenceNode.
NumChildren());
64 for (
size_t i = 0; i < referenceNode.
NumChildren(); ++i)
66 nodesAndScores[i].node = &(referenceNode.
Child(i));
67 nodesAndScores[i].score = rule.Score(queryIndex, *nodesAndScores[i].node);
70 std::sort(nodesAndScores.begin(), nodesAndScores.end(), NodeComparator);
74 for (
size_t i = 0; i < referenceNode.
NumChildren(); ++i)
76 if (rule.Rescore(queryIndex, *nodesAndScores[i].node,
77 nodesAndScores[i].score) != DBL_MAX)
79 Traverse(queryIndex, *nodesAndScores[i].node);
size_t Point(const size_t index) const
Return the index (with reference to the dataset) of a particular point in this node.
Definition: rectangle_tree.hpp:480
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Traverse(const size_t queryIndex, const RectangleTree &referenceNode)
Traverse the tree with the given point.
Definition: single_tree_traverser_impl.hpp:48
friend DescentType
Give friend access for DescentType.
Definition: rectangle_tree.hpp:580
size_t NumChildren() const
Return the number of child nodes. (One level beneath this one only.)
Definition: rectangle_tree.hpp:371
friend SplitType
Give friend access for SplitType.
Definition: rectangle_tree.hpp:583
A rectangle type tree tree, such as an R-tree or X-tree.
Definition: rectangle_tree.hpp:54
A single traverser for rectangle type trees.
Definition: rectangle_tree.hpp:112
bool IsLeaf() const
Return whether or not this node is a leaf (true if it has no children).
Definition: rectangle_tree_impl.hpp:760
RectangleTree & Child(const size_t child) const
Get the specified child.
Definition: rectangle_tree.hpp:437
size_t Count() const
Return the number of points in this subset.
Definition: rectangle_tree.hpp:548