12 #ifndef MLPACK_CORE_TREE_OCTREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 13 #define MLPACK_CORE_TREE_OCTREE_SINGLE_TREE_TRAVERSER_IMPL_HPP 21 template<
typename MetricType,
typename StatisticType,
typename MatType>
22 template<
typename RuleType>
23 Octree<MetricType, StatisticType, MatType>::SingleTreeTraverser<RuleType>::
24 SingleTreeTraverser(RuleType& rule) :
31 template<
typename MetricType,
typename StatisticType,
typename MatType>
32 template<
typename RuleType>
39 const size_t refBegin = referenceNode.
Point(0);
40 const size_t refEnd = refBegin + referenceNode.
NumPoints();
41 for (
size_t r = refBegin; r < refEnd; ++r)
42 rule.BaseCase(queryIndex, r);
47 if (referenceNode.
Parent() == NULL)
49 const double rootScore = rule.Score(queryIndex, referenceNode);
51 if (rootScore == DBL_MAX)
61 for (
size_t i = 0; i < scores.n_elem; ++i)
62 scores[i] = rule.Score(queryIndex, referenceNode.
Child(i));
65 arma::uvec sortedIndices = arma::sort_index(scores);
67 for (
size_t i = 0; i < sortedIndices.n_elem; ++i)
71 if (scores[sortedIndices[i]] == DBL_MAX)
73 numPrunes += (sortedIndices.n_elem - i);
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
size_t NumPoints() const
Return the number of points in this node (0 if not a leaf).
Definition: octree_impl.hpp:627
size_t NumChildren() const
Return the number of children in this node.
Definition: octree_impl.hpp:509
void Traverse(const size_t queryIndex, Octree &referenceNode)
Traverse the reference tree with the given query point.
Definition: single_tree_traverser_impl.hpp:34
size_t Point(const size_t index) const
Return the index (with reference to the dataset) of a particular point in this node.
Definition: octree_impl.hpp:647
const Octree & Child(const size_t child) const
Return the specified child.
Definition: octree.hpp:340
Definition: octree.hpp:25
Octree * Parent() const
Get the pointer to the parent.
Definition: octree.hpp:256