MLPACK  1.0.7
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 
79  math::Range& operator[](const size_t i) { return bounds[i]; }
81  const math::Range& operator[](const size_t i) const { return bounds[i]; }
82 
88  void Centroid(arma::vec& centroid) const;
89 
95  template<typename VecType>
96  double MinDistance(const VecType& point) const;
97 
103  double MinDistance(const HRectBound& other) const;
104 
110  template<typename VecType>
111  double MaxDistance(const VecType& point) 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) const;
136 
144  template<typename MatType>
145  HRectBound& operator|=(const MatType& data);
146 
150  HRectBound& operator|=(const HRectBound& other);
151 
155  template<typename VecType>
156  bool Contains(const VecType& point) const;
157 
161  double Diameter() const;
162 
166  std::string ToString() const;
167 
174 
175  private:
177  size_t dim;
180 };
181 
182 }; // namespace bound
183 }; // namespace mlpack
184 
185 #include "hrectbound_impl.hpp"
186 
187 #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.
const math::Range & operator[](const size_t i) const
Modify the range for a particular dimension. No bounds checking.
Definition: hrectbound.hpp:81
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
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:177
math::Range * bounds
The bounds for each dimension.
Definition: hrectbound.hpp:179
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:173
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.
double MaxDistance(const VecType &point) const
Calculates maximum bound-to-point squared distance.
math::Range & operator[](const size_t i)
Get the range for a particular dimension. No bounds checking.
Definition: hrectbound.hpp:79
double MinDistance(const VecType &point) const
Calculates minimum bound-to-point distance.
Simple real-valued range.
Definition: range.hpp:31