14 #ifndef __MLPACK_CORE_TREE_COVER_TREE_COVER_TREE_HPP 15 #define __MLPACK_CORE_TREE_COVER_TREE_COVER_TREE_HPP 19 #include "../statistic.hpp" 94 template<
typename MetricType = metric::LMetric<2, true>,
95 typename StatisticType = EmptyStatistic,
96 typename MatType = arma::mat,
97 typename RootPo
intPolicy = FirstPo
intIsRoot>
114 const double base = 2.0,
115 MetricType*
metric = NULL);
128 const double base = 2.0);
138 const double base = 2.0);
150 const double base = 2.0);
185 const size_t pointIndex,
189 arma::Col<size_t>& indices,
190 arma::vec& distances,
194 MetricType&
metric = NULL);
214 const size_t pointIndex,
219 MetricType*
metric = NULL);
232 template<
typename Archive>
235 const typename boost::enable_if<typename Archive::is_loading>::type* = 0);
244 template<
typename RuleType>
248 template<
typename RuleType>
251 template<
typename RuleType>
313 double MinDistance(
const arma::vec& other,
const double distance)
const;
327 double MaxDistance(
const arma::vec& other,
const double distance)
const;
413 arma::vec& distances,
416 size_t& usedSetSize);
430 const arma::Col<size_t>& indices,
431 arma::vec& distances,
432 const size_t pointSetSize);
448 arma::vec& distances,
450 const size_t pointSetSize);
472 arma::vec& distances,
473 const size_t childFarSetSize,
474 const size_t childUsedSetSize,
475 const size_t farSetSize);
478 arma::vec& distances,
482 arma::Col<size_t>& childIndices,
483 const size_t childFarSetSize,
484 const size_t childUsedSetSize);
486 arma::vec& distances,
488 const size_t nearSetSize,
489 const size_t pointSetSize);
507 friend class boost::serialization::access;
513 template<
typename Archive>
514 void Serialize(Archive& ar,
const unsigned int );
527 #include "cover_tree_impl.hpp" 530 #include "../cover_tree.hpp" double MinimumBoundDistance() const
Get the minimum distance from the center to any bound edge (this is the same as furthestDescendantDis...
void Center(arma::vec ¢er) const
Get the center of the node and store it in the given vector.
size_t point
Index of the point in the matrix which this node represents.
const MatType * dataset
Reference to the matrix which this tree is built on.
const std::vector< CoverTree * > & Children() const
Get the children.
CoverTree()
A default constructor.
StatisticType & Stat()
Modify the statistic for this node.
std::vector< CoverTree * > & Children()
Modify the children manually (maybe not a great idea).
size_t SortPointSet(arma::Col< size_t > &indices, arma::vec &distances, const size_t childFarSetSize, const size_t childUsedSetSize, const size_t farSetSize)
Assuming that the list of indices and distances is sorted as [ childFarSet | childUsedSet | farSet | ...
double Base() const
Get the base.
size_t Point(const size_t) const
For compatibility with other trees; the argument is ignored.
MetricType * metric
The metric used for this tree.
size_t Descendant(const size_t index) const
Get the index of a particular descendant point.
A dual-tree cover tree traverser; see dual_tree_traverser.hpp.
StatisticType stat
The instantiated statistic.
const MatType & Dataset() const
Get a reference to the dataset.
void RemoveNewImplicitNodes()
Take a look at the last child (the most recently created one) and remove any implicit nodes that have...
double base
The base used to construct the tree.
double MaxDistance(const CoverTree *other) const
Return the maximum distance to another node.
Linear algebra utility functions, generally performed on matrices or vectors.
size_t NumDescendants() const
Get the number of descendant points.
double parentDistance
Distance to the parent.
double furthestDescendantDistance
Distance to the furthest descendant.
void ComputeDistances(const size_t pointIndex, const arma::Col< size_t > &indices, arma::vec &distances, const size_t pointSetSize)
Fill the vector of distances with the distances between the point specified by pointIndex and each po...
MetricType & Metric() const
Get the instantiated metric.
double FurthestPointDistance() const
Get the distance to the furthest point. This is always 0 for cover trees.
double ParentDistance() const
Get the distance to the parent.
void Serialize(Archive &ar, const unsigned int)
Serialize the tree.
double & ParentDistance()
Modify the distance to the parent.
CoverTree *& Parent()
Modify the parent node.
size_t NumChildren() const
Get the number of children.
Simple real-valued range.
int & Scale()
Modify the scale of this node. Be careful...
const StatisticType & Stat() const
Get the statistic for this node.
size_t PruneFarSet(arma::Col< size_t > &indices, arma::vec &distances, const double bound, const size_t nearSetSize, const size_t pointSetSize)
CoverTree * parent
The parent node (NULL if this is the root of the tree).
math::Range RangeDistance(const CoverTree *other) const
Return the minimum and maximum distance to another node.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
A single-tree cover tree traverser; see single_tree_traverser.hpp for implementation.
int scale
Scale level of the node.
std::vector< CoverTree * > children
The list of children; the first is the self-child.
double & Base()
Modify the base; don't do this, you'll break everything.
static bool HasSelfChildren()
Returns true: this tree does have self-children.
double & FurthestDescendantDistance()
Modify the distance from the center of the node to the furthest descendant.
double MinDistance(const CoverTree *other) const
Return the minimum distance to another node.
const CoverTree & Child(const size_t index) const
Get a particular child node.
size_t Point() const
Get the index of the point which this node represents.
size_t SplitNearFar(arma::Col< size_t > &indices, arma::vec &distances, const double bound, const size_t pointSetSize)
Split the given indices and distances into a near and a far set, returning the number of points in th...
size_t numDescendants
The number of descendant points.
bool localDataset
If true, we own the dataset and need to destroy it in the destructor.
size_t DistanceComps() const
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
void CreateChildren(arma::Col< size_t > &indices, arma::vec &distances, size_t nearSetSize, size_t &farSetSize, size_t &usedSetSize)
Create the children for this node.
CoverTree & Child(const size_t index)
Modify a particular child node.
double FurthestDescendantDistance() const
Get the distance from the center of the node to the furthest descendant.
CoverTree *& ChildPtr(const size_t index)
CoverTree * Parent() const
Get the parent node.
~CoverTree()
Delete this cover tree node and its children.
bool localMetric
Whether or not we need to destroy the metric in the destructor.
int Scale() const
Get the scale of this node.
void MoveToUsedSet(arma::Col< size_t > &indices, arma::vec &distances, size_t &nearSetSize, size_t &farSetSize, size_t &usedSetSize, arma::Col< size_t > &childIndices, const size_t childFarSetSize, const size_t childUsedSetSize)