mlpack  master
Public Types | Public Member Functions | Private Attributes | 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...

Public Types

typedef TMetricType MetricType
 A public version of the metric type. More...
 

Public Member Functions

 HollowBallBound ()
 Empty Constructor. More...
 
 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...
 
 HollowBallBound (HollowBallBound &&other)
 Move constructor: take possession of another bound. More...
 
 ~HollowBallBound ()
 Destructor to release allocated memory. More...
 
const arma::Col< ElemType > & Center () const
 Get the center point of the ball. More...
 
arma::Col< ElemType > & Center ()
 Modify the center point of the ball. More...
 
template<typename VecType >
void Center (VecType &center) const
 Place the center of BallBound into the given vector. More...
 
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...
 
ElemType Diameter () const
 Returns the diameter of the ballbound. More...
 
size_t Dim () const
 Get the dimensionality of the ball. More...
 
const arma::Col< ElemType > & HollowCenter () const
 Get the center point of the hollow. More...
 
arma::Col< ElemType > & HollowCenter ()
 Modify the center point of the hollow. More...
 
ElemType InnerRadius () const
 Get the innner radius of the ball. More...
 
ElemType & InnerRadius ()
 Modify the inner radius of the ball. 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...
 
const MetricTypeMetric () const
 Returns the distance metric used in this bound. More...
 
MetricTypeMetric ()
 Modify the distance metric used in this bound. 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...
 
ElemType MinWidth () const
 Get the minimum width of the bound (this is same as the diameter). More...
 
HollowBallBoundoperator= (const HollowBallBound &other)
 For the same reason as the copy constructor: to prevent memory leaks. More...
 
math::RangeType< ElemType > operator[] (const size_t i) const
 Get the range in a certain dimension. 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 OuterRadius () const
 Get the outer radius of the ball. More...
 
ElemType & OuterRadius ()
 Modify the outer radius of the ball. 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 Archive >
void Serialize (Archive &ar, const unsigned int version)
 Serialize the bound. More...
 

Private Attributes

arma::Col< ElemType > center
 The center of the ball bound. More...
 
arma::Col< ElemType > hollowCenter
 The center of the hollow. More...
 
MetricTypemetric
 The metric used in this bound. More...
 
bool ownsMetric
 To know whether this object allocated memory to the metric member variable. More...
 
math::RangeType< ElemType > radii
 The inner and the outer radii of the bound. 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).

Definition at line 33 of file hollow_ball_bound.hpp.

Member Typedef Documentation

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

A public version of the metric type.

Definition at line 37 of file hollow_ball_bound.hpp.

Constructor & Destructor Documentation

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

Empty Constructor.

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

Create the ball bound with the specified dimensionality.

Parameters
dimensionDimensionality of ball bound.
template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
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.

Parameters
innerRadiusInner radius of ball bound.
outerRadiusOuter radius of ball bound.
centerCenter of ball bound.
template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( const HollowBallBound< TMetricType, ElemType > &  other)

Copy constructor. To prevent memory leaks.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowBallBound ( HollowBallBound< TMetricType, ElemType > &&  other)

Move constructor: take possession of another bound.

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

Destructor to release allocated memory.

Member Function Documentation

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

Get the center point of the ball.

Definition at line 104 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::center.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
arma::Col<ElemType>& mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center ( )
inline

Modify the center point of the ball.

Definition at line 106 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::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
template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
bool mlpack::bound::HollowBallBound< TMetricType, ElemType >::Contains ( const VecType &  point) const

Determines if a point is within this bound.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::MinWidth().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
bool mlpack::bound::HollowBallBound< TMetricType, ElemType >::Contains ( const HollowBallBound< TMetricType, ElemType > &  other) const

Determines if another bound is within this bound.

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

Returns the diameter of the ballbound.

Definition at line 209 of file hollow_ball_bound.hpp.

References mlpack::math::RangeType< T >::Hi().

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

Get the dimensionality of the ball.

Definition at line 114 of file hollow_ball_bound.hpp.

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

Get the center point of the hollow.

Definition at line 109 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::hollowCenter.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
arma::Col<ElemType>& mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowCenter ( )
inline

Modify the center point of the hollow.

Definition at line 111 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::hollowCenter.

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

Get the innner radius of the ball.

Definition at line 99 of file hollow_ball_bound.hpp.

References mlpack::math::RangeType< T >::Lo().

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

Modify the inner radius of the ball.

Definition at line 101 of file hollow_ball_bound.hpp.

References mlpack::math::RangeType< T >::Lo().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
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.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center().

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

Computes maximum distance.

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

Returns the distance metric used in this bound.

Definition at line 212 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::metric.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
MetricType& mlpack::bound::HollowBallBound< TMetricType, ElemType >::Metric ( )
inline
template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
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.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center().

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

Calculates minimum bound-to-bound squared distance.

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.

Definition at line 120 of file hollow_ball_bound.hpp.

References mlpack::bound::HollowBallBound< TMetricType, ElemType >::Contains(), mlpack::math::RangeType< T >::Hi(), and mlpack::bound::HollowBallBound< TMetricType, ElemType >::operator[]().

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

For the same reason as the copy constructor: to prevent memory leaks.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
math::RangeType<ElemType> mlpack::bound::HollowBallBound< TMetricType, ElemType >::operator[] ( const size_t  i) const

Get the range in a certain dimension.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::MinWidth().

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.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
const HollowBallBound& 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.
template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HollowBallBound< TMetricType, ElemType >::OuterRadius ( ) const
inline

Get the outer radius of the ball.

Definition at line 94 of file hollow_ball_bound.hpp.

References mlpack::math::RangeType< T >::Hi().

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

Modify the outer radius of the ball.

Definition at line 96 of file hollow_ball_bound.hpp.

References mlpack::math::RangeType< T >::Hi().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
math::RangeType<ElemType> mlpack::bound::HollowBallBound< TMetricType, ElemType >::RangeDistance ( const VecType &  other,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Calculates minimum and maximum bound-to-point distance.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
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.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename Archive >
void mlpack::bound::HollowBallBound< TMetricType, ElemType >::Serialize ( Archive &  ar,
const unsigned int  version 
)

Member Data Documentation

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
arma::Col<ElemType> mlpack::bound::HollowBallBound< TMetricType, ElemType >::center
private

The center of the ball bound.

Definition at line 43 of file hollow_ball_bound.hpp.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Center().

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
arma::Col<ElemType> mlpack::bound::HollowBallBound< TMetricType, ElemType >::hollowCenter
private

The center of the hollow.

Definition at line 45 of file hollow_ball_bound.hpp.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::HollowCenter().

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

The metric used in this bound.

Definition at line 47 of file hollow_ball_bound.hpp.

Referenced by mlpack::bound::HollowBallBound< TMetricType, ElemType >::Metric().

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

To know whether this object allocated memory to the metric member variable.

This will be true except in the copy constructor and the overloaded assignment operator. We need this to know whether we should delete the metric member variable in the destructor.

Definition at line 55 of file hollow_ball_bound.hpp.

template<typename TMetricType = metric::LMetric<2, true>, typename ElemType = double>
math::RangeType<ElemType> mlpack::bound::HollowBallBound< TMetricType, ElemType >::radii
private

The inner and the outer radii of the bound.

Definition at line 41 of file hollow_ball_bound.hpp.


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