mlpack  1.0.12
example_tree.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_CORE_TREE_EXAMPLE_TREE_HPP
17 #define __MLPACK_CORE_TREE_EXAMPLE_TREE_HPP
18 
19 namespace mlpack {
20 namespace tree {
21 
55 template<typename MetricType = metric::LMetric<2, true>,
56  typename StatisticType = EmptyStatistic,
57  typename MatType = arma::mat>
59 {
60  public:
81  ExampleTree(const MatType& dataset,
82  MetricType& metric);
83 
85  size_t NumChildren() const;
86 
88  const ExampleTree& Child(const size_t i) const;
90  ExampleTree& Child(const size_t i);
91 
93  ExampleTree* Parent() const;
94 
96  size_t NumPoints() const;
97 
108  size_t Point(const size_t i) const;
109 
117  size_t NumDescendants() const;
118 
125  size_t Descendant(const size_t i) const;
126 
128  const StatisticType& Stat() const;
130  StatisticType& Stat();
131 
133  const MetricType& Metric() const;
135  MetricType& Metric();
136 
145  double MinDistance(const MatType& point) const;
146 
155  double MinDistance(const ExampleTree& other) const;
156 
165  double MaxDistance(const MatType& point) const;
166 
175  double MaxDistance(const ExampleTree& other) const;
176 
188  math::Range RangeDistance(const MatType& point) const;
189 
201  math::Range RangeDistance(const ExampleTree& other) const;
202 
208  void Centroid(arma::vec& centroid) const;
209 
216  double FurthestDescendantDistance() const;
217 
222  double ParentDistance() const;
223 
224  private:
227  StatisticType stat;
228 
236  MetricType& metric;
237 };
238 
239 }; // namespace tree
240 }; // namespace mlpack
241 
242 #endif
size_t NumChildren() const
Return the number of children of this node.
void Centroid(arma::vec &centroid) const
Fill the given vector with the center of the node.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
This is not an actual space tree but instead an example tree that exists to show and document all the...
size_t NumDescendants() const
Get the number of descendant points.
double ParentDistance() const
Get the distance from the center of this node to the center of the parent node.
double FurthestDescendantDistance() const
Get the distance from the center of the node to the furthest descendant point of this node...
ExampleTree * Parent() const
Return the parent node (NULL if this is the root of the tree).
MetricType & metric
This member is just here so the ExampleTree compiles without warnings.
double MinDistance(const MatType &point) const
Return the minimum distance between this node and a point.
const MetricType & Metric() const
Get the instantiated metric for this node.
double MaxDistance(const MatType &point) const
Return the maximum distance between this node and a point.
ExampleTree(const MatType &dataset, MetricType &metric)
This constructor will build the tree given a dataset and an instantiated metric.
math::Range RangeDistance(const MatType &point) const
Return both the minimum and maximum distances between this node and a point as a math::Range object...
size_t NumPoints() const
Return the number of points held in this node.
StatisticType stat
This member is just here so the ExampleTree compiles without warnings.
const ExampleTree & Child(const size_t i) const
Return a particular child of this node.
size_t Point(const size_t i) const
Return the index of a particular point of this node.
Simple real-valued range.
Definition: range.hpp:23
const StatisticType & Stat() const
Get the statistic for this node.
size_t Descendant(const size_t i) const
Get the index of a particular descendant point.