MLPACK  1.0.11
ballbound.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_CORE_TREE_BALLBOUND_HPP
24 #define __MLPACK_CORE_TREE_BALLBOUND_HPP
25 
26 #include <mlpack/core.hpp>
28 
29 namespace mlpack {
30 namespace bound {
31 
40 template<typename VecType = arma::vec,
41  typename TMetricType = metric::LMetric<2, true> >
42 class BallBound
43 {
44  public:
45  typedef VecType Vec;
47  typedef TMetricType MetricType;
48 
49  private:
50 
52  double radius;
53 
55  VecType center;
56 
58  TMetricType* metric;
59 
66  bool ownsMetric;
67 
68  public:
69 
71  BallBound();
72 
78  BallBound(const size_t dimension);
79 
86  BallBound(const double radius, const VecType& center);
87 
89  BallBound(const BallBound& other);
90 
92  BallBound& operator=(const BallBound& other);
93 
95  ~BallBound();
96 
98  double Radius() const { return radius; }
100  double& Radius() { return radius; }
101 
103  const VecType& Center() const { return center; }
105  VecType& Center() { return center; }
106 
108  double Dim() const { return center.n_elem; }
109 
114  double MinWidth() const { return radius * 2.0; }
115 
117  math::Range operator[](const size_t i) const;
118 
122  bool Contains(const VecType& point) const;
123 
129  void Centroid(VecType& centroid) const { centroid = center; }
130 
134  template<typename OtherVecType>
135  double MinDistance(const OtherVecType& point,
136  typename boost::enable_if<IsVector<OtherVecType> >* = 0)
137  const;
138 
142  double MinDistance(const BallBound& other) const;
143 
147  template<typename OtherVecType>
148  double MaxDistance(const OtherVecType& point,
149  typename boost::enable_if<IsVector<OtherVecType> >* = 0)
150  const;
151 
155  double MaxDistance(const BallBound& other) const;
156 
160  template<typename OtherVecType>
162  const OtherVecType& other,
163  typename boost::enable_if<IsVector<OtherVecType> >* = 0) const;
164 
170  math::Range RangeDistance(const BallBound& other) const;
171 
175  const BallBound& operator|=(const BallBound& other);
176 
185  template<typename MatType>
186  const BallBound& operator|=(const MatType& data);
187 
191  double Diameter() const { return 2 * radius; }
192 
196  TMetricType Metric() const { return *metric; }
197 
201  std::string ToString() const;
202 
203 };
204 
205 }; // namespace bound
206 }; // namespace mlpack
207 
208 #include "ballbound_impl.hpp"
209 
210 #endif // __MLPACK_CORE_TREE_DBALLBOUND_HPP