.TH "mlpack::tree::ExampleTree< MetricType, StatisticType, MatType >" 3 "Tue Sep 9 2014" "Version 1.0.10" "MLPACK" \" -*- nroff -*- .ad l .nh .SH NAME mlpack::tree::ExampleTree< MetricType, StatisticType, MatType > \- .PP This is not an actual space tree but instead an example tree that exists to show and document all the functions that mlpack trees must implement\&. .SH SYNOPSIS .br .PP .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBExampleTree\fP (const MatType &dataset, MetricType &\fBmetric\fP)" .br .RI "\fIThis constructor will build the tree given a dataset and an instantiated metric\&. \fP" .ti -1c .RI "void \fBCentroid\fP (arma::vec ¢roid) const " .br .RI "\fIFill the given vector with the center of the node\&. \fP" .ti -1c .RI "const \fBExampleTree\fP & \fBChild\fP (const size_t i) const " .br .RI "\fIReturn a particular child of this node\&. \fP" .ti -1c .RI "\fBExampleTree\fP & \fBChild\fP (const size_t i)" .br .RI "\fIModify a particular child of this node\&. \fP" .ti -1c .RI "size_t \fBDescendant\fP (const size_t i) const " .br .RI "\fIGet the index of a particular descendant point\&. \fP" .ti -1c .RI "double \fBFurthestDescendantDistance\fP () const " .br .RI "\fIGet the distance from the center of the node to the furthest descendant point of this node\&. \fP" .ti -1c .RI "double \fBMaxDistance\fP (const MatType &point) const " .br .RI "\fIReturn the maximum distance between this node and a point\&. \fP" .ti -1c .RI "double \fBMaxDistance\fP (const \fBExampleTree\fP &other) const " .br .RI "\fIReturn the maximum distance between this node and another node\&. \fP" .ti -1c .RI "const MetricType & \fBMetric\fP () const " .br .RI "\fIGet the instantiated metric for this node\&. \fP" .ti -1c .RI "MetricType & \fBMetric\fP ()" .br .RI "\fIModify the instantiated metric for this node\&. \fP" .ti -1c .RI "double \fBMinDistance\fP (const MatType &point) const " .br .RI "\fIReturn the minimum distance between this node and a point\&. \fP" .ti -1c .RI "double \fBMinDistance\fP (const \fBExampleTree\fP &other) const " .br .RI "\fIReturn the minimum distance between this node and another node\&. \fP" .ti -1c .RI "size_t \fBNumChildren\fP () const " .br .RI "\fIReturn the number of children of this node\&. \fP" .ti -1c .RI "size_t \fBNumDescendants\fP () const " .br .RI "\fIGet the number of descendant points\&. \fP" .ti -1c .RI "size_t \fBNumPoints\fP () const " .br .RI "\fIReturn the number of points held in this node\&. \fP" .ti -1c .RI "\fBExampleTree\fP * \fBParent\fP () const " .br .RI "\fIReturn the parent node (NULL if this is the root of the tree)\&. \fP" .ti -1c .RI "double \fBParentDistance\fP () const " .br .RI "\fIGet the distance from the center of this node to the center of the parent node\&. \fP" .ti -1c .RI "size_t \fBPoint\fP (const size_t i) const " .br .RI "\fIReturn the index of a particular point of this node\&. \fP" .ti -1c .RI "\fBmath::Range\fP \fBRangeDistance\fP (const MatType &point) const " .br .RI "\fIReturn both the minimum and maximum distances between this node and a point as a \fBmath::Range\fP object\&. \fP" .ti -1c .RI "\fBmath::Range\fP \fBRangeDistance\fP (const \fBExampleTree\fP &other) const " .br .RI "\fIReturn both the minimum and maximum distances between this node and another node as a \fBmath::Range\fP object\&. \fP" .ti -1c .RI "const StatisticType & \fBStat\fP () const " .br .RI "\fIGet the statistic for this node\&. \fP" .ti -1c .RI "StatisticType & \fBStat\fP ()" .br .RI "\fIModify the statistic for this node\&. \fP" .in -1c .SS "Private Attributes" .in +1c .ti -1c .RI "MetricType & \fBmetric\fP" .br .RI "\fIThis member is just here so the \fBExampleTree\fP compiles without warnings\&. \fP" .ti -1c .RI "StatisticType \fBstat\fP" .br .RI "\fIThis member is just here so the \fBExampleTree\fP compiles without warnings\&. \fP" .in -1c .SH "Detailed Description" .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat>class mlpack::tree::ExampleTree< MetricType, StatisticType, MatType >" This is not an actual space tree but instead an example tree that exists to show and document all the functions that mlpack trees must implement\&. For a better overview of trees, see \fBtrees\fP\&. Also be aware that the implementations of each of the methods in this example tree are entirely fake and do not work; this example tree exists for its API, not its implementation\&. .PP Note that trees often have different properties\&. These properties are known at compile-time through the \fBmlpack::tree::TreeTraits\fP class, and some properties may imply the existence (or non-existence) of certain functions\&. Refer to the \fBTreeTraits\fP for more documentation on that\&. .PP The three template parameters below must be template parameters to the tree, in the order given below\&. More template parameters are fine, but they must come after the first three\&. .PP \fBTemplate Parameters:\fP .RS 4 \fIMetricType\fP This defines the space in which the tree will be built\&. For some trees, arbitrary metrics cannot be used, and a template metaprogramming approach should be used to issue a compile-time error if a metric cannot be used with a specific tree type\&. One example is the \fBtree::BinarySpaceTree\fP tree type, which cannot work with the \fBmetric::IPMetric\fP class\&. .br \fIStatisticType\fP A tree node can hold a statistic, which is sometimes useful for various dual-tree algorithms\&. The tree itself does not need to know anything about how the statistic works, but it needs to hold a StatisticType in each node\&. It can be assumed that the StatisticType class has a constructor StatisticType(const ExampleTree&)\&. .br \fIMatType\fP A tree could be built on a dense matrix or a sparse matrix\&. All mlpack trees should be able to support any Armadillo-compatible matrix type\&. When the tree is written it should be assumed that MatType has the same functionality as arma::mat\&. .RE .PP .PP Definition at line 66 of file example_tree\&.hpp\&. .SH "Constructor & Destructor Documentation" .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::\fBExampleTree\fP (const MatType &dataset, MetricType &metric)" .PP This constructor will build the tree given a dataset and an instantiated metric\&. Note that the parameter is a MatType& and not an arma::mat&\&. The dataset is not modified by the tree-building process (if it is, see the documentation for \fBmlpack::tree::TreeTraits::RearrangesDataset\fP for how to deal with that situation)\&. The MetricType parameter is necessary even though some metrics do not hold any state\&. This is so that the tree does not have to worry about instantiating the metric (if the tree had to worry about this, this would almost certainly incur additional runtime complexity and a larger runtime size of the tree node objects, which is to be avoided)\&. The metric can't be const, in case MetricType::Evaluate() is non-const\&. .PP When this constructor is finished, the entire tree will be built and ready to use\&. The constructor should call the constructor of the statistic for each node that is built (see \fBtree::EmptyStatistic\fP for more information)\&. .PP \fBParameters:\fP .RS 4 \fIdataset\fP The dataset that the tree will be built on\&. .br \fImetric\fP The instantiated metric to use to build the dataset\&. .RE .PP .SH "Member Function Documentation" .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> void \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Centroid (arma::vec ¢roid) const" .PP Fill the given vector with the center of the node\&. .PP \fBParameters:\fP .RS 4 \fIcentroid\fP Vector to be filled with the center of the node\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> const \fBExampleTree\fP& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Child (const size_ti) const" .PP Return a particular child of this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> \fBExampleTree\fP& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Child (const size_ti)" .PP Modify a particular child of this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> size_t \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Descendant (const size_ti) const" .PP Get the index of a particular descendant point\&. The ordering of the descendants does not matter, as long as calling Descendant(0) through Descendant(\fBNumDescendants()\fP - 1) will return the indices of every unique descendant point of the node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::FurthestDescendantDistance () const" .PP Get the distance from the center of the node to the furthest descendant point of this node\&. This does not necessarily need to be the exact furthest descendant distance but instead can be an upper bound\&. See the definitions in \fBtrees\fP for more information\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::MaxDistance (const MatType &point) const" .PP Return the maximum distance between this node and a point\&. It is not required that the exact maximum distance between the node and the point is returned but instead an upper bound on the maximum distance will suffice\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fIpoint\fP Point to return [upper bound on] maximum distance to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::MaxDistance (const \fBExampleTree\fP< MetricType, StatisticType, MatType > &other) const" .PP Return the maximum distance between this node and another node\&. It is not required that the exact maximum distance between the two nodes be returned but instead an upper bound on the maximum distance will suffice\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fInode\fP Node to return [upper bound on] maximum distance to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> const MetricType& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Metric () const" .PP Get the instantiated metric for this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> MetricType& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Metric ()" .PP Modify the instantiated metric for this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::MinDistance (const MatType &point) const" .PP Return the minimum distance between this node and a point\&. It is not required that the exact minimum distance between the node and the point is returned but instead a lower bound on the minimum distance will suffice\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fIpoint\fP Point to return [lower bound on] minimum distance to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::MinDistance (const \fBExampleTree\fP< MetricType, StatisticType, MatType > &other) const" .PP Return the minimum distance between this node and another node\&. It is not required that the exact minimum distance between the two nodes be returned but instead a lower bound on the minimum distance will suffice\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fInode\fP Node to return [lower bound on] minimum distance to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> size_t \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::NumChildren () const" .PP Return the number of children of this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> size_t \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::NumDescendants () const" .PP Get the number of descendant points\&. This is the number of unique points held in this node plus the number of points held in all descendant nodes\&. This could be calculated at build-time and cached, or could be calculated at run-time\&. This may be harder to calculate for trees that may hold points in multiple nodes (like cover trees and spill trees, for instance)\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> size_t \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::NumPoints () const" .PP Return the number of points held in this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> \fBExampleTree\fP* \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Parent () const" .PP Return the parent node (NULL if this is the root of the tree)\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> double \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::ParentDistance () const" .PP Get the distance from the center of this node to the center of the parent node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> size_t \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Point (const size_ti) const" .PP Return the index of a particular point of this node\&. mlpack trees do not, in general, hold the actual dataset, and instead just hold the indices of the points they contain\&. Thus, you might use this function in code like this: .PP .PP .nf arma::vec thirdPoint = dataset\&.col(treeNode\&.Point(2)); .fi .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> \fBmath::Range\fP \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::RangeDistance (const MatType &point) const" .PP Return both the minimum and maximum distances between this node and a point as a \fBmath::Range\fP object\&. This overload is given because it is possible that, for some tree types, calculation of both at once is faster than a call to \fBMinDistance()\fP then \fBMaxDistance()\fP\&. It is not necessary that the minimum and maximum distances be exact; it is sufficient to return a lower bound on the minimum distance and an upper bound on the maximum distance\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fIpoint\fP Point to return [bounds on] minimum and maximum distances to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> \fBmath::Range\fP \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::RangeDistance (const \fBExampleTree\fP< MetricType, StatisticType, MatType > &other) const" .PP Return both the minimum and maximum distances between this node and another node as a \fBmath::Range\fP object\&. This overload is given because it is possible that, for some tree types, calculation of both at once is faster than a call to \fBMinDistance()\fP then \fBMaxDistance()\fP\&. It is not necessary that the minimum and maximum distances be exact; it is sufficient to return a lower bound on the minimum distance and an upper bound on the maximum distance\&. See the definitions in \fBtrees\fP for more information\&. .PP \fBParameters:\fP .RS 4 \fInode\fP Node to return [bounds on] minimum and maximum distances to\&. .RE .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> const StatisticType& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Stat () const" .PP Get the statistic for this node\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> StatisticType& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::Stat ()" .PP Modify the statistic for this node\&. .SH "Member Data Documentation" .PP .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> MetricType& \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::metric\fC [private]\fP" .PP This member is just here so the \fBExampleTree\fP compiles without warnings\&. It is not required to be a member in every type of tree\&. Be aware that storing the metric as a member and not a reference may mean that for some metrics (such as \fBmetric::MahalanobisDistance\fP in high dimensionality) may incur lots of unnecessary matrix copying\&. .PP Definition at line 244 of file example_tree\&.hpp\&. .SS "template, typename StatisticType = EmptyStatistic, typename MatType = arma::mat> StatisticType \fBmlpack::tree::ExampleTree\fP< MetricType, StatisticType, MatType >::stat\fC [private]\fP" .PP This member is just here so the \fBExampleTree\fP compiles without warnings\&. It is not required to be a member in every type of tree\&. .PP Definition at line 235 of file example_tree\&.hpp\&. .SH "Author" .PP Generated automatically by Doxygen for MLPACK from the source code\&.