---
name: "mlpack_bound_HRectBound"
section: "3"
platform: "linux"
package: "mlpack-doc"
version: "1.0.10-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/mlpack_bound_HRectBound"
---

# mlpack\_bound\_HRectBound(3)

Hyper-rectangle bound for an L-metric.

## NAME

mlpack::bound::HRectBound\< Power, TakeRoot \> -

Hyper-rectangle bound for an L-metric.

## SYNOPSIS

### Public Types

typedef **metric::LMetric**\< Power, \
 TakeRoot \> **MetricType**"\
 *This is the metric type that this bound is using.*

### Public Member Functions

**HRectBound** ()\
 *Empty constructor; creates a bound of dimensionality 0.*  **HRectBound** (const size\_t dimension)\
 *Initializes to specified dimensionality with each dimension the empty set.*  **HRectBound** (const **HRectBound** &other)\
 *Copy constructor; necessary to prevent memory leaks.*  **~HRectBound** ()\
 *Destructor: clean up memory.*  void **Centroid** (arma::vec &centroid) const \
 *Calculates the centroid of the range, placing it into the given vector.*  void **Clear** ()\
 *Resets all dimensions to the empty set (so that this bound contains nothing).*  template\<typename VecType \> bool **Contains** (const VecType &point) const \
 *Determines if a point is within this bound.*  double **Diameter** () const \
 *Returns the diameter of the hyperrectangle (that is, the longest diagonal).*  size\_t **Dim** () const \
 *Gets the dimensionality.*  template\<typename VecType \> double **MaxDistance** (const VecType &point, typename boost::enable\_if\< **IsVector**\< VecType \> \> \*=0) const \
 *Calculates maximum bound-to-point squared distance.*  double **MaxDistance** (const **HRectBound** &other) const \
 *Computes maximum distance.*  template\<typename VecType \> double **MinDistance** (const VecType &point, typename boost::enable\_if\< **IsVector**\< VecType \> \> \*=0) const \
 *Calculates minimum bound-to-point distance.*  double **MinDistance** (const **HRectBound** &other) const \
 *Calculates minimum bound-to-bound distance.*  double **MinWidth** () const \
 *Get the minimum width of the bound.*  double & **MinWidth** ()\
 *Modify the minimum width of the bound.*  **HRectBound** & **operator=** (const **HRectBound** &other)\
 *Same as copy constructor; necessary to prevent memory leaks.*  **math::Range** & **operator\[\]** (const size\_t i)\
 *Get the range for a particular dimension.*  const **math::Range** & **operator\[\]** (const size\_t i) const \
 *Modify the range for a particular dimension. No bounds checking.*  template\<typename MatType \> **HRectBound** & **operator\|=** (const MatType &data)\
 *Expands this region to include new points.*  **HRectBound** & **operator\|=** (const **HRectBound** &other)\
 *Expands this region to encompass another bound.*  **math::Range** **RangeDistance** (const **HRectBound** &other) const \
 *Calculates minimum and maximum bound-to-bound distance.*  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.*  std::string **ToString** () const \
 *Returns a string representation of this object.*

### Static Public Member Functions

static **MetricType** **Metric** ()\
 *Return the metric associated with this bound.*

### Private Attributes

**math::Range** \* **bounds**\
 *The bounds for each dimension.*  size\_t **dim**\
 *The dimensionality of the bound.*  double **minWidth**\
 *Cached minimum width of bound.*

## Detailed Description

### template\<int Power = 2, bool TakeRoot = true\>class mlpack::bound::HRectBound\< Power, TakeRoot \>

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:**

*Power* The metric to use; use 2 for Euclidean (L2). \
 *TakeRoot* Whether or not the root should be taken (see LMetric documentation).

Definition at line 44 of file hrectbound.hpp.

## Member Typedef Documentation

### template\<int Power = 2, bool TakeRoot = true\> typedef metric::LMetric\<Power, TakeRoot\> mlpack::bound::HRectBound\< Power, TakeRoot \>::MetricType

This is the metric type that this bound is using.

Definition at line 48 of file hrectbound.hpp.

## Constructor & Destructor Documentation

### template\<int Power = 2, bool TakeRoot = true\> mlpack::bound::HRectBound\< Power, TakeRoot \>::HRectBound ()

Empty constructor; creates a bound of dimensionality 0.

### template\<int Power = 2, bool TakeRoot = true\> mlpack::bound::HRectBound\< Power, TakeRoot \>::HRectBound (const size\_tdimension)

Initializes to specified dimensionality with each dimension the empty set.

### template\<int Power = 2, bool TakeRoot = true\> mlpack::bound::HRectBound\< Power, TakeRoot \>::HRectBound (const HRectBound\< Power, TakeRoot \> &other)

Copy constructor; necessary to prevent memory leaks.

### template\<int Power = 2, bool TakeRoot = true\> mlpack::bound::HRectBound\< Power, TakeRoot \>::~HRectBound ()

Destructor: clean up memory.

## Member Function Documentation

### template\<int Power = 2, bool TakeRoot = true\> void mlpack::bound::HRectBound\< Power, TakeRoot \>::Centroid (arma::vec &centroid) const

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

**Parameters:**

*centroid* Vector which the centroid will be written to.

### template\<int Power = 2, bool TakeRoot = true\> void mlpack::bound::HRectBound\< Power, TakeRoot \>::Clear ()

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

### template\<int Power = 2, bool TakeRoot = true\> template\<typename VecType \> bool mlpack::bound::HRectBound\< Power, TakeRoot \>::Contains (const VecType &point) const

Determines if a point is within this bound.

### template\<int Power = 2, bool TakeRoot = true\> double mlpack::bound::HRectBound\< Power, TakeRoot \>::Diameter () const

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

### template\<int Power = 2, bool TakeRoot = true\> size\_t mlpack::bound::HRectBound\< Power, TakeRoot \>::Dim () const` [inline]`

Gets the dimensionality.

Definition at line 76 of file hrectbound.hpp.

References mlpack::bound::HRectBound\< Power, TakeRoot \>::dim.

### template\<int Power = 2, bool TakeRoot = true\> template\<typename VecType \> double mlpack::bound::HRectBound\< Power, TakeRoot \>::MaxDistance (const VecType &point, typename boost::enable\_if\< IsVector\< VecType \> \> \* = `0`) const

Calculates maximum bound-to-point squared distance.

**Parameters:**

*point* Point to which the maximum distance is requested.

### template\<int Power = 2, bool TakeRoot = true\> double mlpack::bound::HRectBound\< Power, TakeRoot \>::MaxDistance (const HRectBound\< Power, TakeRoot \> &other) const

Computes maximum distance.

**Parameters:**

*other* Bound to which the maximum distance is requested.

### template\<int Power = 2, bool TakeRoot = true\> static MetricType mlpack::bound::HRectBound\< Power, TakeRoot \>::Metric ()` [inline]`, ` [static]`

Return the metric associated with this bound. Because it is an LMetric, it cannot store state, so we can make it on the fly. It is also static because the metric is only dependent on the template arguments.

Definition at line 183 of file hrectbound.hpp.

### template\<int Power = 2, bool TakeRoot = true\> template\<typename VecType \> double mlpack::bound::HRectBound\< Power, TakeRoot \>::MinDistance (const VecType &point, typename boost::enable\_if\< IsVector\< VecType \> \> \* = `0`) const

Calculates minimum bound-to-point distance.

**Parameters:**

*point* Point to which the minimum distance is requested.

### template\<int Power = 2, bool TakeRoot = true\> double mlpack::bound::HRectBound\< Power, TakeRoot \>::MinDistance (const HRectBound\< Power, TakeRoot \> &other) const

Calculates minimum bound-to-bound distance.

**Parameters:**

*other* Bound to which the minimum distance is requested.

### template\<int Power = 2, bool TakeRoot = true\> double mlpack::bound::HRectBound\< Power, TakeRoot \>::MinWidth () const` [inline]`

Get the minimum width of the bound.

Definition at line 85 of file hrectbound.hpp.

References mlpack::bound::HRectBound\< Power, TakeRoot \>::minWidth.

### template\<int Power = 2, bool TakeRoot = true\> double& mlpack::bound::HRectBound\< Power, TakeRoot \>::MinWidth ()` [inline]`

Modify the minimum width of the bound.

Definition at line 87 of file hrectbound.hpp.

References mlpack::bound::HRectBound\< Power, TakeRoot \>::minWidth.

### template\<int Power = 2, bool TakeRoot = true\> HRectBound& mlpack::bound::HRectBound\< Power, TakeRoot \>::operator= (const HRectBound\< Power, TakeRoot \> &other)

Same as copy constructor; necessary to prevent memory leaks.

### template\<int Power = 2, bool TakeRoot = true\> math::Range& mlpack::bound::HRectBound\< Power, TakeRoot \>::operator\[\] (const size\_ti)` [inline]`

Get the range for a particular dimension. No bounds checking. Be careful: this may make **MinWidth()** invalid.

Definition at line 80 of file hrectbound.hpp.

References mlpack::bound::HRectBound\< Power, TakeRoot \>::bounds.

### template\<int Power = 2, bool TakeRoot = true\> const math::Range& mlpack::bound::HRectBound\< Power, TakeRoot \>::operator\[\] (const size\_ti) const` [inline]`

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

Definition at line 82 of file hrectbound.hpp.

References mlpack::bound::HRectBound\< Power, TakeRoot \>::bounds.

### template\<int Power = 2, bool TakeRoot = true\> template\<typename MatType \> HRectBound& mlpack::bound::HRectBound\< Power, TakeRoot \>::operator\|= (const MatType &data)

Expands this region to include new points.

**Template Parameters:**

*MatType* Type of matrix; could be Mat, SpMat, a subview, or just a vector.

**Parameters:**

*data* Data points to expand this region to include.

### template\<int Power = 2, bool TakeRoot = true\> HRectBound& mlpack::bound::HRectBound\< Power, TakeRoot \>::operator\|= (const HRectBound\< Power, TakeRoot \> &other)

Expands this region to encompass another bound.

### template\<int Power = 2, bool TakeRoot = true\> math::Range mlpack::bound::HRectBound\< Power, TakeRoot \>::RangeDistance (const HRectBound\< Power, TakeRoot \> &other) const

Calculates minimum and maximum bound-to-bound distance.

**Parameters:**

*other* Bound to which the minimum and maximum distances are requested.

### template\<int Power = 2, bool TakeRoot = true\> template\<typename VecType \> math::Range mlpack::bound::HRectBound\< Power, TakeRoot \>::RangeDistance (const VecType &point, typename boost::enable\_if\< IsVector\< VecType \> \> \* = `0`) const

Calculates minimum and maximum bound-to-point distance.

**Parameters:**

*point* Point to which the minimum and maximum distances are requested.

### template\<int Power = 2, bool TakeRoot = true\> std::string mlpack::bound::HRectBound\< Power, TakeRoot \>::ToString () const

Returns a string representation of this object.

## Member Data Documentation

### template\<int Power = 2, bool TakeRoot = true\> math::Range\* mlpack::bound::HRectBound\< Power, TakeRoot \>::bounds` [private]`

The bounds for each dimension.

Definition at line 189 of file hrectbound.hpp.

Referenced by mlpack::bound::HRectBound\< Power, TakeRoot \>::operator\[\]().

### template\<int Power = 2, bool TakeRoot = true\> size\_t mlpack::bound::HRectBound\< Power, TakeRoot \>::dim` [private]`

The dimensionality of the bound.

Definition at line 187 of file hrectbound.hpp.

Referenced by mlpack::bound::HRectBound\< Power, TakeRoot \>::Dim().

### template\<int Power = 2, bool TakeRoot = true\> double mlpack::bound::HRectBound\< Power, TakeRoot \>::minWidth` [private]`

Cached minimum width of bound.

Definition at line 191 of file hrectbound.hpp.

Referenced by mlpack::bound::HRectBound\< Power, TakeRoot \>::MinWidth().

## Author

Generated automatically by Doxygen for MLPACK from the source code.
