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(
83  const VecType1& pt1,
84  const VecType2& pt2,
87 
96  static int CompareValues(const DiscreteHilbertValue& val1,
97  const DiscreteHilbertValue& val2);
98 
107  int CompareWith(const DiscreteHilbertValue& val) const;
108 
118  template<typename VecType>
119  int CompareWith(
120  const VecType& pt,
121  typename std::enable_if_t<IsVector<VecType>::value>* = 0) const;
122 
133  template<typename VecType>
134  int CompareWithCachedPoint(
135  const VecType& pt,
136  typename std::enable_if_t<IsVector<VecType>::value>* = 0) const;
137 
145  template<typename TreeType, typename VecType>
146  size_t InsertPoint(TreeType *node,
147  const VecType& pt,
149 
155  template<typename TreeType>
156  void InsertNode(TreeType* node);
157 
165  template<typename TreeType>
166  void DeletePoint(TreeType* node, const size_t localIndex);
167 
174  template<typename TreeType>
175  void RemoveNode(TreeType* node, const size_t nodeIndex);
176 
183  DiscreteHilbertValue& operator=(const DiscreteHilbertValue& other);
184 
191  DiscreteHilbertValue& operator=(DiscreteHilbertValue&& other);
192 
196  void NullifyData();
197 
205  template<typename TreeType>
206  void UpdateLargestValue(TreeType* node);
207 
217  template<typename TreeType>
218  void RedistributeHilbertValues(TreeType* parent,
219  const size_t firstSibling,
220  const size_t lastSibling);
221 
227  template<typename VecType>
228  static arma::Col<HilbertElemType> CalculateValue(
229  const VecType& pt,
231 
240  static int CompareValues(const arma::Col<HilbertElemType>& value1,
241  const arma::Col<HilbertElemType>& value2);
242 
244  size_t NumValues() const { return numValues; }
246  size_t& NumValues() { return numValues; }
247 
249  const arma::Mat<HilbertElemType>* LocalHilbertValues() const
250  { return localHilbertValues; }
252  arma::Mat<HilbertElemType>*& LocalHilbertValues()
253  { return localHilbertValues; }
254 
256  bool OwnsLocalHilbertValues() const { return ownsLocalHilbertValues; }
258  bool& OwnsLocalHilbertValues() { return ownsLocalHilbertValues; }
259 
261  const arma::Col<HilbertElemType>* ValueToInsert() const
262  { return valueToInsert; }
264  arma::Col<HilbertElemType>* ValueToInsert() { return valueToInsert; }
265 
267  bool OwnsValueToInsert() const { return ownsValueToInsert; }
269  bool& OwnsValueToInsert() { return ownsValueToInsert; }
270  private:
272  static constexpr size_t order = sizeof(HilbertElemType) * CHAR_BIT;
274  arma::Mat<HilbertElemType>* localHilbertValues;
276  bool ownsLocalHilbertValues;
278  size_t numValues;
285  arma::Col<HilbertElemType>* valueToInsert;
287  bool ownsValueToInsert;
288 
289  public:
290  template<typename Archive>
291  void serialize(Archive& ar, const uint32_t /* version */);
292 };
293 
294 } // namespace tree
295 } // namespace mlpack
296 
297 // Include implementation.
298 #include "discrete_hilbert_value_impl.hpp"
299 
300 #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...
typename enable_if< B, T >::type enable_if_t
Definition: prereqs.hpp:70
Linear algebra utility functions, generally performed on matrices or vectors.
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