MLPACK  1.0.10
hrectbound.hpp
Go to the documentation of this file.
1 
24 #ifndef __MLPACK_CORE_TREE_HRECTBOUND_HPP
25 #define __MLPACK_CORE_TREE_HRECTBOUND_HPP
26 
27 #include <mlpack/core.hpp>
30 
31 namespace mlpack {
32 namespace bound {
33 
43 template<int Power = 2, bool TakeRoot = true>
45 {
46  public:
49 
53  HRectBound();
54 
59  HRectBound(const size_t dimension);
60 
62  HRectBound(const HRectBound& other);
64  HRectBound& operator=(const HRectBound& other);
65 
67  ~HRectBound();
68 
73  void Clear();
74 
76  size_t Dim() const { return dim; }
77 
80  math::Range& operator[](const size_t i) { return bounds[i]; }
82  const math::Range& operator[](const size_t i) const { return bounds[i]; }
83 
85  double MinWidth() const { return minWidth; }
87  double& MinWidth() { return minWidth; }
88 
94  void Centroid(arma::vec& centroid) const;
95 
101  template<typename VecType>
102  double MinDistance(const VecType& point,
103  typename boost::enable_if<IsVector<VecType> >* = 0) const;
104 
110  double MinDistance(const HRectBound& other) const;
111 
117  template<typename VecType>
118  double MaxDistance(const VecType& point,
119  typename boost::enable_if<IsVector<VecType> >* = 0) const;
120 
126  double MaxDistance(const HRectBound& other) const;
127 
134  math::Range RangeDistance(const HRectBound& other) const;
135 
142  template<typename VecType>
143  math::Range RangeDistance(const VecType& point,
144  typename boost::enable_if<IsVector<VecType> >* = 0)
145  const;
146 
154  template<typename MatType>
155  HRectBound& operator|=(const MatType& data);
156 
160  HRectBound& operator|=(const HRectBound& other);
161 
165  template<typename VecType>
166  bool Contains(const VecType& point) const;
167 
171  double Diameter() const;
172 
176  std::string ToString() const;
177 
183  static MetricType Metric() { return metric::LMetric<Power, TakeRoot>(); }
184 
185  private:
187  size_t dim;
191  double minWidth;
192 };
193 
194 }; // namespace bound
195 }; // namespace mlpack
196 
197 #include "hrectbound_impl.hpp"
198 
199 #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:31
double minWidth
Cached minimum width of bound.
Definition: hrectbound.hpp:191
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:82
double & MinWidth()
Modify the minimum width of the bound.
Definition: hrectbound.hpp:87
Hyper-rectangle bound for an L-metric.
Definition: hrectbound.hpp:44
metric::LMetric< Power, TakeRoot > MetricType
This is the metric type that this bound is using.
Definition: hrectbound.hpp:48
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:187
math::Range * bounds
The bounds for each dimension.
Definition: hrectbound.hpp:189
double MinWidth() const
Get the minimum width of the bound.
Definition: hrectbound.hpp:85
The L_p metric for arbitrary integer p, with an option to take the root.
Definition: lmetric.hpp:73
static MetricType Metric()
Return the metric associated with this bound.
Definition: hrectbound.hpp:183
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:76
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:80
If value == true, then VecType is some sort of Armadillo vector or subview.
Definition: arma_traits.hpp:45
Simple real-valued range.
Definition: range.hpp:31