MLPACK  1.0.7
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 
37 template<typename VecType = arma::vec>
38 class BallBound
39 {
40  public:
41  typedef VecType Vec;
42 
43  private:
44  double radius;
45  VecType center;
46 
47  public:
48  BallBound() : radius(0) { }
49 
55  BallBound(const size_t dimension) : radius(0), center(dimension) { }
56 
63  BallBound(const double radius, const VecType& center) :
64  radius(radius), center(center) { }
65 
67  double Radius() const { return radius; }
69  double& Radius() { return radius; }
70 
72  const VecType& Center() const { return center; }
74  VecType& Center() { return center; }
75 
76  // Get the range in a certain dimension.
77  math::Range operator[](const size_t i) const;
78 
82  bool Contains(const VecType& point) const;
83 
91  void CalculateMidpoint(VecType& centroid) const;
92 
96  double MinDistance(const VecType& point) const;
97 
101  double MinDistance(const BallBound& other) const;
102 
106  double MaxDistance(const VecType& point) const;
107 
111  double MaxDistance(const BallBound& other) const;
112 
116  math::Range RangeDistance(const VecType& other) const;
117 
123  math::Range RangeDistance(const BallBound& other) const;
124 
128  const BallBound& operator|=(const BallBound& other);
129 
138  template<typename MatType>
139  const BallBound& operator|=(const MatType& data);
140 
144  std::string ToString() const;
145 
146 };
147 
148 }; // namespace bound
149 }; // namespace mlpack
150 
151 #include "ballbound_impl.hpp"
152 
153 #endif // __MLPACK_CORE_TREE_DBALLBOUND_HPP
VecType & Center()
Modify the center point of the ball.
Definition: ballbound.hpp:74
BallBound(const double radius, const VecType &center)
Create the ball bound with the specified radius and center.
Definition: ballbound.hpp:63
math::Range operator[](const size_t i) const
double Radius() const
Get the radius of the ball.
Definition: ballbound.hpp:67
BallBound(const size_t dimension)
Create the ball bound with the specified dimensionality.
Definition: ballbound.hpp:55
double MinDistance(const VecType &point) const
Calculates minimum bound-to-point squared distance.
const BallBound & operator|=(const BallBound &other)
Expand the bound to include the given node.
Ball bound that works in the regular Euclidean metric space.
Definition: ballbound.hpp:38
double & Radius()
Modify the radius of the ball.
Definition: ballbound.hpp:69
const VecType & Center() const
Get the center point of the ball.
Definition: ballbound.hpp:72
bool Contains(const VecType &point) const
Determines if a point is within this bound.
double MaxDistance(const VecType &point) const
Computes maximum distance.
math::Range RangeDistance(const VecType &other) const
Calculates minimum and maximum bound-to-point distance.
std::string ToString() const
Returns a string representation of this object.
void CalculateMidpoint(VecType &centroid) const
Gets the center.
Simple real-valued range.
Definition: range.hpp:31