mlpack
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > Class Template Reference

A binary space partitioning tree, such as a KD-tree or a ball tree. More...

#include <binary_space_tree.hpp>

Classes

class  BreadthFirstDualTreeTraverser
 
class  DualTreeTraverser
 A dual-tree traverser for binary space trees; see dual_tree_traverser.hpp. More...
 
class  SingleTreeTraverser
 A single-tree traverser for binary space trees; see single_tree_traverser.hpp for implementation. More...
 

Public Types

typedef MatType Mat
 So other classes can use TreeType::Mat.
 
typedef MatType::elem_type ElemType
 The type of element held in MatType.
 
typedef SplitType< BoundType< MetricType >, MatType > Split
 

Public Member Functions

 BinarySpaceTree (const MatType &data, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (const MatType &data, std::vector< size_t > &oldFromNew, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (const MatType &data, std::vector< size_t > &oldFromNew, std::vector< size_t > &newFromOld, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (MatType &&data, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (MatType &&data, std::vector< size_t > &oldFromNew, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (MatType &&data, std::vector< size_t > &oldFromNew, std::vector< size_t > &newFromOld, const size_t maxLeafSize=20)
 Construct this as the root node of a binary space tree using the given dataset. More...
 
 BinarySpaceTree (BinarySpaceTree *parent, const size_t begin, const size_t count, SplitType< BoundType< MetricType >, MatType > &splitter, const size_t maxLeafSize=20)
 Construct this node as a child of the given parent, starting at column begin and using count points. More...
 
 BinarySpaceTree (BinarySpaceTree *parent, const size_t begin, const size_t count, std::vector< size_t > &oldFromNew, SplitType< BoundType< MetricType >, MatType > &splitter, const size_t maxLeafSize=20)
 Construct this node as a child of the given parent, starting at column begin and using count points. More...
 
 BinarySpaceTree (BinarySpaceTree *parent, const size_t begin, const size_t count, std::vector< size_t > &oldFromNew, std::vector< size_t > &newFromOld, SplitType< BoundType< MetricType >, MatType > &splitter, const size_t maxLeafSize=20)
 Construct this node as a child of the given parent, starting at column begin and using count points. More...
 
 BinarySpaceTree (const BinarySpaceTree &other)
 Create a binary space tree by copying the other tree. More...
 
 BinarySpaceTree (BinarySpaceTree &&other)
 Move constructor for a BinarySpaceTree; possess all the members of the given tree. More...
 
BinarySpaceTreeoperator= (const BinarySpaceTree &other)
 Copy the given BinarySaceTree. More...
 
BinarySpaceTreeoperator= (BinarySpaceTree &&other)
 Take ownership of the given BinarySpaceTree. More...
 
template<typename Archive >
 BinarySpaceTree (Archive &ar, const typename std::enable_if_t< cereal::is_loading< Archive >()> *=0)
 Initialize the tree from a cereal archive. More...
 
 ~BinarySpaceTree ()
 Deletes this node, deallocating the memory for the children and calling their destructors in turn. More...
 
const BoundType< MetricType > & Bound () const
 Return the bound object for this node.
 
BoundType< MetricType > & Bound ()
 Return the bound object for this node.
 
const StatisticType & Stat () const
 Return the statistic object for this node.
 
StatisticType & Stat ()
 Return the statistic object for this node.
 
bool IsLeaf () const
 Return whether or not this node is a leaf (true if it has no children).
 
BinarySpaceTreeLeft () const
 Gets the left child of this node.
 
BinarySpaceTree *& Left ()
 Modify the left child of this node.
 
BinarySpaceTreeRight () const
 Gets the right child of this node.
 
BinarySpaceTree *& Right ()
 Modify the right child of this node.
 
BinarySpaceTreeParent () const
 Gets the parent of this node.
 
BinarySpaceTree *& Parent ()
 Modify the parent of this node.
 
const MatType & Dataset () const
 Get the dataset which the tree is built on.
 
MatType & Dataset ()
 Modify the dataset which the tree is built on. Be careful!
 
MetricType Metric () const
 Get the metric that the tree uses.
 
size_t NumChildren () const
 Return the number of children in this 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...
 
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 GetNearestChild (const BinarySpaceTree &queryNode)
 Return the index of the nearest child node to the given query node. More...
 
size_t GetFurthestChild (const BinarySpaceTree &queryNode)
 Return the index of the furthest child node to the given query node. More...
 
ElemType FurthestPointDistance () const
 Return the furthest distance to a point held in this node. More...
 
ElemType FurthestDescendantDistance () const
 Return the furthest possible descendant distance. More...
 
ElemType MinimumBoundDistance () const
 Return the minimum distance from the center of the node to any bound edge. More...
 
ElemType ParentDistance () const
 Return the distance from the center of this node to the center of the parent node. More...
 
ElemTypeParentDistance ()
 Modify the distance from the center of this node to the center of the parent node. More...
 
BinarySpaceTreeChild (const size_t child) const
 Return the specified child (0 will be left, 1 will be right). More...
 
BinarySpaceTree *& ChildPtr (const size_t child)
 
size_t NumPoints () const
 Return the number of points in this node (0 if not a leaf). More...
 
size_t NumDescendants () const
 Return the number of descendants of this node. 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...
 
size_t Point (const size_t index) const
 Return the index (with reference to the dataset) of a particular point in this node. More...
 
ElemType MinDistance (const BinarySpaceTree &other) const
 Return the minimum distance to another node.
 
ElemType MaxDistance (const BinarySpaceTree &other) const
 Return the maximum distance to another node.
 
math::RangeType< ElemTypeRangeDistance (const BinarySpaceTree &other) const
 Return the minimum and maximum distance to another node.
 
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.
 
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.
 
template<typename VecType >
math::RangeType< ElemTypeRangeDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Return the minimum and maximum distance to another point.
 
size_t Begin () const
 Return the index of the beginning point of this subset.
 
size_t & Begin ()
 Modify the index of the beginning point of this subset.
 
size_t Count () const
 Return the number of points in this subset.
 
size_t & Count ()
 Modify the number of points in this subset.
 
void Center (arma::vec &center) const
 Store the center of the bounding region in the given vector.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t version)
 Serialize the tree.
 

Protected Member Functions

 BinarySpaceTree ()
 A default constructor. More...
 

Friends

class cereal::access
 Friend access is given for the default constructor.
 

Detailed Description

template<typename MetricType, typename StatisticType = EmptyStatistic, typename MatType = arma::mat, template< typename BoundMetricType, typename... > class BoundType = bound::HRectBound, template< typename SplitBoundType, typename SplitMatType > class SplitType = MidpointSplit>
class mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >

A binary space partitioning tree, such as a KD-tree or a ball 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 particular tree does not allow growth, so you cannot add or delete nodes from it. If you need to add or delete a node, the better procedure is to rebuild the tree entirely.

This tree does take one runtime parameter in the constructor, which is the max leaf size to be used.

Template Parameters
MetricTypeThe metric used for tree-building. The BoundType may place restrictions on the metrics that can be used.
StatisticTypeExtra data contained in the node. See statistic.hpp for the necessary skeleton interface.
MatTypeThe dataset class.
BoundTypeThe bound used for each node. HRectBound, the default, requires that an LMetric<> is used for MetricType (so, EuclideanDistance, ManhattanDistance, etc.).
SplitTypeThe class that partitions the dataset/points at a particular node into two parts. Its definition decides the way this split is done.

Constructor & Destructor Documentation

◆ BinarySpaceTree() [1/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( const MatType &  data,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will copy the input matrix; if you don't want this, consider using the constructor that takes an rvalue reference and use std::move().

Parameters
dataDataset to create tree from. This will be copied!
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [2/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( const MatType &  data,
std::vector< size_t > &  oldFromNew,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will copy the input matrix and modify its ordering; a mapping of the old point indices to the new point indices is filled. If you don't want the matrix to be copied, consider using the constructor that takes an rvalue reference and use std::move().

Parameters
dataDataset to create tree from. This will be copied!
oldFromNewVector which will be filled with the old positions for each new point.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [3/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( const MatType &  data,
std::vector< size_t > &  oldFromNew,
std::vector< size_t > &  newFromOld,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will copy the input matrix and modify its ordering; a mapping of the old point indices to the new point indices is filled, as well as a mapping of the new point indices to the old point indices. If you don't want the matrix to be copied, consider using the constructor that takes an rvalue reference and use std::move().

Parameters
dataDataset to create tree from. This will be copied!
oldFromNewVector which will be filled with the old positions for each new point.
newFromOldVector which will be filled with the new positions for each old point.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [4/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( MatType &&  data,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will take ownership of the data matrix; if you don't want this, consider using the constructor that takes a const reference to a dataset.

Parameters
dataDataset to create tree from.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [5/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( MatType &&  data,
std::vector< size_t > &  oldFromNew,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will take ownership of the data matrix; a mapping of the old point indices to the new point indices is filled. If you don't want the matrix to have its ownership taken, consider using the constructor that takes a const reference to a dataset.

Parameters
dataDataset to create tree from.
oldFromNewVector which will be filled with the old positions for each new point.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [6/13]

template<typename MetricType , typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( MatType &&  data,
std::vector< size_t > &  oldFromNew,
std::vector< size_t > &  newFromOld,
const size_t  maxLeafSize = 20 
)

Construct this as the root node of a binary space tree using the given dataset.

This will take ownership of the data matrix; a mapping of the old point indices to the new point indices is filled, as well as a mapping of the new point indices to the old point indices. If you don't want the matrix to have its ownership taken, consider using the constructor that takes a const reference to a dataset.

Parameters
dataDataset to create tree from.
oldFromNewVector which will be filled with the old positions for each new point.
newFromOldVector which will be filled with the new positions for each old point.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [7/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > *  parent,
const size_t  begin,
const size_t  count,
SplitType< BoundType< MetricType >, MatType > &  splitter,
const size_t  maxLeafSize = 20 
)

Construct this node as a child of the given parent, starting at column begin and using count points.

The ordering of that subset of points in the parent's data matrix will be modified! This is used for recursive tree-building by the other constructors which don't specify point indices.

Parameters
parentParent of this node. Its dataset will be modified!
beginIndex of point to start tree construction with.
countNumber of points to use to construct tree.
splitterInstantiated node splitter object.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [8/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > *  parent,
const size_t  begin,
const size_t  count,
std::vector< size_t > &  oldFromNew,
SplitType< BoundType< MetricType >, MatType > &  splitter,
const size_t  maxLeafSize = 20 
)

Construct this node as a child of the given parent, starting at column begin and using count points.

The ordering of that subset of points in the parent's data matrix will be modified! This is used for recursive tree-building by the other constructors which don't specify point indices.

A mapping of the old point indices to the new point indices is filled, but it is expected that the vector is already allocated with size greater than or equal to (begin + count), and if that is not true, invalid memory reads (and writes) will occur.

Parameters
parentParent of this node. Its dataset will be modified!
beginIndex of point to start tree construction with.
countNumber of points to use to construct tree.
oldFromNewVector which will be filled with the old positions for each new point.
splitterInstantiated node splitter object.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [9/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > *  parent,
const size_t  begin,
const size_t  count,
std::vector< size_t > &  oldFromNew,
std::vector< size_t > &  newFromOld,
SplitType< BoundType< MetricType >, MatType > &  splitter,
const size_t  maxLeafSize = 20 
)

Construct this node as a child of the given parent, starting at column begin and using count points.

The ordering of that subset of points in the parent's data matrix will be modified! This is used for recursive tree-building by the other constructors which don't specify point indices.

A mapping of the old point indices to the new point indices is filled, as well as a mapping of the new point indices to the old point indices. It is expected that the vector is already allocated with size greater than or equal to (begin_in + count_in), and if that is not true, invalid memory reads (and writes) will occur.

Parameters
parentParent of this node. Its dataset will be modified!
beginIndex of point to start tree construction with.
countNumber of points to use to construct tree.
oldFromNewVector which will be filled with the old positions for each new point.
newFromOldVector which will be filled with the new positions for each old point.
splitterSplitter matrix to use.
maxLeafSizeSize of each leaf in the tree.

◆ BinarySpaceTree() [10/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( const BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &  other)

Create a binary space tree by copying the other tree.

Be careful! This can take a long time and use a lot of memory.

Parameters
otherTree to be copied.

Be careful! This can take a long time and use a lot of memory.

◆ BinarySpaceTree() [11/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &&  other)

Move constructor for a BinarySpaceTree; possess all the members of the given tree.

Move constructor.

◆ BinarySpaceTree() [12/13]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
template<typename Archive >
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( Archive &  ar,
const typename std::enable_if_t< cereal::is_loading< Archive >()> *  = 0 
)

Initialize the tree from a cereal archive.

Initialize the tree from an archive.

Parameters
arArchive to load tree from. Must be an iarchive, not an oarchive.

◆ ~BinarySpaceTree()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::~BinarySpaceTree ( )

Deletes this node, deallocating the memory for the children and calling their destructors in turn.

This will invalidate any pointers or references to any nodes which are children of this one.

◆ BinarySpaceTree() [13/13]

template<typename MetricType, typename StatisticType , typename MatType, template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::BinarySpaceTree ( )
protected

A default constructor.

This is meant to only be used with cereal, which is allowed with the friend declaration below. This does not return a valid tree! The method must be protected, so that the serialization shim can work with the default constructor.

Member Function Documentation

◆ Child()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > & mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::Child ( const size_t  child) const
inline

Return the specified child (0 will be left, 1 will be right).

Return the specified child.

If the index is greater than 1, this will return the right child.

Parameters
childIndex of child to return.

◆ Descendant()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::Descendant ( const size_t  index) const
inline

Return the index (with reference to the dataset) of a particular descendant of this node.

Return the index of a particular descendant contained in this node.

The index should be greater than zero but less than the number of descendants.

Parameters
indexIndex of the descendant.

◆ FurthestDescendantDistance()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::ElemType mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::FurthestDescendantDistance ( ) const
inline

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).

This returns the maximum distance from the center 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).

◆ FurthestPointDistance()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::ElemType mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::FurthestPointDistance ( ) const
inline

Return the furthest distance to a point held in this node.

Return a bound on the furthest point in the node from the center.

If this is not a leaf node, then the distance is 0 because the node holds no points.

This returns 0 unless the node is a leaf.

◆ GetFurthestChild() [1/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
template<typename VecType >
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::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).

◆ GetFurthestChild() [2/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::GetFurthestChild ( const BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &  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).

◆ GetNearestChild() [1/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
template<typename VecType >
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::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).

◆ GetNearestChild() [2/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::GetNearestChild ( const BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &  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).

◆ MinimumBoundDistance()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::ElemType mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::MinimumBoundDistance ( ) const
inline

Return the minimum distance from the center of the node to any bound edge.

Return the minimum distance from the center to any bound edge.

◆ NumChildren()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::NumChildren ( ) const
inline

Return the number of children in this node.

Returns the number of children in this node.

◆ NumDescendants()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::NumDescendants ( ) const
inline

Return the number of descendants of this node.

Return the number of descendants contained in the 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.

◆ NumPoints()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::NumPoints ( ) const
inline

Return the number of points in this node (0 if not a leaf).

Return the number of points contained in this node.

◆ operator=() [1/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > & mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::operator= ( const BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &  other)

Copy the given BinarySaceTree.

Copy assignment operator: copy the given other tree.

Parameters
otherThe tree to be copied.

◆ operator=() [2/2]

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > & mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::operator= ( BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType > &&  other)

Take ownership of the given BinarySpaceTree.

Move assignment operator: take ownership of the given tree.

Parameters
otherThe tree to take ownership of.

◆ ParentDistance() [1/2]

template<typename MetricType, typename StatisticType = EmptyStatistic, typename MatType = arma::mat, template< typename BoundMetricType, typename... > class BoundType = bound::HRectBound, template< typename SplitBoundType, typename SplitMatType > class SplitType = MidpointSplit>
ElemType mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::ParentDistance ( ) const
inline

Return the distance from the center of this node to the center of the parent node.

◆ ParentDistance() [2/2]

template<typename MetricType, typename StatisticType = EmptyStatistic, typename MatType = arma::mat, template< typename BoundMetricType, typename... > class BoundType = bound::HRectBound, template< typename SplitBoundType, typename SplitMatType > class SplitType = MidpointSplit>
ElemType& mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::ParentDistance ( )
inline

Modify the distance from the center of this node to the center of the parent node.

◆ Point()

template<typename MetricType , typename StatisticType , typename MatType , template< typename BoundMetricType, typename... > class BoundType, template< typename SplitBoundType, typename SplitMatType > class SplitType>
size_t mlpack::tree::BinarySpaceTree< MetricType, StatisticType, MatType, BoundType, SplitType >::Point ( const size_t  index) const
inline

Return the index (with reference to the dataset) of a particular point in this node.

Return the index of a particular point contained 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.

Parameters
indexIndex of point for which a dataset index is wanted.

The documentation for this class was generated from the following files: