mlpack
master
|
A rectangle type tree tree, such as an R-tree or X-tree. More...
Classes | |
class | DualTreeTraverser |
A dual tree traverser for rectangle type trees. More... | |
class | SingleTreeTraverser |
A single traverser for rectangle type trees. More... | |
Public Types | |
typedef AuxiliaryInformationType< RectangleTree > | AuxiliaryInformation |
The auxiliary information type held by the tree. More... | |
typedef MatType::elem_type | ElemType |
The element type held by the matrix type. More... | |
typedef MatType | Mat |
So other classes can use TreeType::Mat. More... | |
Public Member Functions | |
RectangleTree (const MatType &data, const size_t maxLeafSize=20, const size_t minLeafSize=8, const size_t maxNumChildren=5, const size_t minNumChildren=2, const size_t firstDataIndex=0) | |
Construct this as the root node of a rectangle type tree using the given dataset. More... | |
RectangleTree (MatType &&data, const size_t maxLeafSize=20, const size_t minLeafSize=8, const size_t maxNumChildren=5, const size_t minNumChildren=2, const size_t firstDataIndex=0) | |
Construct this as the root node of a rectangle tree type using the given dataset, and taking ownership of the given dataset. More... | |
RectangleTree (RectangleTree *parentNode, const size_t numMaxChildren=0) | |
Construct this as an empty node with the specified parent. More... | |
RectangleTree (const RectangleTree &other, const bool deepCopy=true, RectangleTree *newParent=NULL) | |
Create a rectangle tree by copying the other tree. More... | |
RectangleTree (RectangleTree &&other) | |
Create a rectangle tree by moving the other tree. More... | |
template<typename Archive > | |
RectangleTree (Archive &ar, const typename std::enable_if_t< Archive::is_loading::value > *=0) | |
Construct the tree from a boost::serialization archive. More... | |
~RectangleTree () | |
Deletes this node, deallocating the memory for the children and calling their destructors in turn. More... | |
const AuxiliaryInformationType< RectangleTree > & | AuxiliaryInfo () const |
Return the auxiliary information object of this node. More... | |
AuxiliaryInformationType< RectangleTree > & | AuxiliaryInfo () |
Modify the split object of this node. More... | |
size_t | Begin () const |
Return the index of the beginning point of this subset. More... | |
size_t & | Begin () |
Modify the index of the beginning point of this subset. More... | |
const bound::HRectBound< MetricType > & | Bound () const |
Return the bound object for this node. More... | |
bound::HRectBound< MetricType > & | Bound () |
Modify the bound object for this node. More... | |
void | Center (arma::vec ¢er) |
Get the centroid of the node and store it in the given vector. More... | |
RectangleTree & | Child (const size_t child) const |
Get the specified child. More... | |
RectangleTree & | Child (const size_t child) |
Modify the specified child. More... | |
void | CondenseTree (const arma::vec &point, std::vector< bool > &relevels, const bool usePoint) |
Condense the bounding rectangles for this node based on the removal of the point specified by the arma::vec&. More... | |
size_t | Count () const |
Return the number of points in this subset. More... | |
size_t & | Count () |
Modify the number of points in this subset. More... | |
const MatType & | Dataset () const |
Get the dataset which the tree is built on. More... | |
MatType & | Dataset () |
Modify the dataset which the tree is built on. Be careful! More... | |
bool | DeletePoint (const size_t point) |
Deletes a point from the treeand, updates the bounding rectangle. More... | |
bool | DeletePoint (const size_t point, std::vector< bool > &relevels) |
Deletes a point from the tree, updates the bounding rectangle, tracking levels. More... | |
size_t | Descendant (const size_t index) const |
Return the index (with reference to the dataset) of a particular descendant of this node. More... | |
RectangleTree * | ExactClone () |
Make an exact copy of this node, pointers and everything. More... | |
const RectangleTree * | FindByBeginCount (size_t begin, size_t count) const |
Find a node in this tree by its begin and count (const). More... | |
RectangleTree * | FindByBeginCount (size_t begin, size_t count) |
Find a node in this tree by its begin and count. More... | |
ElemType | FurthestDescendantDistance () const |
Return the furthest possible descendant distance. More... | |
ElemType | FurthestPointDistance () const |
Return the furthest distance to a point held in this node. More... | |
template<typename VecType > | |
size_t | GetFurthestChild (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) |
Return the index of the furthest child node to the given query point. More... | |
size_t | GetFurthestChild (const RectangleTree &queryNode) |
Return the index of the furthest child node to the given query node. More... | |
template<typename VecType > | |
size_t | GetNearestChild (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) |
Return the index of the nearest child node to the given query point. More... | |
size_t | GetNearestChild (const RectangleTree &queryNode) |
Return the index of the nearest child node to the given query node. More... | |
void | InsertNode (RectangleTree *node, const size_t level, std::vector< bool > &relevels) |
Inserts a node into the tree, tracking which levels have been inserted into. More... | |
void | InsertPoint (const size_t point) |
Inserts a point into the tree. More... | |
void | InsertPoint (const size_t point, std::vector< bool > &relevels) |
Inserts a point into the tree, tracking which levels have been inserted into. More... | |
bool | IsLeaf () const |
Return whether or not this node is a leaf (true if it has no children). More... | |
ElemType | MaxDistance (const RectangleTree &other) const |
Return the maximum distance to another node. More... | |
template<typename VecType > | |
ElemType | MaxDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const |
Return the maximum distance to another point. More... | |
size_t | MaxLeafSize () const |
Return the maximum leaf size. More... | |
size_t & | MaxLeafSize () |
Modify the maximum leaf size. More... | |
size_t | MaxNumChildren () const |
Return the maximum number of children (in a non-leaf node). More... | |
size_t & | MaxNumChildren () |
Modify the maximum number of children (in a non-leaf node). More... | |
MetricType | Metric () const |
Get the metric which the tree uses. More... | |
ElemType | MinDistance (const RectangleTree &other) const |
Return the minimum distance to another node. More... | |
template<typename VecType > | |
ElemType | MinDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const |
Return the minimum distance to another point. More... | |
ElemType | MinimumBoundDistance () const |
Return the minimum distance from the center to any edge of the bound. More... | |
size_t | MinLeafSize () const |
Return the minimum leaf size. More... | |
size_t & | MinLeafSize () |
Modify the minimum leaf size. More... | |
size_t | MinNumChildren () const |
Return the minimum number of children (in a non-leaf node). More... | |
size_t & | MinNumChildren () |
Modify the minimum number of children (in a non-leaf node). More... | |
void | NullifyData () |
Nullify the auxiliary information. More... | |
size_t | NumChildren () const |
Return the number of child nodes. (One level beneath this one only.) More... | |
size_t & | NumChildren () |
Modify the number of child nodes. Be careful. More... | |
size_t | NumDescendants () const |
Return the number of descendants of this node. More... | |
size_t | NumPoints () const |
Return the number of points in this node (returns 0 if this node is not a leaf). More... | |
RectangleTree * | Parent () const |
Gets the parent of this node. More... | |
RectangleTree *& | Parent () |
Modify the parent of this node. More... | |
ElemType | ParentDistance () const |
Return the distance from the center of this node to the center of the parent node. More... | |
ElemType & | ParentDistance () |
Modify the distance from the center of this node to the center of the parent node. More... | |
size_t | Point (const size_t index) const |
Return the index (with reference to the dataset) of a particular point in this node. More... | |
size_t & | Point (const size_t index) |
Modify the index of a particular point in this node. More... | |
math::RangeType< ElemType > | RangeDistance (const RectangleTree &other) const |
Return the minimum and maximum distance to another node. More... | |
template<typename VecType > | |
math::RangeType< ElemType > | RangeDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const |
Return the minimum and maximum distance to another point. More... | |
bool | RemoveNode (const RectangleTree *node, std::vector< bool > &relevels) |
Removes a node from the tree. More... | |
template<typename Archive > | |
void | Serialize (Archive &ar, const unsigned int) |
Serialize the tree. More... | |
bool | ShrinkBoundForBound (const bound::HRectBound< MetricType > &changedBound) |
Shrink the bound object of this node for the removal of a child node. More... | |
bool | ShrinkBoundForPoint (const arma::vec &point) |
Shrink the bound object of this node for the removal of a point. More... | |
void | SoftDelete () |
Delete this node of the tree, but leave the stuff contained in it intact. More... | |
const StatisticType & | Stat () const |
Return the statistic object for this node. More... | |
StatisticType & | Stat () |
Modify the statistic object for this node. More... | |
size_t | TreeDepth () const |
Obtains the number of levels below this node in the tree, starting with this. More... | |
size_t | TreeSize () const |
Obtains the number of nodes in the tree, starting with this. More... | |
Protected Member Functions | |
RectangleTree () | |
A default constructor. More... | |
Protected Attributes | |
friend | AuxiliaryInformation |
Give friend access for AuxiliaryInformationType. More... | |
friend | DescentType |
Give friend access for DescentType. More... | |
friend | SplitType |
Give friend access for SplitType. More... | |
Private Member Functions | |
void | SplitNode (std::vector< bool > &relevels) |
Splits the current node, recursing up the tree. More... | |
Private Attributes | |
AuxiliaryInformationType< RectangleTree > | auxiliaryInfo |
A tree-specific information. More... | |
size_t | begin |
The index of the first point in the dataset contained in this node (and its children). More... | |
bound::HRectBound< metric::EuclideanDistance, ElemType > | bound |
The bound object for this node. More... | |
std::vector< RectangleTree * > | children |
The child nodes (Starting at 0 and ending at (numChildren-1) ). More... | |
size_t | count |
The number of points in the dataset contained in this node (and its children). More... | |
const MatType * | dataset |
The dataset. More... | |
size_t | maxLeafSize |
The max leaf size. More... | |
size_t | maxNumChildren |
The max number of child nodes a non-leaf node can have. More... | |
size_t | minLeafSize |
The minimum leaf size. More... | |
size_t | minNumChildren |
The minimum number of child nodes a non-leaf node can have. More... | |
size_t | numChildren |
The number of child nodes actually in use (0 if this is a leaf node). More... | |
size_t | numDescendants |
The number of descendants of this node. More... | |
bool | ownsDataset |
Whether or not we are responsible for deleting the dataset. More... | |
RectangleTree * | parent |
The parent node (NULL if this is the root of the tree). More... | |
ElemType | parentDistance |
The distance from the centroid of this node to the centroid of the parent. More... | |
std::vector< size_t > | points |
The mapping to the dataset. More... | |
StatisticType | stat |
Any extra data contained in the node. More... | |
A rectangle type tree tree, such as an R-tree or X-tree.
Once the bound and type of dataset is defined, the tree will construct itself. Call the constructor with the dataset to build the tree on, and the entire tree will be built.
This tree does allow growth, so you can add and delete nodes from it.
MetricType | This must be EuclideanDistance, but the template parameter is required to satisfy the TreeType API. |
StatisticType | Extra data contained in the node. See statistic.hpp for the necessary skeleton interface. |
MatType | The dataset class. |
SplitType | The type of split to use when inserting points. |
DescentType | The heuristic to use when descending the tree to insert points. |
AuxiliaryInformationType | An auxiliary information contained in the node. This information depends on the type of the RectangleTree. |
Definition at line 53 of file rectangle_tree.hpp.
typedef AuxiliaryInformationType<RectangleTree> mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::AuxiliaryInformation |
The auxiliary information type held by the tree.
Definition at line 65 of file rectangle_tree.hpp.
typedef MatType::elem_type mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::ElemType |
The element type held by the matrix type.
Definition at line 63 of file rectangle_tree.hpp.
typedef MatType mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Mat |
So other classes can use TreeType::Mat.
Definition at line 57 of file rectangle_tree.hpp.
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree | ( | const MatType & | data, |
const size_t | maxLeafSize = 20 , |
||
const size_t | minLeafSize = 8 , |
||
const size_t | maxNumChildren = 5 , |
||
const size_t | minNumChildren = 2 , |
||
const size_t | firstDataIndex = 0 |
||
) |
Construct this as the root node of a rectangle type tree using the given dataset.
This will modify the ordering of the points in the dataset!
data | Dataset from which to create the tree. This will be modified! |
maxLeafSize | Maximum size of each leaf in the tree. |
minLeafSize | Minimum size of each leaf in the tree. |
maxNumChildren | The maximum number of child nodes a non-leaf node may have. |
minNumChildren | The minimum number of child nodes a non-leaf node may have. |
firstDataIndex | The index of the first data point. UNUSED UNLESS WE ADD SUPPORT FOR HAVING A "CENTERAL" DATA MATRIX. |
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree | ( | MatType && | data, |
const size_t | maxLeafSize = 20 , |
||
const size_t | minLeafSize = 8 , |
||
const size_t | maxNumChildren = 5 , |
||
const size_t | minNumChildren = 2 , |
||
const size_t | firstDataIndex = 0 |
||
) |
Construct this as the root node of a rectangle tree type using the given dataset, and taking ownership of the given dataset.
data | Dataset from which to create the tree. |
maxLeafSize | Maximum size of each leaf in the tree. |
minLeafSize | Minimum size of each leaf in the tree. |
maxNumChildren | The maximum number of child nodes a non-leaf node may have. |
minNumChildren | The minimum number of child nodes a non-leaf node may have. |
firstDataIndex | The index of the first data point. UNUSED UNLESS WE ADD SUPPORT FOR HAVING A "CENTERAL" DATA MATRIX. |
|
explicit |
Construct this as an empty node with the specified parent.
Copying the parameters (maxLeafSize, minLeafSize, maxNumChildren, minNumChildren, firstDataIndex) from the parent.
parentNode | The parent of the node that is being constructed. |
numMaxChildren | The max number of child nodes (used in x-trees). |
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree | ( | const RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > & | other, |
const bool | deepCopy = true , |
||
RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > * | newParent = NULL |
||
) |
Create a rectangle tree by copying the other tree.
Be careful! This can take a long time and use a lot of memory.
other | The tree to be copied. |
deepCopy | If false, the children are not recursively copied. |
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree | ( | RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > && | other | ) |
Create a rectangle tree by moving the other tree.
other | The tree to be copied. |
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree | ( | Archive & | ar, |
const typename std::enable_if_t< Archive::is_loading::value > * | = 0 |
||
) |
Construct the tree from a boost::serialization archive.
mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::~RectangleTree | ( | ) |
Deletes this node, deallocating the memory for the children and calling their destructors in turn.
This will invalidate any younters or references to any nodes which are children of this one.
|
protected |
A default constructor.
This is meant to only be used with boost::serialization, which is allowed with the friend declaration below. This does not return a valid tree! This method must be protected, so that the serialization shim can work with the default constructor.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Count().
|
inline |
Return the auxiliary information object of this node.
Definition at line 309 of file rectangle_tree.hpp.
|
inline |
Modify the split object of this node.
Definition at line 312 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::auxiliaryInfo, and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::IsLeaf().
|
inline |
Return the index of the beginning point of this subset.
Definition at line 527 of file rectangle_tree.hpp.
|
inline |
Modify the index of the beginning point of this subset.
Definition at line 529 of file rectangle_tree.hpp.
|
inline |
Return the bound object for this node.
Definition at line 299 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MaxDistance(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MinDistance(), and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RangeDistance().
|
inline |
Modify the bound object for this node.
Definition at line 301 of file rectangle_tree.hpp.
|
inline |
Get the centroid of the node and store it in the given vector.
Definition at line 352 of file rectangle_tree.hpp.
References mlpack::bound::HRectBound< MetricType, ElemType >::Center().
|
inline |
Get the specified child.
child | Index of child to return. |
Definition at line 421 of file rectangle_tree.hpp.
|
inline |
Modify the specified child.
child | Index of child to return. |
Definition at line 431 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Descendant(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumDescendants(), and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumPoints().
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::CondenseTree | ( | const arma::vec & | point, |
std::vector< bool > & | relevels, | ||
const bool | usePoint | ||
) |
Condense the bounding rectangles for this node based on the removal of the point specified by the arma::vec&.
This recurses up the tree. If a node goes below the minimum fill, this function will fix the tree.
point | The arma::vec& of the point that was removed to require this condesation of the tree. |
usePoint | True if we use the optimized version of the algorithm that is possible when we now what point was deleted. False otherwise (eg. if we deleted a node instead of a point). |
|
inline |
Return the number of points in this subset.
Definition at line 532 of file rectangle_tree.hpp.
|
inline |
Modify the number of points in this subset.
Definition at line 534 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::count, mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RectangleTree(), and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::SplitNode().
|
inline |
Get the dataset which the tree is built on.
Definition at line 344 of file rectangle_tree.hpp.
|
inline |
Modify the dataset which the tree is built on. Be careful!
Definition at line 346 of file rectangle_tree.hpp.
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::DeletePoint | ( | const size_t | point | ) |
Deletes a point from the treeand, updates the bounding rectangle.
However, the point will be kept in the centeral dataset. (The user may remove it from there if he wants, but he must not change the indices of the other points.) Returns true if the point is successfully removed and false if it is not. (ie. the point is not in the tree)
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::DeletePoint | ( | const size_t | point, |
std::vector< bool > & | relevels | ||
) |
Deletes a point from the tree, updates the bounding rectangle, tracking levels.
However, the point will be kept in the centeral dataset. (The user may remove it from there if he wants, but he must not change the indices of the other points.) Returns true if the point is successfully removed and false if it is not. (ie. the point is not in the tree)
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Descendant | ( | const size_t | index | ) | const |
Return the index (with reference to the dataset) of a particular descendant of this node.
The index should be greater than zero but less than the number of descendants.
index | Index of the descendant. |
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Child().
RectangleTree* mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::ExactClone | ( | ) |
Make an exact copy of this node, pointers and everything.
const RectangleTree* mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FindByBeginCount | ( | size_t | begin, |
size_t | count | ||
) | const |
Find a node in this tree by its begin and count (const).
Every node is uniquely identified by these two numbers. This is useful for communicating position over the network, when pointers would be invalid.
RectangleTree* mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FindByBeginCount | ( | size_t | begin, |
size_t | count | ||
) |
Find a node in this tree by its begin and count.
Every node is uniquely identified by these two numbers. This is useful for communicating position over the network, when pointers would be invalid.
ElemType mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FurthestDescendantDistance | ( | ) | const |
Return the furthest possible descendant distance.
This returns the maximum distance from the centroid to the edge of the bound and not the empirical quantity which is the actual furthest descendant distance. So the actual furthest descendant distance may be less than what this method returns (but it will never be greater than this).
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumChildren().
ElemType mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FurthestPointDistance | ( | ) | const |
Return the furthest distance to a point held in this node.
If this is not a leaf node, then the distance is 0 because the node holds no points.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumChildren().
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetFurthestChild | ( | const VecType & | point, |
typename std::enable_if_t< IsVector< VecType >::value > * | = 0 |
||
) |
Return the index of the furthest child node to the given query point.
If this is a leaf node, it will return NumChildren() (invalid index).
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumChildren().
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetFurthestChild | ( | const RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > & | queryNode | ) |
Return the index of the furthest child node to the given query node.
If it can't decide, it will return NumChildren() (invalid index).
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetNearestChild | ( | const VecType & | point, |
typename std::enable_if_t< IsVector< VecType >::value > * | = 0 |
||
) |
Return the index of the nearest child node to the given query point.
If this is a leaf node, it will return NumChildren() (invalid index).
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumChildren().
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetNearestChild | ( | const RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > & | queryNode | ) |
Return the index of the nearest child node to the given query node.
If it can't decide, it will return NumChildren() (invalid index).
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::InsertNode | ( | RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > * | node, |
const size_t | level, | ||
std::vector< bool > & | relevels | ||
) |
Inserts a node into the tree, tracking which levels have been inserted into.
The node will be inserted so that the tree remains valid.
node | The node to be inserted. |
level | The depth that should match the node where this node is finally inserted. This should be the number returned by calling TreeDepth() from the node that originally contained "node". |
relevels | The levels that have been reinserted to on this top level insertion. |
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::InsertPoint | ( | const size_t | point | ) |
Inserts a point into the tree.
point | The index of a point in the dataset. |
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::InsertPoint | ( | const size_t | point, |
std::vector< bool > & | relevels | ||
) |
Inserts a point into the tree, tracking which levels have been inserted into.
point | The index of a point in the dataset. |
relevels | The levels that have been reinserted to on this top level insertion. |
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::IsLeaf | ( | ) | const |
Return whether or not this node is a leaf (true if it has no children).
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::AuxiliaryInfo().
|
inline |
Return the maximum distance to another node.
Definition at line 477 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Bound(), and mlpack::bound::HRectBound< MetricType, ElemType >::MaxDistance().
|
inline |
Return the maximum distance to another point.
Definition at line 499 of file rectangle_tree.hpp.
References mlpack::bound::HRectBound< MetricType, ElemType >::MaxDistance().
|
inline |
Return the maximum leaf size.
Definition at line 319 of file rectangle_tree.hpp.
|
inline |
Modify the maximum leaf size.
Definition at line 321 of file rectangle_tree.hpp.
|
inline |
Return the maximum number of children (in a non-leaf node).
Definition at line 329 of file rectangle_tree.hpp.
|
inline |
Modify the maximum number of children (in a non-leaf node).
Definition at line 331 of file rectangle_tree.hpp.
|
inline |
Get the metric which the tree uses.
Definition at line 349 of file rectangle_tree.hpp.
|
inline |
Return the minimum distance to another node.
Definition at line 471 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Bound(), and mlpack::bound::HRectBound< MetricType, ElemType >::MinDistance().
|
inline |
Return the minimum distance to another point.
Definition at line 490 of file rectangle_tree.hpp.
References mlpack::bound::HRectBound< MetricType, ElemType >::MinDistance().
|
inline |
Return the minimum distance from the center to any edge of the bound.
Currently, this returns 0, which doesn't break algorithms, but it isn't necessarily correct, either.
Definition at line 407 of file rectangle_tree.hpp.
References mlpack::bound::HRectBound< MetricType, ElemType >::MinWidth().
|
inline |
Return the minimum leaf size.
Definition at line 324 of file rectangle_tree.hpp.
|
inline |
Modify the minimum leaf size.
Definition at line 326 of file rectangle_tree.hpp.
|
inline |
Return the minimum number of children (in a non-leaf node).
Definition at line 334 of file rectangle_tree.hpp.
|
inline |
Modify the minimum number of children (in a non-leaf node).
Definition at line 336 of file rectangle_tree.hpp.
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NullifyData | ( | ) |
Nullify the auxiliary information.
Used for memory management. Be cafeful.
|
inline |
Return the number of child nodes. (One level beneath this one only.)
Definition at line 355 of file rectangle_tree.hpp.
|
inline |
Modify the number of child nodes. Be careful.
Definition at line 357 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FurthestDescendantDistance(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::FurthestPointDistance(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetFurthestChild(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::GetNearestChild(), and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::numChildren.
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumDescendants | ( | ) | const |
Return the number of descendants of this node.
For a non-leaf in a binary space tree, this is the number of points at the descendant leaves. For a leaf, this is the number of points in the leaf.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Child().
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumPoints | ( | ) | const |
Return the number of points in this node (returns 0 if this node is not a leaf).
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Child().
|
inline |
Gets the parent of this node.
Definition at line 339 of file rectangle_tree.hpp.
|
inline |
Modify the parent of this node.
Definition at line 341 of file rectangle_tree.hpp.
|
inline |
Return the distance from the center of this node to the center of the parent node.
Definition at line 411 of file rectangle_tree.hpp.
|
inline |
Modify the distance from the center of this node to the center of the parent node.
Definition at line 414 of file rectangle_tree.hpp.
|
inline |
Return the index (with reference to the dataset) of a particular point in this node.
This will happily return invalid indices if the given index is greater than the number of points in this node (obtained with NumPoints()) – be careful.
index | Index of point for which a dataset index is wanted. |
Definition at line 464 of file rectangle_tree.hpp.
|
inline |
Modify the index of a particular point in this node.
Be very careful when you do this! You may make the tree invalid.
Definition at line 468 of file rectangle_tree.hpp.
|
inline |
Return the minimum and maximum distance to another node.
Definition at line 483 of file rectangle_tree.hpp.
References mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Bound(), and mlpack::bound::HRectBound< MetricType, ElemType >::RangeDistance().
|
inline |
Return the minimum and maximum distance to another point.
Definition at line 508 of file rectangle_tree.hpp.
References mlpack::bound::HRectBound< MetricType, ElemType >::RangeDistance(), mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::TreeDepth(), and mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::TreeSize().
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RemoveNode | ( | const RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType > * | node, |
std::vector< bool > & | relevels | ||
) |
Removes a node from the tree.
You are responsible for deleting it if you wish to do so.
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the tree.
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::ShrinkBoundForBound | ( | const bound::HRectBound< MetricType > & | changedBound | ) |
Shrink the bound object of this node for the removal of a child node.
bound | The HRectBound<>& of the bound that was removed to reqire this shrinking. |
bool mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::ShrinkBoundForPoint | ( | const arma::vec & | point | ) |
Shrink the bound object of this node for the removal of a point.
point | The arma::vec& of the point that was removed to require this shrinking. |
void mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::SoftDelete | ( | ) |
Delete this node of the tree, but leave the stuff contained in it intact.
This is used when splitting a node, where the data in this tree is moved to two other trees.
|
private |
Splits the current node, recursing up the tree.
relevels | Vector to track which levels have been inserted to. |
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Count().
|
inline |
Return the statistic object for this node.
Definition at line 304 of file rectangle_tree.hpp.
|
inline |
Modify the statistic object for this node.
Definition at line 306 of file rectangle_tree.hpp.
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::TreeDepth | ( | ) | const |
Obtains the number of levels below this node in the tree, starting with this.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RangeDistance().
size_t mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::TreeSize | ( | ) | const |
Obtains the number of nodes in the tree, starting with this.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RangeDistance().
|
private |
A tree-specific information.
Definition at line 105 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::AuxiliaryInfo().
|
protected |
Give friend access for AuxiliaryInformationType.
Definition at line 563 of file rectangle_tree.hpp.
|
private |
The index of the first point in the dataset contained in this node (and its children).
THIS IS ALWAYS 0 AT THE MOMENT. IT EXISTS MERELY IN CASE I THINK OF A WAY TO CHANGE THAT. IN OTHER WORDS, IT WILL PROBABLY BE REMOVED.
Definition at line 81 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Begin().
|
private |
The bound object for this node.
Definition at line 92 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Bound().
|
private |
The child nodes (Starting at 0 and ending at (numChildren-1) ).
Definition at line 74 of file rectangle_tree.hpp.
|
private |
The number of points in the dataset contained in this node (and its children).
Definition at line 84 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Count().
|
private |
The dataset.
Definition at line 98 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Dataset().
|
protected |
Give friend access for DescentType.
Definition at line 557 of file rectangle_tree.hpp.
|
private |
The max leaf size.
Definition at line 88 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MaxLeafSize().
|
private |
The max number of child nodes a non-leaf node can have.
Definition at line 68 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MaxNumChildren().
|
private |
The minimum leaf size.
Definition at line 90 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MinLeafSize().
|
private |
The minimum number of child nodes a non-leaf node can have.
Definition at line 70 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MinNumChildren().
|
private |
The number of child nodes actually in use (0 if this is a leaf node).
Definition at line 72 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::NumChildren().
|
private |
The number of descendants of this node.
Definition at line 86 of file rectangle_tree.hpp.
|
private |
Whether or not we are responsible for deleting the dataset.
This is probably not aligned well...
Definition at line 101 of file rectangle_tree.hpp.
|
private |
The parent node (NULL if this is the root of the tree).
Definition at line 76 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Parent().
|
private |
The distance from the centroid of this node to the centroid of the parent.
Definition at line 96 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::ParentDistance().
|
private |
The mapping to the dataset.
Definition at line 103 of file rectangle_tree.hpp.
|
protected |
Give friend access for SplitType.
Definition at line 560 of file rectangle_tree.hpp.
|
private |
Any extra data contained in the node.
Definition at line 94 of file rectangle_tree.hpp.
Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Stat().