mlpack  1.0.12
hrectbound.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_CORE_TREE_HRECTBOUND_HPP
17 #define __MLPACK_CORE_TREE_HRECTBOUND_HPP
18 
19 #include <mlpack/core.hpp>
22 
23 namespace mlpack {
24 namespace bound {
25 
35 template<int Power = 2, bool TakeRoot = true>
37 {
38  public:
41 
45  HRectBound();
46 
51  HRectBound(const size_t dimension);
52 
54  HRectBound(const HRectBound& other);
56  HRectBound& operator=(const HRectBound& other);
57 
59  ~HRectBound();
60 
65  void Clear();
66 
68  size_t Dim() const { return dim; }
69 
72  math::Range& operator[](const size_t i) { return bounds[i]; }
74  const math::Range& operator[](const size_t i) const { return bounds[i]; }
75 
77  double MinWidth() const { return minWidth; }
79  double& MinWidth() { return minWidth; }
80 
86  void Centroid(arma::vec& centroid) const;
87 
93  template<typename VecType>
94  double MinDistance(const VecType& point,
95  typename boost::enable_if<IsVector<VecType> >* = 0) const;
96 
102  double MinDistance(const HRectBound& other) const;
103 
109  template<typename VecType>
110  double MaxDistance(const VecType& point,
111  typename boost::enable_if<IsVector<VecType> >* = 0) const;
112 
118  double MaxDistance(const HRectBound& other) const;
119 
126  math::Range RangeDistance(const HRectBound& other) const;
127 
134  template<typename VecType>
135  math::Range RangeDistance(const VecType& point,
136  typename boost::enable_if<IsVector<VecType> >* = 0)
137  const;
138 
146  template<typename MatType>
147  HRectBound& operator|=(const MatType& data);
148 
152  HRectBound& operator|=(const HRectBound& other);
153 
157  template<typename VecType>
158  bool Contains(const VecType& point) const;
159 
163  double Diameter() const;
164 
168  std::string ToString() const;
169 
175  static MetricType Metric() { return metric::LMetric<Power, TakeRoot>(); }
176 
177  private:
179  size_t dim;
183  double minWidth;
184 };
185 
186 }; // namespace bound
187 }; // namespace mlpack
188 
189 #include "hrectbound_impl.hpp"
190 
191 #endif // __MLPACK_CORE_TREE_HRECTBOUND_HPP
HRectBound & operator=(const HRectBound &other)
Same as copy constructor; necessary to prevent memory leaks.
std::string ToString() const
Returns a string representation of this object.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
double minWidth
Cached minimum width of bound.
Definition: hrectbound.hpp:183
double MaxDistance(const VecType &point, typename boost::enable_if< IsVector< VecType > > *=0) const
Calculates maximum bound-to-point squared distance.
const math::Range & operator[](const size_t i) const
Modify the range for a particular dimension. No bounds checking.
Definition: hrectbound.hpp:74
double & MinWidth()
Modify the minimum width of the bound.
Definition: hrectbound.hpp:79
Hyper-rectangle bound for an L-metric.
Definition: hrectbound.hpp:36
metric::LMetric< Power, TakeRoot > MetricType
This is the metric type that this bound is using.
Definition: hrectbound.hpp:40
double MinDistance(const VecType &point, typename boost::enable_if< IsVector< VecType > > *=0) const
Calculates minimum bound-to-point distance.
HRectBound()
Empty constructor; creates a bound of dimensionality 0.
HRectBound & operator|=(const MatType &data)
Expands this region to include new points.
size_t dim
The dimensionality of the bound.
Definition: hrectbound.hpp:179
math::Range * bounds
The bounds for each dimension.
Definition: hrectbound.hpp:181
double MinWidth() const
Get the minimum width of the bound.
Definition: hrectbound.hpp:77
The L_p metric for arbitrary integer p, with an option to take the root.
Definition: lmetric.hpp:65
static MetricType Metric()
Return the metric associated with this bound.
Definition: hrectbound.hpp:175
math::Range RangeDistance(const HRectBound &other) const
Calculates minimum and maximum bound-to-bound distance.
void Clear()
Resets all dimensions to the empty set (so that this bound contains nothing).
double Diameter() const
Returns the diameter of the hyperrectangle (that is, the longest diagonal).
~HRectBound()
Destructor: clean up memory.
Definition of the Range class, which represents a simple range with a lower and upper bound...
bool Contains(const VecType &point) const
Determines if a point is within this bound.
size_t Dim() const
Gets the dimensionality.
Definition: hrectbound.hpp:68
void Centroid(arma::vec &centroid) const
Calculates the centroid of the range, placing it into the given vector.
math::Range & operator[](const size_t i)
Get the range for a particular dimension.
Definition: hrectbound.hpp:72
If value == true, then VecType is some sort of Armadillo vector or subview.
Definition: arma_traits.hpp:37
Simple real-valued range.
Definition: range.hpp:23