00001 00024 #ifndef __MLPACK_CORE_TREE_HRECTBOUND_HPP 00025 #define __MLPACK_CORE_TREE_HRECTBOUND_HPP 00026 00027 #include <mlpack/core.hpp> 00028 #include <mlpack/core/math/range.hpp> 00029 #include <mlpack/core/metrics/lmetric.hpp> 00030 00031 namespace mlpack { 00032 namespace bound { 00033 00043 template<int Power = 2, bool TakeRoot = true> 00044 class HRectBound 00045 { 00046 public: 00048 typedef metric::LMetric<Power, TakeRoot> MetricType; 00049 00053 HRectBound(); 00054 00059 HRectBound(const size_t dimension); 00060 00062 HRectBound(const HRectBound& other); 00064 HRectBound& operator=(const HRectBound& other); 00065 00067 ~HRectBound(); 00068 00073 void Clear(); 00074 00076 size_t Dim() const { return dim; } 00077 00079 math::Range& operator[](const size_t i) { return bounds[i]; } 00081 const math::Range& operator[](const size_t i) const { return bounds[i]; } 00082 00088 void Centroid(arma::vec& centroid) const; 00089 00095 template<typename VecType> 00096 double MinDistance(const VecType& point) const; 00097 00103 double MinDistance(const HRectBound& other) const; 00104 00110 template<typename VecType> 00111 double MaxDistance(const VecType& point) const; 00112 00118 double MaxDistance(const HRectBound& other) const; 00119 00126 math::Range RangeDistance(const HRectBound& other) const; 00127 00134 template<typename VecType> 00135 math::Range RangeDistance(const VecType& point) const; 00136 00144 template<typename MatType> 00145 HRectBound& operator|=(const MatType& data); 00146 00150 HRectBound& operator|=(const HRectBound& other); 00151 00155 template<typename VecType> 00156 bool Contains(const VecType& point) const; 00157 00161 double Diameter() const; 00162 00166 std::string ToString() const; 00167 00173 static MetricType Metric() { return metric::LMetric<Power, TakeRoot>(); } 00174 00175 private: 00177 size_t dim; 00179 math::Range* bounds; 00180 }; 00181 00182 }; // namespace bound 00183 }; // namespace mlpack 00184 00185 #include "hrectbound_impl.hpp" 00186 00187 #endif // __MLPACK_CORE_TREE_HRECTBOUND_HPP