mlpack
|
Classes | |
class | DualTreeTraverser |
A dual-tree traverser; see dual_tree_traverser.hpp. More... | |
class | SingleTreeTraverser |
A single-tree traverser; see single_tree_traverser.hpp. 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. | |
Public Member Functions | |
Octree (const MatType &data, const size_t maxLeafSize=20) | |
Construct this as the root node of an octree on the given dataset. More... | |
Octree (const MatType &data, std::vector< size_t > &oldFromNew, const size_t maxLeafSize=20) | |
Construct this as the root node of an octree on the given dataset. More... | |
Octree (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 an octree on the given dataset. More... | |
Octree (MatType &&data, const size_t maxLeafSize=20) | |
Construct this as the root node of an octree on the given dataset. More... | |
Octree (MatType &&data, std::vector< size_t > &oldFromNew, const size_t maxLeafSize=20) | |
Construct this as the root node of an octree on the given dataset. More... | |
Octree (MatType &&data, std::vector< size_t > &oldFromNew, std::vector< size_t > &newFromOld, const size_t maxLeafSize=20) | |
Construct this as the root node of an octree on the given dataset. More... | |
Octree (Octree *parent, const size_t begin, const size_t count, const arma::vec ¢er, const double width, const size_t maxLeafSize=20) | |
Construct this node as a child of the given parent, starting at column begin and using count points. More... | |
Octree (Octree *parent, const size_t begin, const size_t count, std::vector< size_t > &oldFromNew, const arma::vec ¢er, const double width, const size_t maxLeafSize=20) | |
Construct this node as a child of the given parent, starting at column begin and using count points. More... | |
Octree (const Octree &other) | |
Copy the given tree. More... | |
Octree (Octree &&other) | |
Move the given tree. More... | |
Octree & | operator= (const Octree &other) |
Copy the given Octree. More... | |
Octree & | operator= (Octree &&other) |
Take ownership of the given Octree. More... | |
template<typename Archive > | |
Octree (Archive &ar, const typename std::enable_if_t< cereal::is_loading< Archive >()> *=0) | |
Initialize the tree from a cereal archive. More... | |
~Octree () | |
Destroy the tree. | |
const MatType & | Dataset () const |
Return the dataset used by this node. | |
Octree * | Parent () const |
Get the pointer to the parent. | |
Octree *& | Parent () |
Modify the pointer to the parent (be careful!). | |
const bound::HRectBound< MetricType > & | Bound () const |
Return the bound object for this node. | |
bound::HRectBound< MetricType > & | Bound () |
Modify the bound object for this node. | |
const StatisticType & | Stat () const |
Return the statistic object for this node. | |
StatisticType & | Stat () |
Modify the statistic object for this node. | |
size_t | NumChildren () const |
Return the number of children in this node. | |
MetricType | Metric () const |
Return the metric that this tree uses. | |
template<typename VecType > | |
size_t | GetNearestChild (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const |
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) const |
Return the index of the furthest child node to the given query point. More... | |
bool | IsLeaf () const |
Return whether or not the node is a leaf. | |
size_t | GetNearestChild (const Octree &queryNode) const |
Return the index of the nearest child node to the given query node. More... | |
size_t | GetFurthestChild (const Octree &queryNode) const |
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. | |
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... | |
const Octree & | Child (const size_t child) const |
Return the specified child. More... | |
Octree & | Child (const size_t child) |
Return the specified child. More... | |
Octree *& | ChildPtr (const size_t child) |
Return the pointer to the given child. More... | |
size_t | NumPoints () const |
Return the number of points in this node (0 if not a leaf). | |
size_t | NumDescendants () const |
Return the number of descendants of this node. | |
size_t | Descendant (const size_t index) const |
Return the index (with reference to the dataset) of a particular descendant. | |
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 Octree &other) const |
Return the minimum distance to another node. | |
ElemType | MaxDistance (const Octree &other) const |
Return the maximum distance to another node. | |
math::RangeType< ElemType > | RangeDistance (const Octree &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 the given point. | |
template<typename VecType > | |
ElemType | MaxDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const |
Return the maximum distance to the given point. | |
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 node. | |
void | Center (arma::vec ¢er) const |
Store the center of the bounding region in the given vector. | |
template<typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the tree. | |
template<typename VecType > | |
math::RangeType< typename Octree< MetricType, StatisticType, MatType >::ElemType > | RangeDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *) const |
Protected Member Functions | |
Octree () | |
A default constructor. More... | |
Friends | |
class | cereal::access |
Friend access is given for the default constructor. | |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | const MatType & | data, |
const size_t | maxLeafSize = 20 |
||
) |
Construct this as the root node of an octree on the given dataset.
Construct the tree.
This copies the dataset. If you don't want to copy the input dataset, consider using the constructor that takes an rvalue reference and use std::move().
data | Dataset to create tree from. This will be copied! |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | const MatType & | data, |
std::vector< size_t > & | oldFromNew, | ||
const size_t | maxLeafSize = 20 |
||
) |
Construct this as the root node of an octree on the given dataset.
Construct the tree.
This copies the dataset and modifies 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().
data | Dataset to create tree from. This will be copied! |
oldFromNew | Vector which will be filled with the old positions for each new point. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | 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 an octree on the given dataset.
Construct the tree.
This copies the dataset and modifies its ordering; a mapping of the old point indices to the new point indices is filled, and a mapping of the new point indices to the old 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().
data | Dataset to create tree from. This will be copied! |
oldFromNew | Vector which will be filled with the old positions for each new point. |
newFromOld | Vector which will be filled with the new positions for each old point. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | MatType && | data, |
const size_t | maxLeafSize = 20 |
||
) |
Construct this as the root node of an octree on the given dataset.
Construct the tree.
This will take ownership of the dataset; if you don't want this, consider using the constructor that takes a const reference to the dataset.
data | Dataset to create tree from. This will be copied! |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | MatType && | data, |
std::vector< size_t > & | oldFromNew, | ||
const size_t | maxLeafSize = 20 |
||
) |
Construct this as the root node of an octree on the given dataset.
Construct the tree.
This will take ownership of the dataset; if you don't want this, consider using the constructor that takes a const reference to the dataset. This modifies the ordering of the dataset; a mapping of the old point indices to the new point indices is filled.
data | Dataset to create tree from. This will be copied! |
oldFromNew | Vector which will be filled with the old positions for each new point. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | MatType && | data, |
std::vector< size_t > & | oldFromNew, | ||
std::vector< size_t > & | newFromOld, | ||
const size_t | maxLeafSize = 20 |
||
) |
Construct this as the root node of an octree on the given dataset.
Construct the tree.
This will take ownership of the dataset; if you don't want this, consider using the constructor that takes a const reference to the dataset. This modifies the ordering of the dataset; a mapping of the old point indices to the new point indices is filled, and a mapping of the new point indices to the old point indices is filled.
data | Dataset to create tree from. This will be copied! |
oldFromNew | Vector which will be filled with the old positions for each new point. |
newFromOld | Vector which will be filled with the new positions for each old point. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | Octree< MetricType, StatisticType, MatType > * | parent, |
const size_t | begin, | ||
const size_t | count, | ||
const arma::vec & | center, | ||
const double | width, | ||
const size_t | maxLeafSize = 20 |
||
) |
Construct this node as a child of the given parent, starting at column begin and using count points.
Construct a child node.
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 that don't specify point indices.
parent | Parent of this node. Its dataset will be modified! |
begin | Index of point to start tree construction with. |
count | Number of points to use to construct tree. |
center | Center of the node (for splitting). |
width | Width of the node in each dimension. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | Octree< MetricType, StatisticType, MatType > * | parent, |
const size_t | begin, | ||
const size_t | count, | ||
std::vector< size_t > & | oldFromNew, | ||
const arma::vec & | center, | ||
const double | width, | ||
const size_t | maxLeafSize = 20 |
||
) |
Construct this node as a child of the given parent, starting at column begin and using count points.
Construct a child node.
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 that 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.
parent | Parent of this node. Its dataset will be modified! |
begin | Index of point to start tree construction with. |
count | Number of points to use to construct tree. |
oldFromNew | Vector which will be filled with the old positions for each new point. |
center | Center of the node (for splitting). |
width | Width of the node in each dimension. |
maxLeafSize | Maximum number of points in a leaf node. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | const Octree< MetricType, StatisticType, MatType > & | other | ) |
Copy the given tree.
Be careful! This may use a lot of memory.
other | Tree to copy from. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | Octree< MetricType, StatisticType, MatType > && | other | ) |
Move the given tree.
The tree passed as a parameter will be emptied and will not be usable after this call.
other | Tree to move. |
mlpack::tree::Octree< MetricType, StatisticType, MatType >::Octree | ( | Archive & | ar, |
const typename std::enable_if_t< cereal::is_loading< Archive >()> * | = 0 |
||
) |
Initialize the tree from a cereal archive.
ar | Archive to load tree from. Must be an iarchive, not an oarchive. |
|
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 treee! The method must be protected, so that the serialization shim can work with the default constructor.
|
inline |
Return the specified child.
If the index is out of bounds, unspecified behavior will occur.
|
inline |
Return the specified child.
If the index is out of bounds, unspecified behavior will occur.
|
inline |
Return the pointer to the given child.
This allows the child itself to be modified.
Octree< MetricType, StatisticType, MatType >::ElemType mlpack::tree::Octree< MetricType, StatisticType, MatType >::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).
Octree< MetricType, StatisticType, MatType >::ElemType mlpack::tree::Octree< MetricType, StatisticType, MatType >::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.
size_t mlpack::tree::Octree< MetricType, StatisticType, MatType >::GetFurthestChild | ( | const VecType & | point, |
typename std::enable_if_t< IsVector< VecType >::value > * | = 0 |
||
) | const |
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).
size_t mlpack::tree::Octree< MetricType, StatisticType, MatType >::GetFurthestChild | ( | const Octree< MetricType, StatisticType, MatType > & | queryNode | ) | const |
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::Octree< MetricType, StatisticType, MatType >::GetNearestChild | ( | const VecType & | point, |
typename std::enable_if_t< IsVector< VecType >::value > * | = 0 |
||
) | const |
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).
size_t mlpack::tree::Octree< MetricType, StatisticType, MatType >::GetNearestChild | ( | const Octree< MetricType, StatisticType, MatType > & | queryNode | ) | const |
Return the index of the nearest child node to the given query node.
If it can't decide, it will return NumChildren() (invalid index).
Octree< MetricType, StatisticType, MatType > & mlpack::tree::Octree< MetricType, StatisticType, MatType >::operator= | ( | const Octree< MetricType, StatisticType, MatType > & | other | ) |
Copy the given Octree.
Copy assignment operator: copy the given other tree.
other | The tree to be copied. |
Octree< MetricType, StatisticType, MatType > & mlpack::tree::Octree< MetricType, StatisticType, MatType >::operator= | ( | Octree< MetricType, StatisticType, MatType > && | other | ) |
Take ownership of the given Octree.
Move assignment operator: take ownership of the given tree.
other | The tree to take ownership of. |
|
inline |
Return the distance from the center of this node to the center of the parent node.
|
inline |
Modify the distance from the center of this node to the center of the parent node.
size_t mlpack::tree::Octree< MetricType, StatisticType, MatType >::Point | ( | const size_t | index | ) | const |
Return the index (with reference to the dataset) of a particular point in this node.
If the given index is invalid (i.e. if it is greater than NumPoints()), the indices returned will be invalid.