MLPACK
1.0.4
|
00001 00024 #ifndef __MLPACK_CORE_TREE_PERIODICHRECTBOUND_HPP 00025 #define __MLPACK_CORE_TREE_PERIODICHRECTBOUND_HPP 00026 00027 #include <mlpack/core.hpp> 00028 00029 namespace mlpack { 00030 namespace bound { 00031 00037 template<int t_pow = 2> 00038 class PeriodicHRectBound 00039 { 00040 public: 00044 PeriodicHRectBound(); 00045 00050 PeriodicHRectBound(arma::vec box); 00051 00052 /*** 00053 * Copy constructor and copy operator. These are necessary because we do our 00054 * own memory management. 00055 */ 00056 PeriodicHRectBound(const PeriodicHRectBound& other); 00057 PeriodicHRectBound& operator=(const PeriodicHRectBound& other); 00058 00062 ~PeriodicHRectBound(); 00063 00067 void SetBoxSize(arma::vec box); 00068 00072 const arma::vec& Box() const { return box; } 00073 00077 void Clear(); 00078 00080 size_t Dim() const { return dim; } 00081 00085 math::Range& operator[](size_t i); 00086 const math::Range operator[](size_t i) const; 00087 00088 /*** 00089 * Calculates the centroid of the range. This does not factor in periodic 00090 * coordinates, so the centroid may not necessarily be inside the given box. 00091 * 00092 * @param centroid Vector to write the centroid to. 00093 */ 00094 void Centroid(arma::vec& centroid) const; 00095 00100 double MinDistance(const arma::vec& point) const; 00101 00108 double MinDistance(const PeriodicHRectBound& other) const; 00109 00114 double MaxDistance(const arma::vec& point) const; 00115 00120 double MaxDistance(const PeriodicHRectBound& other) const; 00121 00126 math::Range RangeDistance(const arma::vec& point) const; 00127 00132 math::Range RangeDistance(const PeriodicHRectBound& other) const; 00133 00137 PeriodicHRectBound& operator|=(const arma::vec& vector); 00138 00142 PeriodicHRectBound& operator|=(const PeriodicHRectBound& other); 00143 00147 bool Contains(const arma::vec& point) const; 00148 00149 private: 00150 math::Range *bounds; 00151 size_t dim; 00152 arma::vec box; 00153 }; 00154 00155 }; // namespace bound 00156 }; // namespace mlpack 00157 00158 #include "periodichrectbound_impl.hpp" 00159 00160 #endif // __MLPACK_CORE_TREE_PERIODICHRECTBOUND_HPP