14#ifndef MLPACK_CORE_TREE_HRECTBOUND_HPP
15#define MLPACK_CORE_TREE_HRECTBOUND_HPP
29template<
typename MetricType>
32 static const bool Value =
false;
36template<
int Power,
bool TakeRoot>
52template<
typename MetricType = metric::LMetric<2, true>,
53 typename ElemType =
double>
58 "HRectBound can only be used with the LMetric<> metric type.");
92 size_t Dim()
const {
return dim; }
107 const MetricType&
Metric()
const {
return metric; }
116 void Center(arma::Col<ElemType>& center)
const;
130 template<
typename VecType>
147 template<
typename VecType>
173 template<
typename VecType>
175 const VecType& point,
185 template<
typename MatType>
198 template<
typename VecType>
231 template<
typename Archive>
232 void serialize(Archive& ar,
const unsigned int version);
246template<
typename MetricType,
typename ElemType>
256#include "hrectbound_impl.hpp"
Hyper-rectangle bound for an L-metric.
HRectBound & operator&=(const HRectBound &bound)
Intersects this bound with another.
const math::RangeType< ElemType > & operator[](const size_t i) const
Modify the range for a particular dimension. No bounds checking.
math::RangeType< ElemType > & operator[](const size_t i)
Get the range for a particular dimension.
HRectBound()
Empty constructor; creates a bound of dimensionality 0.
HRectBound(const HRectBound &other)
Copy constructor; necessary to prevent memory leaks.
ElemType Overlap(const HRectBound &bound) const
Returns the volume of overlap of this bound and another.
const MetricType & Metric() const
Get the instantiated metric associated with the bound.
bool Contains(const VecType &point) const
Determines if a point is within this bound.
HRectBound & operator|=(const HRectBound &other)
Expands this region to encompass another bound.
HRectBound(HRectBound &&other)
Move constructor: take possession of another bound's information.
ElemType Diameter() const
Returns the diameter of the hyperrectangle (that is, the longest diagonal).
HRectBound(const size_t dimension)
Initializes to specified dimensionality with each dimension the empty set.
~HRectBound()
Destructor: clean up memory.
void serialize(Archive &ar, const unsigned int version)
Serialize the bound object.
HRectBound operator&(const HRectBound &bound) const
Returns the intersection of this bound and another.
ElemType MinDistance(const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
Calculates minimum bound-to-point distance.
size_t Dim() const
Gets the dimensionality.
HRectBound & operator|=(const MatType &data)
Expands this region to include new points.
MetricType & Metric()
Modify the instantiated metric associated with the bound.
void Clear()
Resets all dimensions to the empty set (so that this bound contains nothing).
ElemType & MinWidth()
Modify the minimum width of the bound.
HRectBound & operator=(const HRectBound &other)
Same as copy constructor; necessary to prevent memory leaks.
ElemType MinWidth() const
Get the minimum width of the bound.
ElemType Volume() const
Calculate the volume of the hyperrectangle.
void Center(arma::Col< ElemType > ¢er) const
Calculates the center of the range, placing it into the given vector.
bool Contains(const HRectBound &bound) const
Determines if this bound partially contains a bound.
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.
math::RangeType< ElemType > RangeDistance(const HRectBound &other) const
Calculates minimum and maximum bound-to-bound distance.
ElemType MaxDistance(const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0) const
Calculates maximum bound-to-point squared distance.
ElemType MinDistance(const HRectBound &other) const
Calculates minimum bound-to-bound distance.
ElemType MaxDistance(const HRectBound &other) const
Computes maximum distance.
Simple real-valued range.
Linear algebra utility functions, generally performed on matrices or vectors.
typename enable_if< B, T >::type enable_if_t
The core includes that mlpack expects; standard C++ includes and Armadillo.
Definition of the Range class, which represents a simple range with a lower and upper bound.
If value == true, then VecType is some sort of Armadillo vector or subview.
A class to obtain compile-time traits about BoundType classes.
static const bool HasTightBounds
If true, then the bounds for each dimension are tight.