mlpack  master
Public Member Functions | Private Attributes | List of all members
mlpack::bound::HRectBound< MetricType, ElemType > Class Template Reference

Hyper-rectangle bound for an L-metric. More...

Inheritance diagram for mlpack::bound::HRectBound< MetricType, ElemType >:
Inheritance graph
[legend]

Public Member Functions

 HRectBound ()
 Empty constructor; creates a bound of dimensionality 0. More...
 
 HRectBound (const size_t dimension)
 Initializes to specified dimensionality with each dimension the empty set. More...
 
 HRectBound (const HRectBound &other)
 Copy constructor; necessary to prevent memory leaks. More...
 
 HRectBound (HRectBound &&other)
 Move constructor: take possession of another bound's information. More...
 
 ~HRectBound ()
 Destructor: clean up memory. More...
 
void Center (arma::Col< ElemType > &center) const
 Calculates the center of the range, placing it into the given vector. More...
 
void Clear ()
 Resets all dimensions to the empty set (so that this bound contains nothing). More...
 
template<typename VecType >
bool Contains (const VecType &point) const
 Determines if a point is within this bound. More...
 
bool Contains (const HRectBound &bound) const
 Determines if this bound partially contains a bound. More...
 
ElemType Diameter () const
 Returns the diameter of the hyperrectangle (that is, the longest diagonal). More...
 
size_t Dim () const
 Gets the dimensionality. More...
 
template<typename VecType >
ElemType MaxDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Calculates maximum bound-to-point squared distance. More...
 
ElemType MaxDistance (const HRectBound &other) const
 Computes maximum distance. More...
 
template<typename VecType >
ElemType MinDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
 Calculates minimum bound-to-point distance. More...
 
ElemType MinDistance (const HRectBound &other) const
 Calculates minimum bound-to-bound distance. More...
 
ElemType MinWidth () const
 Get the minimum width of the bound. More...
 
ElemType & MinWidth ()
 Modify the minimum width of the bound. More...
 
HRectBound operator& (const HRectBound &bound) const
 Returns the intersection of this bound and another. More...
 
HRectBoundoperator&= (const HRectBound &bound)
 Intersects this bound with another. More...
 
HRectBoundoperator= (const HRectBound &other)
 Same as copy constructor; necessary to prevent memory leaks. More...
 
math::RangeType< ElemType > & operator[] (const size_t i)
 Get the range for a particular dimension. More...
 
const math::RangeType< ElemType > & operator[] (const size_t i) const
 Modify the range for a particular dimension. No bounds checking. More...
 
template<typename MatType >
HRectBoundoperator|= (const MatType &data)
 Expands this region to include new points. More...
 
HRectBoundoperator|= (const HRectBound &other)
 Expands this region to encompass another bound. More...
 
ElemType Overlap (const HRectBound &bound) const
 Returns the volume of overlap of this bound and another. More...
 
math::RangeType< ElemType > RangeDistance (const HRectBound &other) const
 Calculates minimum and maximum bound-to-bound distance. More...
 
template<typename VecType >
math::RangeType< ElemType > RangeDistance (const VecType &point, typename std::enable_if_t< IsVector< VecType >::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 object. More...
 
ElemType Volume () const
 Calculate the volume of the hyperrectangle. More...
 

Private Attributes

math::RangeType< ElemType > * bounds
 The bounds for each dimension. More...
 
size_t dim
 The dimensionality of the bound. More...
 
ElemType minWidth
 Cached minimum width of bound. More...
 

Detailed Description

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

Hyper-rectangle bound for an L-metric.

This should be used in conjunction with the LMetric class. Be sure to use the same template parameters for LMetric as you do for HRectBound – otherwise odd results may occur.

Template Parameters
MetricTypeType of metric to use; must be of type LMetric.
ElemTypeElement type (double/float/int/etc.).

Definition at line 54 of file hrectbound.hpp.

Constructor & Destructor Documentation

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

Empty constructor; creates a bound of dimensionality 0.

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

Initializes to specified dimensionality with each dimension the empty set.

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

Copy constructor; necessary to prevent memory leaks.

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

Move constructor: take possession of another bound's information.

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

Destructor: clean up memory.

Member Function Documentation

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
void mlpack::bound::HRectBound< MetricType, ElemType >::Center ( arma::Col< ElemType > &  center) const

Calculates the center of the range, placing it into the given vector.

Parameters
centerVector which the center will be written to.

Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::Center(), and mlpack::tree::Octree< MetricType, StatisticType, MatType >::Center().

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
void mlpack::bound::HRectBound< MetricType, ElemType >::Clear ( )

Resets all dimensions to the empty set (so that this bound contains nothing).

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
bool mlpack::bound::HRectBound< MetricType, ElemType >::Contains ( const VecType &  point) const

Determines if a point is within this bound.

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

Determines if this bound partially contains a bound.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::Diameter ( ) const

Returns the diameter of the hyperrectangle (that is, the longest diagonal).

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

Gets the dimensionality.

Definition at line 90 of file hrectbound.hpp.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::MaxDistance ( const VecType &  point,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Calculates maximum bound-to-point squared distance.

Parameters
pointPoint to which the maximum distance is requested.

Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MaxDistance().

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

Computes maximum distance.

Parameters
otherBound to which the maximum distance is requested.
template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename VecType >
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::MinDistance ( const VecType &  point,
typename std::enable_if_t< IsVector< VecType >::value > *  = 0 
) const

Calculates minimum bound-to-point distance.

Parameters
pointPoint to which the minimum distance is requested.

Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::MinDistance().

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

Calculates minimum bound-to-bound distance.

Parameters
otherBound to which the minimum distance is requested.
template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::MinWidth ( ) const
inline
template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType& mlpack::bound::HRectBound< MetricType, ElemType >::MinWidth ( )
inline

Modify the minimum width of the bound.

Definition at line 102 of file hrectbound.hpp.

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

Returns the intersection of this bound and another.

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

Intersects this bound with another.

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

Same as copy constructor; necessary to prevent memory leaks.

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

Get the range for a particular dimension.

No bounds checking. Be careful: this may make MinWidth() invalid.

Definition at line 94 of file hrectbound.hpp.

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

Modify the range for a particular dimension. No bounds checking.

Definition at line 96 of file hrectbound.hpp.

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

Expands this region to include new points.

Template Parameters
MatTypeType of matrix; could be Mat, SpMat, a subview, or just a vector.
Parameters
dataData points to expand this region to include.
template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
HRectBound& mlpack::bound::HRectBound< MetricType, ElemType >::operator|= ( const HRectBound< MetricType, ElemType > &  other)

Expands this region to encompass another bound.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::Overlap ( const HRectBound< MetricType, ElemType > &  bound) const

Returns the volume of overlap of this bound and another.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
math::RangeType<ElemType> mlpack::bound::HRectBound< MetricType, ElemType >::RangeDistance ( const HRectBound< MetricType, ElemType > &  other) const

Calculates minimum and maximum bound-to-bound distance.

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

Referenced by mlpack::tree::RectangleTree< MetricType, StatisticType, MatType, SplitType, DescentType, AuxiliaryInformationType >::RangeDistance().

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

Calculates minimum and maximum bound-to-point distance.

Parameters
pointPoint to which the minimum and maximum distances are requested.
template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
template<typename Archive >
void mlpack::bound::HRectBound< MetricType, ElemType >::Serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize the bound object.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::Volume ( ) const

Calculate the volume of the hyperrectangle.

Returns
Volume of the hyperrectangle.

Member Data Documentation

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
math::RangeType<ElemType>* mlpack::bound::HRectBound< MetricType, ElemType >::bounds
private

The bounds for each dimension.

Definition at line 227 of file hrectbound.hpp.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
size_t mlpack::bound::HRectBound< MetricType, ElemType >::dim
private

The dimensionality of the bound.

Definition at line 225 of file hrectbound.hpp.

template<typename MetricType = metric::LMetric<2, true>, typename ElemType = double>
ElemType mlpack::bound::HRectBound< MetricType, ElemType >::minWidth
private

Cached minimum width of bound.

Definition at line 229 of file hrectbound.hpp.


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