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

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

Inheritance diagram for mlpack::bound::HRectBound< MetricType >:
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::vec &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...
 
double 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 >
double MaxDistance (const VecType &point, typename boost::enable_if< IsVector< VecType > > *=0) const
 Calculates maximum bound-to-point squared distance. More...
 
double MaxDistance (const HRectBound &other) const
 Computes maximum distance. More...
 
template<typename VecType >
double MinDistance (const VecType &point, typename boost::enable_if< IsVector< VecType > > *=0) const
 Calculates minimum bound-to-point distance. More...
 
double MinDistance (const HRectBound &other) const
 Calculates minimum bound-to-bound distance. More...
 
double MinWidth () const
 Get the minimum width of the bound. More...
 
double & MinWidth ()
 Modify the minimum width of the bound. More...
 
HRectBoundoperator= (const HRectBound &other)
 Same as copy constructor; necessary to prevent memory leaks. More...
 
math::Rangeoperator[] (const size_t i)
 Get the range for a particular dimension. More...
 
const math::Rangeoperator[] (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...
 
math::Range RangeDistance (const HRectBound &other) const
 Calculates minimum and maximum bound-to-bound distance. More...
 
template<typename VecType >
math::Range RangeDistance (const VecType &point, typename boost::enable_if< IsVector< VecType > > *=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...
 
double Volume () const
 Calculate the volume of the hyperrectangle. More...
 

Private Attributes

math::Rangebounds
 The bounds for each dimension. More...
 
size_t dim
 The dimensionality of the bound. More...
 
double minWidth
 Cached minimum width of bound. More...
 

Detailed Description

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

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
PowerThe metric to use; use 2 for Euclidean (L2).
TakeRootWhether or not the root should be taken (see LMetric documentation).

Definition at line 56 of file hrectbound.hpp.

Constructor & Destructor Documentation

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

Empty constructor; creates a bound of dimensionality 0.

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

Initializes to specified dimensionality with each dimension the empty set.

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

Copy constructor; necessary to prevent memory leaks.

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

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

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

Destructor: clean up memory.

Member Function Documentation

template<typename MetricType = metric::LMetric<2, true>>
void mlpack::bound::HRectBound< MetricType >::Center ( arma::vec &  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 >::Center().

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

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

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

Determines if a point is within this bound.

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

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

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

Gets the dimensionality.

Definition at line 92 of file hrectbound.hpp.

template<typename MetricType = metric::LMetric<2, true>>
template<typename VecType >
double mlpack::bound::HRectBound< MetricType >::MaxDistance ( const VecType &  point,
typename boost::enable_if< IsVector< VecType > > *  = 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 >::MaxDistance().

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

Computes maximum distance.

Parameters
otherBound to which the maximum distance is requested.
template<typename MetricType = metric::LMetric<2, true>>
template<typename VecType >
double mlpack::bound::HRectBound< MetricType >::MinDistance ( const VecType &  point,
typename boost::enable_if< IsVector< VecType > > *  = 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 >::MinDistance().

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

Calculates minimum bound-to-bound distance.

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

Modify the minimum width of the bound.

Definition at line 103 of file hrectbound.hpp.

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

Same as copy constructor; necessary to prevent memory leaks.

template<typename MetricType = metric::LMetric<2, true>>
math::Range& mlpack::bound::HRectBound< MetricType >::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 96 of file hrectbound.hpp.

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

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

Definition at line 98 of file hrectbound.hpp.

template<typename MetricType = metric::LMetric<2, true>>
template<typename MatType >
HRectBound& mlpack::bound::HRectBound< MetricType >::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>>
HRectBound& mlpack::bound::HRectBound< MetricType >::operator|= ( const HRectBound< MetricType > &  other)

Expands this region to encompass another bound.

template<typename MetricType = metric::LMetric<2, true>>
math::Range mlpack::bound::HRectBound< MetricType >::RangeDistance ( const HRectBound< MetricType > &  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 >::RangeDistance().

template<typename MetricType = metric::LMetric<2, true>>
template<typename VecType >
math::Range mlpack::bound::HRectBound< MetricType >::RangeDistance ( const VecType &  point,
typename boost::enable_if< IsVector< VecType > > *  = 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>>
template<typename Archive >
void mlpack::bound::HRectBound< MetricType >::Serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize the bound object.

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

Calculate the volume of the hyperrectangle.

Returns
Volume of the hyperrectangle.

Member Data Documentation

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

The bounds for each dimension.

Definition at line 206 of file hrectbound.hpp.

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

The dimensionality of the bound.

Definition at line 204 of file hrectbound.hpp.

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

Cached minimum width of bound.

Definition at line 208 of file hrectbound.hpp.


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