ub_tree_split.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_UB_TREE_SPLIT_HPP
14 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_UB_TREE_SPLIT_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 #include "../address.hpp"
18 
19 namespace mlpack {
20 namespace tree {
21 
28 template<typename BoundType, typename MatType = arma::mat>
30 {
31  public:
33  typedef typename std::conditional<
34  sizeof(typename MatType::elem_type) * CHAR_BIT <= 32,
35  uint32_t,
36  uint64_t>::type AddressElemType;
37 
39  struct SplitInfo
40  {
42  std::vector<std::pair<arma::Col<AddressElemType>, size_t>>* addresses;
43  };
44 
56  bool SplitNode(BoundType& bound,
57  MatType& data,
58  const size_t begin,
59  const size_t count,
60  SplitInfo& splitInfo);
61 
71  static size_t PerformSplit(MatType& data,
72  const size_t begin,
73  const size_t count,
74  const SplitInfo& splitInfo);
75 
88  static size_t PerformSplit(MatType& data,
89  const size_t begin,
90  const size_t count,
91  const SplitInfo& splitInfo,
92  std::vector<size_t>& oldFromNew);
93 
94  private:
96  std::vector<std::pair<arma::Col<AddressElemType>, size_t>> addresses;
97 
103  void InitializeAddresses(const MatType& data);
104 
106  static bool ComparePair(
107  const std::pair<arma::Col<AddressElemType>, size_t>& p1,
108  const std::pair<arma::Col<AddressElemType>, size_t>& p2)
109  {
110  return bound::addr::CompareAddresses(p1.first, p2.first) < 0;
111  }
112 };
113 
114 } // namespace tree
115 } // namespace mlpack
116 
117 // Include implementation.
118 #include "ub_tree_split_impl.hpp"
119 
120 #endif
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t PerformSplit(MatType &data, const size_t begin, const size_t count, const typename SplitType::SplitInfo &splitInfo)
This function implements the default split behavior i.e.
Split a node into two parts according to the median address of points contained in the node...
int CompareAddresses(const AddressType1 &addr1, const AddressType2 &addr2)
Compare two addresses.
Definition: address.hpp:233