mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
discrete_hilbert_value.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_DISCRETE_HILBERT_VALUE_HPP
14 #define MLPACK_CORE_TREE_RECTANGLE_TREE_DISCRETE_HILBERT_VALUE_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace tree {
20 
28 template<typename TreeElemType>
30 {
31  public:
34  typedef typename std::conditional<sizeof(TreeElemType) * CHAR_BIT <= 32,
35  uint32_t,
36  uint64_t>::type HilbertElemType;
37 
40 
47  template<typename TreeType>
48  DiscreteHilbertValue(const TreeType* tree);
49 
57  template<typename TreeType>
58  DiscreteHilbertValue(const DiscreteHilbertValue& other,
59  TreeType* tree,
60  bool deepCopy);
61 
67  DiscreteHilbertValue(DiscreteHilbertValue&& other);
68 
70  ~DiscreteHilbertValue();
71 
81  template<typename VecType1, typename VecType2>
82  static int ComparePoints(const VecType1& pt1, const VecType2& pt2,
83  typename boost::enable_if<IsVector<VecType1>>* = 0,
84  typename boost::enable_if<IsVector<VecType2>>* = 0);
85 
94  static int CompareValues(const DiscreteHilbertValue& val1,
95  const DiscreteHilbertValue& val2);
96 
105  int CompareWith(const DiscreteHilbertValue& val) const;
106 
116  template<typename VecType>
117  int CompareWith(const VecType& pt,
118  typename boost::enable_if<IsVector<VecType>>* = 0) const;
119 
130  template<typename VecType>
131  int CompareWithCachedPoint(
132  const VecType& pt,
133  typename boost::enable_if<IsVector<VecType>>* = 0) const;
134 
142  template<typename TreeType, typename VecType>
143  size_t InsertPoint(TreeType *node,
144  const VecType& pt,
145  typename boost::enable_if<IsVector<VecType>>* = 0);
146 
152  template<typename TreeType>
153  void InsertNode(TreeType* node);
154 
162  template<typename TreeType>
163  void DeletePoint(TreeType* node, const size_t localIndex);
164 
171  template<typename TreeType>
172  void RemoveNode(TreeType* node, const size_t nodeIndex);
173 
180  DiscreteHilbertValue& operator=(const DiscreteHilbertValue& val);
181 
185  void NullifyData();
186 
194  template<typename TreeType>
195  void UpdateLargestValue(TreeType* node);
196 
206  template<typename TreeType>
207  void RedistributeHilbertValues(TreeType* parent,
208  const size_t firstSibling,
209  const size_t lastSibling);
210 
216  template<typename VecType>
217  static arma::Col<HilbertElemType> CalculateValue(
218  const VecType& pt,
219  typename boost::enable_if<IsVector<VecType>>* = 0);
220 
229  static int CompareValues(const arma::Col<HilbertElemType>& value1,
230  const arma::Col<HilbertElemType>& value2);
231 
233  size_t NumValues() const { return numValues; }
235  size_t& NumValues() { return numValues; }
236 
238  const arma::Mat<HilbertElemType>* LocalHilbertValues() const
239  { return localHilbertValues; }
241  arma::Mat<HilbertElemType>*& LocalHilbertValues()
242  { return localHilbertValues; }
243 
245  bool OwnsLocalHilbertValues() const { return ownsLocalHilbertValues; }
247  bool& OwnsLocalHilbertValues() { return ownsLocalHilbertValues; }
248 
250  const arma::Col<HilbertElemType>* ValueToInsert() const
251  { return valueToInsert; }
253  arma::Col<HilbertElemType>* ValueToInsert() { return valueToInsert; }
254 
256  bool OwnsValueToInsert() const { return ownsValueToInsert; }
258  bool& OwnsValueToInsert() { return ownsValueToInsert; }
259  private:
261  static constexpr size_t order = sizeof(HilbertElemType) * CHAR_BIT;
263  arma::Mat<HilbertElemType>* localHilbertValues;
265  bool ownsLocalHilbertValues;
267  size_t numValues;
274  arma::Col<HilbertElemType>* valueToInsert;
276  bool ownsValueToInsert;
277 
278  public:
279  template<typename Archive>
280  void Serialize(Archive& ar, const unsigned int /* version */);
281 };
282 
283 } // namespace tree
284 } // namespace mlpack
285 
286 // Include implementation.
287 #include "discrete_hilbert_value_impl.hpp"
288 
289 #endif // MLPACK_CORE_TREE_RECTANGLE_TREE_DISCRETE_HILBERT_VALUE_HPP
The DiscreteHilbertValue class stores Hilbert values for all of the points in a RectangleTree node...
The core includes that mlpack expects; standard C++ includes and Armadillo.
If value == true, then VecType is some sort of Armadillo vector or subview.
Definition: arma_traits.hpp:35