mlpack
Public Types | Public Member Functions | List of all members
mlpack::bound::HollowBallBound< TMetricType, ElemType > Class Template Reference

Hollow ball bound encloses a set of points at a specific distance (radius) from a specific point (center) except points at a specific distance from another point (the center of the hole). More...

#include <hollow_ball_bound.hpp>

Public Types

typedef TMetricType MetricType
 A public version of the metric type.
 

Public Member Functions

 HollowBallBound ()
 Empty Constructor.
 
 HollowBallBound (const size_t dimension)
 Create the ball bound with the specified dimensionality. More...
 
template<typename VecType >
 HollowBallBound (const ElemType innerRadius, const ElemType outerRadius, const VecType &center)
 Create the ball bound with the specified radius and center. More...
 
 HollowBallBound (const HollowBallBound &other)
 Copy constructor. To prevent memory leaks. More...
 
HollowBallBoundoperator= (const HollowBallBound &other)
 For the same reason as the copy constructor: to prevent memory leaks.
 
 HollowBallBound (HollowBallBound &&other)
 Move constructor: take possession of another bound. More...
 
HollowBallBoundoperator= (HollowBallBound &&other)
 Move assignment operator.
 
 ~HollowBallBound ()
 Destructor to release allocated memory.
 
ElemType OuterRadius () const
 Get the outer radius of the ball.
 
ElemType & OuterRadius ()
 Modify the outer radius of the ball.
 
ElemType InnerRadius () const
 Get the innner radius of the ball.
 
ElemType & InnerRadius ()
 Modify the inner radius of the ball.
 
const arma::Col< ElemType > & Center () const
 Get the center point of the ball.
 
arma::Col< ElemType > & Center ()
 Modify the center point of the ball.
 
const arma::Col< ElemType > & HollowCenter () const
 Get the center point of the hollow.
 
arma::Col< ElemType > & HollowCenter ()
 Modify the center point of the hollow.
 
size_t Dim () const
 Get the dimensionality of the ball.
 
ElemType MinWidth () const
 Get the minimum width of the bound (this is same as the diameter). More...
 
math::RangeType< ElemType > operator[] (const size_t i) const
 Get the range in a certain dimension.
 
template<typename VecType >
bool Contains (const VecType &point) const
 Determines if a point is within this bound. More...
 
bool Contains (const HollowBallBound &other) const
 Determines if another bound is within this bound. More...
 
template<typename VecType >
void Center (VecType &center) const
 Place the center of BallBound into the given vector. More...
 
template<typename VecType >
ElemType MinDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Calculates minimum bound-to-point squared distance. More...
 
ElemType MinDistance (const HollowBallBound &other) const
 Calculates minimum bound-to-bound squared distance. More...
 
template<typename VecType >
ElemType MaxDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Computes maximum distance. More...
 
ElemType MaxDistance (const HollowBallBound &other) const
 Computes maximum distance. More...
 
template<typename VecType >
math::RangeType< ElemType > RangeDistance (const VecType &other, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Calculates minimum and maximum bound-to-point distance. More...
 
math::RangeType< ElemType > RangeDistance (const HollowBallBound &other) const
 Calculates minimum and maximum bound-to-bound distance. More...
 
template<typename MatType >
const HollowBallBoundoperator|= (const MatType &data)
 Expand the bound to include the given point. More...
 
const HollowBallBoundoperator|= (const HollowBallBound &other)
 Expand the bound to include the given bound. More...
 
ElemType Diameter () const
 Returns the diameter of the ballbound.
 
const MetricTypeMetric () const
 Returns the distance metric used in this bound.
 
MetricTypeMetric ()
 Modify the distance metric used in this bound.
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t version)
 Serialize the bound. More...
 
template<typename MatType >
const HollowBallBound< TMetricType, ElemType > & operator|= (const MatType &data)
 Expand the bound to include the given point. More...
 

Detailed Description

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
class mlpack::bound::HollowBallBound< TMetricType, ElemType >

Hollow ball bound encloses a set of points at a specific distance (radius) from a specific point (center) except points at a specific distance from another point (the center of the hole).

MetricType is the custom metric type that defaults to the Euclidean (L2) distance.

Template Parameters
TMetricTypemetric type used in the distance measure.
ElemTypeType of element (float or double or similar).

Constructor & Destructor Documentation

◆ HollowBallBound() [1/4]

template<typename TMetricType , typename ElemType >
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( const size_t  dimension)

Create the ball bound with the specified dimensionality.

Create the hollow ball bound with the specified dimensionality.

Parameters
dimensionDimensionality of ball bound.

◆ HollowBallBound() [2/4]

template<typename TMetricType , typename ElemType >
template<typename VecType >
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( const ElemType  innerRadius,
const ElemType  outerRadius,
const VecType &  center 
)

Create the ball bound with the specified radius and center.

Create the hollow ball bound with the specified radii and center.

Parameters
innerRadiusInner radius of ball bound.
outerRadiusOuter radius of ball bound.
centerCenter of ball bound.
innerRadiusInner radius of hollow ball bound.
outerRadiusOuter radius of hollow ball bound.
centerCenter of hollow ball bound.

◆ HollowBallBound() [3/4]

template<typename TMetricType , typename ElemType >
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( const HollowBallBound< TMetricType, ElemType > &  other)

Copy constructor. To prevent memory leaks.

Copy Constructor. To prevent memory leaks.

◆ HollowBallBound() [4/4]

template<typename TMetricType , typename ElemType >
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( HollowBallBound< TMetricType, ElemType > &&  other)

Move constructor: take possession of another bound.

Move constructor.

Member Function Documentation

◆ Center()

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
void mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center ( VecType &  center) const
inline

Place the center of BallBound into the given vector.

Parameters
centerVector which the centroid will be written to.

◆ Contains() [1/2]

template<typename TMetricType , typename ElemType >
template<typename VecType >
bool mlpack::bound::HollowBallBound< TMetricType, ElemType >::Contains ( const VecType &  point) const

Determines if a point is within this bound.

Determines if a point is within the bound.

Parameters
pointPoint to check the condition.

◆ Contains() [2/2]

template<typename TMetricType , typename ElemType >
bool mlpack::bound::HollowBallBound< TMetricType, ElemType >::Contains ( const HollowBallBound< TMetricType, ElemType > &  other) const

Determines if another bound is within this bound.

Parameters
otherBound to check the condition.

◆ MaxDistance() [1/2]

template<typename TMetricType , typename ElemType >
template<typename VecType >
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::MaxDistance ( const VecType &  point,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Computes maximum distance.

Parameters
pointPoint to which the maximum distance is requested.

◆ MaxDistance() [2/2]

template<typename TMetricType , typename ElemType >
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::MaxDistance ( const HollowBallBound< TMetricType, ElemType > &  other) const

Computes maximum distance.

Parameters
otherBound to which the maximum distance is requested.

◆ MinDistance() [1/2]

template<typename TMetricType , typename ElemType >
template<typename VecType >
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::MinDistance ( const VecType &  point,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Calculates minimum bound-to-point squared distance.

Parameters
pointPoint to which the minimum distance is requested.

◆ MinDistance() [2/2]

template<typename TMetricType , typename ElemType >
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::MinDistance ( const HollowBallBound< TMetricType, ElemType > &  other) const

Calculates minimum bound-to-bound squared distance.

Parameters
otherBound to which the minimum distance is requested.

◆ MinWidth()

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::MinWidth ( ) const
inline

Get the minimum width of the bound (this is same as the diameter).

For ball bounds, width along all dimensions remain same.

◆ operator|=() [1/3]

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename MatType >
const HollowBallBound& mlpack::bound::HollowBallBound< TMetricType, ElemType >::operator|= ( const MatType &  data)

Expand the bound to include the given point.

The centroid will not be moved.

Template Parameters
MatTypeType of matrix; could be arma::mat, arma::spmat, or a vector.
dataData points to add.

◆ operator|=() [2/3]

template<typename TMetricType , typename ElemType >
const HollowBallBound< TMetricType, ElemType > & mlpack::bound::HollowBallBound< TMetricType, ElemType >::operator|= ( const HollowBallBound< TMetricType, ElemType > &  other)

Expand the bound to include the given bound.

The centroid will not be moved.

Template Parameters
MatTypeType of matrix; could be arma::mat, arma::spmat, or a vector.
dataData points to add.

◆ operator|=() [3/3]

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename MatType >
const HollowBallBound<TMetricType, ElemType>& mlpack::bound::HollowBallBound< TMetricType, ElemType >::operator|= ( const MatType &  data)

Expand the bound to include the given point.

Algorithm adapted from Jack Ritter, "An Efficient Bounding Sphere" in Graphics Gems (1990). The difference lies in the way we initialize the ball bound. The way we expand the bound is same.

◆ RangeDistance() [1/2]

template<typename TMetricType , typename ElemType >
template<typename VecType >
math::RangeType< ElemType > mlpack::bound::HollowBallBound< TMetricType, ElemType >::RangeDistance ( const VecType &  point,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Calculates minimum and maximum bound-to-point distance.

Calculates minimum and maximum bound-to-bound squared distance.

Parameters
otherPoint to which the minimum and maximum distances are requested.

Example: bound1.MinDistanceSq(other) for minimum squared distance.

◆ RangeDistance() [2/2]

template<typename TMetricType , typename ElemType >
math::RangeType< ElemType > mlpack::bound::HollowBallBound< TMetricType, ElemType >::RangeDistance ( const HollowBallBound< TMetricType, ElemType > &  other) const

Calculates minimum and maximum bound-to-bound distance.

Example: bound1.MinDistanceSq(other) for minimum distance.

Parameters
otherBound to which the minimum and maximum distances are requested.

◆ serialize()

template<typename TMetricType , typename ElemType >
template<typename Archive >
void mlpack::bound::HollowBallBound< TMetricType, ElemType >::serialize ( Archive &  ar,
const uint32_t  version 
)

Serialize the bound.

Serialize the BallBound.


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