mlpack 3.4.2
Public Types | Public Member Functions | List of all members
BallBound< MetricType, VecType > Class Template Reference

Ball bound encloses a set of points at a specific distance (radius) from a specific point (center). More...

#include <ballbound.hpp>

Public Types

typedef VecType::elem_type ElemType
 The underlying data type. More...
 
typedef VecType Vec
 A public version of the vector type. More...
 

Public Member Functions

 BallBound ()
 Empty Constructor. More...
 
 BallBound (BallBound &&other)
 Move constructor: take possession of another bound. More...
 
 BallBound (const BallBound &other)
 Copy constructor. To prevent memory leaks. More...
 
 BallBound (const ElemType radius, const VecType &center)
 Create the ball bound with the specified radius and center. More...
 
 BallBound (const size_t dimension)
 Create the ball bound with the specified dimensionality. More...
 
 ~BallBound ()
 Destructor to release allocated memory. More...
 
VecType & Center ()
 Modify the center point of the ball. More...
 
const VecType & Center () const
 Get the center point of the ball. More...
 
void Center (VecType &center) const
 Place the center of BallBound into the given vector. More...
 
bool Contains (const VecType &point) const
 Determines if a point 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...
 
ElemType MaxDistance (const BallBound &other) const
 Computes maximum distance. More...
 
template<typename OtherVecType >
ElemType MaxDistance (const OtherVecType &point, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
 Computes maximum distance. More...
 
MetricType & Metric ()
 Modify the distance metric used in this bound. More...
 
const MetricType & Metric () const
 Returns the distance metric used in this bound. More...
 
ElemType MinDistance (const BallBound &other) const
 Calculates minimum bound-to-bound squared distance. More...
 
template<typename OtherVecType >
ElemType MinDistance (const OtherVecType &point, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
 Calculates minimum bound-to-point squared distance. More...
 
ElemType MinWidth () const
 Get the minimum width of the bound (this is same as the diameter). More...
 
BallBoundoperator= (const BallBound &other)
 For the same reason as the copy constructor: to prevent memory leaks. More...
 
math::RangeType< ElemTypeoperator[] (const size_t i) const
 Get the range in a certain dimension. More...
 
const BallBoundoperator|= (const BallBound &other)
 Expand the bound to include the given node. More...
 
template<typename MatType >
const BallBoundoperator|= (const MatType &data)
 Expand the bound to include the given point. More...
 
ElemTypeRadius ()
 Modify the radius of the ball. More...
 
ElemType Radius () const
 Get the radius of the ball. More...
 
math::RangeType< ElemTypeRangeDistance (const BallBound &other) const
 Calculates minimum and maximum bound-to-bound distance. More...
 
template<typename OtherVecType >
math::RangeType< ElemTypeRangeDistance (const OtherVecType &other, typename std::enable_if_t< IsVector< OtherVecType >::value > *=0) const
 Calculates minimum and maximum bound-to-point distance. More...
 
template<typename Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize the bound. More...
 

Detailed Description

template<typename MetricType = metric::LMetric<2, true>, typename VecType = arma::vec>
class mlpack::bound::BallBound< MetricType, VecType >

Ball bound encloses a set of points at a specific distance (radius) from a specific point (center).

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

Template Parameters
MetricTypemetric type used in the distance measure.
VecTypeType of vector (arma::vec or arma::sp_vec or similar).

Definition at line 32 of file ballbound.hpp.

Member Typedef Documentation

◆ ElemType

typedef VecType::elem_type ElemType

The underlying data type.

Definition at line 36 of file ballbound.hpp.

◆ Vec

typedef VecType Vec

A public version of the vector type.

Definition at line 38 of file ballbound.hpp.

Constructor & Destructor Documentation

◆ BallBound() [1/5]

BallBound ( )

Empty Constructor.

◆ BallBound() [2/5]

BallBound ( const size_t  dimension)

Create the ball bound with the specified dimensionality.

Parameters
dimensionDimensionality of ball bound.

◆ BallBound() [3/5]

BallBound ( const ElemType  radius,
const VecType &  center 
)

Create the ball bound with the specified radius and center.

Parameters
radiusRadius of ball bound.
centerCenter of ball bound.

◆ BallBound() [4/5]

BallBound ( const BallBound< MetricType, VecType > &  other)

Copy constructor. To prevent memory leaks.

◆ BallBound() [5/5]

BallBound ( BallBound< MetricType, VecType > &&  other)

Move constructor: take possession of another bound.

◆ ~BallBound()

~BallBound ( )

Destructor to release allocated memory.

Member Function Documentation

◆ Center() [1/3]

VecType & Center ( )
inline

Modify the center point of the ball.

Definition at line 95 of file ballbound.hpp.

◆ Center() [2/3]

const VecType & Center ( ) const
inline

Get the center point of the ball.

Definition at line 93 of file ballbound.hpp.

Referenced by ProjVector::Project().

◆ Center() [3/3]

void Center ( VecType &  center) const
inline

Place the center of BallBound into the given vector.

Parameters
centerVector which the centroid will be written to.

Definition at line 121 of file ballbound.hpp.

◆ Contains()

bool Contains ( const VecType &  point) const

Determines if a point is within this bound.

Parameters
pointPoint to check the condition.

◆ Diameter()

ElemType Diameter ( ) const
inline

Returns the diameter of the ballbound.

Definition at line 197 of file ballbound.hpp.

◆ Dim()

size_t Dim ( ) const
inline

Get the dimensionality of the ball.

Definition at line 98 of file ballbound.hpp.

◆ MaxDistance() [1/2]

ElemType MaxDistance ( const BallBound< MetricType, VecType > &  other) const

Computes maximum distance.

Parameters
otherBound to which the maximum distance is requested.

◆ MaxDistance() [2/2]

ElemType MaxDistance ( const OtherVecType &  point,
typename std::enable_if_t< IsVector< OtherVecType >::value > *  = 0 
) const

Computes maximum distance.

Parameters
pointPoint to which the maximum distance is requested.

◆ Metric() [1/2]

MetricType & Metric ( )
inline

Modify the distance metric used in this bound.

Definition at line 202 of file ballbound.hpp.

◆ Metric() [2/2]

const MetricType & Metric ( ) const
inline

Returns the distance metric used in this bound.

Definition at line 200 of file ballbound.hpp.

◆ MinDistance() [1/2]

ElemType MinDistance ( const BallBound< MetricType, VecType > &  other) const

Calculates minimum bound-to-bound squared distance.

Parameters
otherBound to which the minimum distance is requested.

◆ MinDistance() [2/2]

ElemType MinDistance ( const OtherVecType &  point,
typename std::enable_if_t< IsVector< OtherVecType >::value > *  = 0 
) const

Calculates minimum bound-to-point squared distance.

Parameters
pointPoint to which the minimum distance is requested.

◆ MinWidth()

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 104 of file ballbound.hpp.

◆ operator=()

BallBound & operator= ( const BallBound< MetricType, VecType > &  other)

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

◆ operator[]()

math::RangeType< ElemType > operator[] ( const size_t  i) const

Get the range in a certain dimension.

◆ operator|=() [1/2]

const BallBound & operator|= ( const BallBound< MetricType, VecType > &  other)

Expand the bound to include the given node.

◆ operator|=() [2/2]

const BallBound & operator|= ( const MatType &  data)

Expand the bound to include the given point.

The centroid is recalculated to be the center of all of the given points.

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

◆ Radius() [1/2]

ElemType & Radius ( )
inline

Modify the radius of the ball.

Definition at line 90 of file ballbound.hpp.

◆ Radius() [2/2]

ElemType Radius ( ) const
inline

Get the radius of the ball.

Definition at line 88 of file ballbound.hpp.

Referenced by ProjVector::Project().

◆ RangeDistance() [1/2]

math::RangeType< ElemType > RangeDistance ( const BallBound< MetricType, VecType > &  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.

◆ RangeDistance() [2/2]

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.

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

◆ serialize()

void serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize the bound.


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