12#ifndef MLPACK_CORE_TREE_BALLBOUND_HPP
13#define MLPACK_CORE_TREE_BALLBOUND_HPP
30template<
typename MetricType = metric::LMetric<2, true>,
31 typename VecType = arma::vec>
93 const VecType&
Center()
const {
return center; }
98 size_t Dim()
const {
return center.n_elem; }
121 void Center(VecType& center)
const { center = this->center; }
128 template<
typename OtherVecType>
130 const OtherVecType& point,
145 template<
typename OtherVecType>
147 const OtherVecType& point,
163 template<
typename OtherVecType>
165 const OtherVecType& other,
191 template<
typename MatType>
200 const MetricType&
Metric()
const {
return *metric; }
205 template<
typename Archive>
206 void serialize(Archive& ar,
const unsigned int version);
210template<
typename MetricType,
typename VecType>
220#include "ballbound_impl.hpp"
Ball bound encloses a set of points at a specific distance (radius) from a specific point (center).
ElemType Radius() const
Get the radius of the ball.
math::RangeType< ElemType > operator[](const size_t i) const
Get the range in a certain dimension.
ElemType MinDistance(const BallBound &other) const
Calculates minimum bound-to-bound squared distance.
~BallBound()
Destructor to release allocated memory.
const MetricType & Metric() const
Returns the distance metric used in this bound.
ElemType & Radius()
Modify the radius of the ball.
BallBound(const BallBound &other)
Copy constructor. To prevent memory leaks.
const VecType & Center() const
Get the center point of the ball.
ElemType Diameter() const
Returns the diameter of the ballbound.
void serialize(Archive &ar, const unsigned int version)
Serialize the bound.
BallBound()
Empty Constructor.
size_t Dim() const
Get the dimensionality of the ball.
void Center(VecType ¢er) const
Place the center of BallBound into the given vector.
bool Contains(const VecType &point) const
Determines if a point is within this bound.
math::RangeType< ElemType > RangeDistance(const OtherVecType &other, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
Calculates minimum and maximum bound-to-point distance.
BallBound(BallBound &&other)
Move constructor: take possession of another bound.
math::RangeType< ElemType > RangeDistance(const BallBound &other) const
Calculates minimum and maximum bound-to-bound distance.
MetricType & Metric()
Modify the distance metric used in this bound.
BallBound(const size_t dimension)
Create the ball bound with the specified dimensionality.
ElemType MinWidth() const
Get the minimum width of the bound (this is same as the diameter).
const BallBound & operator|=(const BallBound &other)
Expand the bound to include the given node.
ElemType MaxDistance(const OtherVecType &point, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
Computes maximum distance.
VecType::elem_type ElemType
The underlying data type.
BallBound & operator=(const BallBound &other)
For the same reason as the copy constructor: to prevent memory leaks.
ElemType MaxDistance(const BallBound &other) const
Computes maximum distance.
VecType & Center()
Modify the center point of the ball.
ElemType MinDistance(const OtherVecType &point, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
Calculates minimum bound-to-point squared distance.
BallBound(const ElemType radius, const VecType ¢er)
Create the ball bound with the specified radius and center.
VecType Vec
A public version of the vector type.
const BallBound & operator|=(const MatType &data)
Expand the bound to include the given point.
Simple real-valued range.
Linear algebra utility functions, generally performed on matrices or vectors.
typename enable_if< B, T >::type enable_if_t
The core includes that mlpack expects; standard C++ includes and Armadillo.
If value == true, then VecType is some sort of Armadillo vector or subview.
A class to obtain compile-time traits about BoundType classes.
static const bool HasTightBounds
If true, then the bounds for each dimension are tight.