12 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP 13 #define MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP 24 template<
typename MetricType,
25 typename StatisticType,
29 template<
typename>
class AuxiliaryInformationType>
30 void RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
31 AuxiliaryInformationType>::
32 BuildStatistics(RectangleTree* node)
35 for (
size_t i = 0; i < node->NumChildren(); ++i)
36 BuildStatistics(&node->Child(i));
39 node->Stat() = StatisticType(*node);
42 template<
typename MetricType,
43 typename StatisticType,
47 template<
typename>
class AuxiliaryInformationType>
48 RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
49 AuxiliaryInformationType>::
50 RectangleTree(
const MatType&
data,
51 const size_t maxLeafSize,
52 const size_t minLeafSize,
53 const size_t maxNumChildren,
54 const size_t minNumChildren,
55 const size_t firstDataIndex) :
56 maxNumChildren(maxNumChildren),
57 minNumChildren(minNumChildren),
59 children(maxNumChildren + 1),
64 maxLeafSize(maxLeafSize),
65 minLeafSize(minLeafSize),
68 dataset(new MatType(data)),
70 points(maxLeafSize + 1),
76 for (
size_t i = firstDataIndex; i < data.n_cols; ++i)
80 BuildStatistics(
this);
83 template<
typename MetricType,
84 typename StatisticType,
88 template<
typename>
class AuxiliaryInformationType>
90 AuxiliaryInformationType>
:: 92 const size_t maxLeafSize,
93 const size_t minLeafSize,
94 const size_t maxNumChildren,
95 const size_t minNumChildren,
96 const size_t firstDataIndex) :
97 maxNumChildren(maxNumChildren),
98 minNumChildren(minNumChildren),
100 children(maxNumChildren + 1),
105 maxLeafSize(maxLeafSize),
106 minLeafSize(minLeafSize),
109 dataset(new MatType(
std::move(
data))),
111 points(maxLeafSize + 1),
117 for (
size_t i = firstDataIndex; i < dataset->n_cols; ++i)
121 BuildStatistics(
this);
124 template<
typename MetricType,
125 typename StatisticType,
129 template<
typename>
class AuxiliaryInformationType>
131 AuxiliaryInformationType>
:: 133 RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
134 AuxiliaryInformationType>*
135 parentNode,
const size_t numMaxChildren) :
136 maxNumChildren(numMaxChildren > 0 ? numMaxChildren :
140 children(maxNumChildren + 1),
147 bound(parentNode->
Bound().Dim()),
149 dataset(&parentNode->
Dataset()),
151 points(maxLeafSize + 1),
155 BuildStatistics(
this);
162 template<
typename MetricType,
163 typename StatisticType,
167 template<
typename>
class AuxiliaryInformationType>
169 AuxiliaryInformationType>
:: 177 children(maxNumChildren + 1, NULL),
178 parent(deepCopy ? newParent : other.
Parent()),
179 begin(other.
Begin()),
180 count(other.
Count()),
181 numDescendants(other.numDescendants),
188 (parent ? parent->dataset : new MatType(*other.dataset)) :
190 ownsDataset(deepCopy && (!parent)),
191 points(other.points),
192 auxiliaryInfo(other.auxiliaryInfo, this, deepCopy)
198 for (
size_t i = 0; i < numChildren; ++i)
203 children = other.children;
209 template<
typename MetricType,
210 typename StatisticType,
214 template<
typename>
class AuxiliaryInformationType>
216 AuxiliaryInformationType>
:: 221 children(
std::move(other.children)),
223 begin(other.
Begin()),
224 count(other.
Count()),
225 numDescendants(other.numDescendants),
228 bound(
std::move(other.bound)),
229 stat(
std::move(other.stat)),
231 dataset(other.dataset),
232 ownsDataset(other.ownsDataset),
233 points(
std::move(other.points)),
234 auxiliaryInfo(
std::move(other.auxiliaryInfo))
239 while (parent->children[iChild] != (&other))
241 assert(iChild < numChildren);
242 parent->children[iChild] =
this;
246 for (
size_t i = 0; i < numChildren; ++i)
247 children[i]->parent =
this;
251 other.maxNumChildren = 0;
252 other.minNumChildren = 0;
253 other.numChildren = 0;
257 other.numDescendants = 0;
258 other.maxLeafSize = 0;
259 other.minLeafSize = 0;
260 other.parentDistance = 0;
261 other.dataset = NULL;
262 other.ownsDataset =
false;
268 template<
typename MetricType,
269 typename StatisticType,
273 template<
typename>
class AuxiliaryInformationType>
275 AuxiliaryInformationType>&
277 AuxiliaryInformationType>::
285 for (
size_t i = 0; i < numChildren; ++i)
291 maxNumChildren = other.MaxNumChildren();
292 minNumChildren = other.MinNumChildren();
293 numChildren = other.NumChildren();
294 children.resize(maxNumChildren + 1, NULL);
296 begin = other.Begin();
297 count = other.Count();
298 numDescendants = other.numDescendants;
299 maxLeafSize = other.MaxLeafSize();
300 minLeafSize = other.MinLeafSize();
303 parentDistance = other.ParentDistance();
304 dataset =
new MatType(*other.dataset);
306 points = other.points;
307 auxiliaryInfo = AuxiliaryInfoType(other.auxiliaryInfo,
this,
true);
311 for (
size_t i = 0; i < numChildren; ++i)
321 template<
typename MetricType,
322 typename StatisticType,
326 template<
typename>
class AuxiliaryInformationType>
328 AuxiliaryInformationType>&
330 AuxiliaryInformationType>::
338 for (
size_t i = 0; i < numChildren; ++i)
344 maxNumChildren = other.MaxNumChildren();
345 minNumChildren = other.MinNumChildren();
346 numChildren = other.NumChildren();
347 children = std::move(other.children);
349 begin = other.Begin();
350 count = other.Count();
351 numDescendants = other.numDescendants;
352 maxLeafSize = other.MaxLeafSize();
353 minLeafSize = other.MinLeafSize();
354 bound = std::move(other.bound);
355 stat = std::move(other.stat);
356 parentDistance = other.ParentDistance();
357 dataset = other.dataset;
358 ownsDataset = other.ownsDataset;
359 points = std::move(other.points);
360 auxiliaryInfo = std::move(other.auxiliaryInfo);
364 other.maxNumChildren = 0;
365 other.minNumChildren = 0;
366 other.numChildren = 0;
370 other.numDescendants = 0;
371 other.maxLeafSize = 0;
372 other.minLeafSize = 0;
373 other.parentDistance = 0;
374 other.dataset = NULL;
375 other.ownsDataset =
false;
383 template<
typename MetricType,
384 typename StatisticType,
388 template<
typename>
class AuxiliaryInformationType>
389 template<
typename Archive>
391 AuxiliaryInformationType>
:: 394 const typename std::enable_if_t<cereal::is_loading<Archive>()>*) :
398 ar(CEREAL_NVP(*
this));
406 template<
typename MetricType,
407 typename StatisticType,
411 template<
typename>
class AuxiliaryInformationType>
413 AuxiliaryInformationType>
:: 416 for (
size_t i = 0; i < numChildren; ++i)
427 template<
typename MetricType,
428 typename StatisticType,
432 template<
typename>
class AuxiliaryInformationType>
434 AuxiliaryInformationType>
:: 439 for (
size_t i = 0; i < children.size(); ++i)
449 template<
typename MetricType,
450 typename StatisticType,
454 template<
typename>
class AuxiliaryInformationType>
456 AuxiliaryInformationType>
:: 459 auxiliaryInfo.NullifyData();
466 template<
typename MetricType,
467 typename StatisticType,
471 template<
typename>
class AuxiliaryInformationType>
473 AuxiliaryInformationType>
:: 477 bound |= dataset->col(point);
481 std::vector<bool> lvls(
TreeDepth(),
true);
484 if (numChildren == 0)
486 if (!auxiliaryInfo.HandlePointInsertion(
this, point))
487 points[count++] = point;
495 auxiliaryInfo.HandlePointInsertion(
this, point);
496 const size_t descentNode = DescentType::ChooseDescentNode(
this, point);
497 children[descentNode]->InsertPoint(point, lvls);
503 template<
typename MetricType,
504 typename StatisticType,
508 template<
typename>
class AuxiliaryInformationType>
510 AuxiliaryInformationType>
:: 514 bound |= dataset->col(point);
519 if (numChildren == 0)
521 if (!auxiliaryInfo.HandlePointInsertion(
this, point))
522 points[count++] = point;
530 auxiliaryInfo.HandlePointInsertion(
this, point);
531 const size_t descentNode = DescentType::ChooseDescentNode(
this, point);
532 children[descentNode]->InsertPoint(point, relevels);
543 template<
typename MetricType,
544 typename StatisticType,
548 template<
typename>
class AuxiliaryInformationType>
550 AuxiliaryInformationType>
:: 553 std::vector<bool>& relevels)
556 bound |= node->
Bound();
557 numDescendants += node->numDescendants;
560 if (!auxiliaryInfo.HandleNodeInsertion(
this, node,
true))
562 children[numChildren++] = node;
569 auxiliaryInfo.HandleNodeInsertion(
this, node,
false);
570 const size_t descentNode = DescentType::ChooseDescentNode(
this, node);
571 children[descentNode]->InsertNode(node, level, relevels);
579 template<
typename MetricType,
580 typename StatisticType,
584 template<
typename>
class AuxiliaryInformationType>
586 AuxiliaryInformationType>
:: 592 while (root->
Parent() != NULL)
595 std::vector<bool> lvls(root->
TreeDepth(),
true);
597 if (numChildren == 0)
599 for (
size_t i = 0; i < count; ++i)
601 if (points[i] == point)
603 if (!auxiliaryInfo.HandlePointDeletion(
this, i))
604 points[i] = points[--count];
609 tree->numDescendants--;
619 for (
size_t i = 0; i < numChildren; ++i)
631 template<
typename MetricType,
632 typename StatisticType,
636 template<
typename>
class AuxiliaryInformationType>
638 AuxiliaryInformationType>
:: 641 if (numChildren == 0)
643 for (
size_t i = 0; i < count; ++i)
645 if (points[i] == point)
647 if (!auxiliaryInfo.HandlePointDeletion(
this, i))
648 points[i] = points[--count];
653 tree->numDescendants--;
663 for (
size_t i = 0; i < numChildren; ++i)
676 template<
typename MetricType,
677 typename StatisticType,
681 template<
typename>
class AuxiliaryInformationType>
683 AuxiliaryInformationType>
:: 686 for (
size_t i = 0; i < numChildren; ++i)
688 if (children[i] == node)
690 if (!auxiliaryInfo.HandleNodeRemoval(
this, i))
692 children[i] = children[--numChildren];
697 tree->numDescendants -= node->numDescendants;
704 bool contains =
true;
705 for (
size_t j = 0; j < node->
Bound().
Dim(); ++j)
716 template<
typename MetricType,
717 typename StatisticType,
721 template<
typename>
class AuxiliaryInformationType>
726 for (
int i = 0; i < numChildren; ++i)
732 template<
typename MetricType,
733 typename StatisticType,
737 template<
typename>
class AuxiliaryInformationType>
744 while (!currentNode->
IsLeaf())
746 currentNode = currentNode->children[0];
753 template<
typename MetricType,
754 typename StatisticType,
758 template<
typename>
class AuxiliaryInformationType>
762 return (numChildren == 0);
769 template<
typename MetricType,
770 typename StatisticType,
774 template<
typename>
class AuxiliaryInformationType>
775 template<
typename VecType>
778 const VecType& point,
784 ElemType bestDistance = std::numeric_limits<ElemType>::max();
785 size_t bestIndex = 0;
789 if (distance <= bestDistance)
791 bestDistance = distance;
802 template<
typename MetricType,
803 typename StatisticType,
807 template<
typename>
class AuxiliaryInformationType>
808 template<
typename VecType>
811 const VecType& point,
818 size_t bestIndex = 0;
822 if (distance >= bestDistance)
824 bestDistance = distance;
835 template<
typename MetricType,
836 typename StatisticType,
840 template<
typename>
class AuxiliaryInformationType>
847 ElemType bestDistance = std::numeric_limits<ElemType>::max();
848 size_t bestIndex = 0;
852 if (distance <= bestDistance)
854 bestDistance = distance;
865 template<
typename MetricType,
866 typename StatisticType,
870 template<
typename>
class AuxiliaryInformationType>
878 size_t bestIndex = 0;
882 if (distance >= bestDistance)
884 bestDistance = distance;
895 template<
typename MetricType,
896 typename StatisticType,
900 template<
typename>
class AuxiliaryInformationType>
921 template<
typename MetricType,
922 typename StatisticType,
926 template<
typename>
class AuxiliaryInformationType>
941 template<
typename MetricType,
942 typename StatisticType,
946 template<
typename>
class AuxiliaryInformationType>
950 if (numChildren != 0)
959 template<
typename MetricType,
960 typename StatisticType,
964 template<
typename>
class AuxiliaryInformationType>
968 return numDescendants;
974 template<
typename MetricType,
975 typename StatisticType,
979 template<
typename>
class AuxiliaryInformationType>
984 if (numChildren == 0)
986 return (points[index]);
991 for (
size_t i = 0; i < numChildren; ++i)
993 const size_t nd = children[i]->NumDescendants();
995 return children[i]->Descendant(index - n);
1000 return children[numChildren - 1]->Descendant(index - n);
1008 template<
typename MetricType,
1009 typename StatisticType,
1013 template<
typename>
class AuxiliaryInformationType>
1015 AuxiliaryInformationType>::
1016 SplitNode(std::vector<bool>& relevels)
1018 if (numChildren == 0)
1025 SplitType::SplitLeafNode(
this, relevels);
1030 if (numChildren <= maxNumChildren)
1035 SplitType::SplitNonLeafNode(
this, relevels);
1040 template<
typename MetricType,
1041 typename StatisticType,
1045 template<
typename>
class AuxiliaryInformationType>
1047 AuxiliaryInformationType>
:: 1058 parentDistance(0.0),
1069 template<
typename MetricType,
1070 typename StatisticType,
1074 template<
typename>
class AuxiliaryInformationType>
1076 AuxiliaryInformationType>
:: 1078 std::vector<bool>& relevels,
1079 const bool usePoint)
1083 if (
IsLeaf() && count < minLeafSize && parent != NULL)
1086 for (
size_t i = 0; i < parent->
NumChildren(); ++i)
1088 if (parent->children[i] ==
this)
1091 if (!auxiliaryInfo.HandleNodeRemoval(parent, i))
1093 parent->children[i] = parent->children[--parent->
NumChildren()];
1097 bool stillShrinking =
true;
1099 while (root->
Parent() != NULL)
1109 while (root != NULL)
1111 root->numDescendants -= numDescendants;
1115 stillShrinking =
true;
1117 while (root->
Parent() != NULL)
1120 stillShrinking = root->
AuxiliaryInfo().UpdateAuxiliaryInfo(root);
1127 for (
size_t j = 0; j < count; ++j)
1141 else if (!
IsLeaf() && numChildren < minNumChildren)
1146 for (
size_t j = 0; j < parent->
NumChildren(); ++j)
1148 if (parent->children[j] ==
this)
1151 if (!auxiliaryInfo.HandleNodeRemoval(parent, j))
1153 parent->children[j] = parent->children[--parent->
NumChildren()];
1158 bool stillShrinking =
true;
1160 while (root->
Parent() != NULL)
1170 while (root != NULL)
1172 root->numDescendants -= numDescendants;
1176 stillShrinking =
true;
1178 while (root->
Parent() != NULL)
1181 stillShrinking = root->
AuxiliaryInfo().UpdateAuxiliaryInfo(root);
1188 for (
size_t i = 0; i < numChildren; ++i)
1189 root->
InsertNode(children[i], level, relevels);
1200 else if (numChildren == 1)
1209 children.resize(maxNumChildren + 1);
1214 children[i] = child->children[i];
1215 children[i]->Parent() =
this;
1216 child->children[i] = NULL;
1222 for (
size_t i = 0; i < child->
Count(); ++i)
1225 points[i] = child->
Point(i);
1230 count = child->
Count();
1243 else if (!usePoint &&
1245 auxiliaryInfo.UpdateAuxiliaryInfo(
this)) &&
1253 template<
typename MetricType,
1254 typename StatisticType,
1258 template<
typename>
class AuxiliaryInformationType>
1260 AuxiliaryInformationType>
:: 1263 bool shrunk =
false;
1266 for (
size_t i = 0; i < bound.
Dim(); ++i)
1268 if (bound[i].Lo() == point[i])
1270 ElemType min = std::numeric_limits<ElemType>::max();
1271 for (
size_t j = 0; j < count; ++j)
1273 if (dataset->col(points[j])[i] < min)
1274 min = dataset->col(points[j])[i];
1277 if (bound[i].Lo() < min)
1280 bound[i].Lo() = min;
1282 else if (min < bound[i].Lo())
1287 else if (bound[i].Hi() == point[i])
1289 ElemType max = std::numeric_limits<ElemType>::lowest();
1290 for (
size_t j = 0; j < count; ++j)
1292 if (dataset->col(points[j])[i] > max)
1293 max = dataset->col(points[j])[i];
1296 if (bound[i].Hi() > max)
1299 bound[i].Hi() = max;
1301 else if (max > bound[i].Hi())
1310 for (
size_t i = 0; i < bound.
Dim(); ++i)
1312 if (bound[i].Lo() == point[i])
1314 ElemType min = std::numeric_limits<ElemType>::max();
1315 for (
size_t j = 0; j < numChildren; ++j)
1317 if (children[j]->
Bound()[i].Lo() < min)
1318 min = children[j]->Bound()[i].Lo();
1321 if (bound[i].Lo() < min)
1324 bound[i].Lo() = min;
1327 else if (bound[i].Hi() == point[i])
1329 ElemType max = std::numeric_limits<ElemType>::lowest();
1330 for (
size_t j = 0; j < numChildren; ++j)
1332 if (children[j]->
Bound()[i].Hi() > max)
1333 max = children[j]->Bound()[i].Hi();
1336 if (bound[i].Hi() > max)
1339 bound[i].Hi() = max;
1351 template<
typename MetricType,
1352 typename StatisticType,
1356 template<
typename>
class AuxiliaryInformationType>
1358 AuxiliaryInformationType>
:: 1365 for (
size_t i = 0; i < bound.
Dim(); ++i)
1367 sum += bound[i].Width();
1368 bound[i].Lo() = std::numeric_limits<ElemType>::max();
1369 bound[i].Hi() = std::numeric_limits<ElemType>::lowest();
1372 for (
size_t i = 0; i < numChildren; ++i)
1374 bound |= children[i]->Bound();
1378 for (
size_t i = 0; i < bound.
Dim(); ++i)
1379 sum2 += bound[i].Width();
1387 template<
typename MetricType,
1388 typename StatisticType,
1392 template<
typename>
class AuxiliaryInformationType>
1393 template<
typename Archive>
1400 if (cereal::is_loading<Archive>())
1402 for (
size_t i = 0; i < numChildren; ++i)
1406 if (ownsDataset && dataset)
1412 bool hasParent = (parent != NULL);
1414 ar(CEREAL_NVP(maxNumChildren));
1415 ar(CEREAL_NVP(minNumChildren));
1416 ar(CEREAL_NVP(numChildren));
1417 if (cereal::is_loading<Archive>())
1418 children.resize(maxNumChildren + 1);
1420 ar(CEREAL_NVP(begin));
1421 ar(CEREAL_NVP(count));
1422 ar(CEREAL_NVP(numDescendants));
1423 ar(CEREAL_NVP(maxLeafSize));
1424 ar(CEREAL_NVP(minLeafSize));
1425 ar(CEREAL_NVP(bound));
1426 ar(CEREAL_NVP(stat));
1427 ar(CEREAL_NVP(parentDistance));
1428 ar(CEREAL_NVP(hasParent));
1432 MatType*& datasetTemp =
const_cast<MatType*&
>(dataset);
1436 ar(CEREAL_NVP(points));
1437 ar(CEREAL_NVP(auxiliaryInfo));
1441 for (
size_t i = 0; i < numChildren; ++i)
1443 std::ostringstream oss;
1444 oss <<
"children" << i;
1447 if (cereal::is_loading<Archive>())
1448 children[i]->parent =
this;
1450 for (
size_t i = numChildren; i < maxNumChildren + 1; ++i)
1458 std::stack<RectangleTree*> stack;
1459 for (
size_t i = 0; i < numChildren; ++i)
1461 stack.push(children[i]);
1463 while (!stack.empty())
1467 node->dataset = dataset;
1468 for (
size_t i = 0; i < node->numChildren; ++i)
1470 stack.push(node->children[i]);
size_t TreeSize() const
Obtains the number of nodes in the tree, starting with this.
Definition: rectangle_tree_impl.hpp:723
const MatType & Dataset() const
Get the dataset which the tree is built on.
Definition: rectangle_tree.hpp:360
ElemType FurthestDescendantDistance() const
Return the furthest possible descendant distance.
Definition: rectangle_tree_impl.hpp:931
size_t Point(const size_t index) const
Return the index (with reference to the dataset) of a particular point in this node.
Definition: rectangle_tree.hpp:480
void NullifyData()
Nullify the auxiliary information.
Definition: rectangle_tree_impl.hpp:457
void SoftDelete()
Delete this node of the tree, but leave the stuff contained in it intact.
Definition: rectangle_tree_impl.hpp:435
~RectangleTree()
Deletes this node, deallocating the memory for the children and calling their destructors in turn...
Definition: rectangle_tree_impl.hpp:414
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
size_t Begin() const
Return the index of the beginning point of this subset.
Definition: rectangle_tree.hpp:543
ElemType MinDistance(const RectangleTree &other) const
Return the minimum distance to another node.
Definition: rectangle_tree.hpp:487
ElemType FurthestPointDistance() const
Return the furthest distance to a point held in this node.
Definition: rectangle_tree_impl.hpp:905
const bound::HRectBound< MetricType > & Bound() const
Return the bound object for this node.
Definition: rectangle_tree.hpp:315
Definition: pointer_wrapper.hpp:23
bool DeletePoint(const size_t point)
Deletes a point from the treeand, updates the bounding rectangle.
Definition: rectangle_tree_impl.hpp:587
ElemType Diameter() const
Returns the diameter of the hyperrectangle (that is, the longest diagonal).
Definition: hrectbound_impl.hpp:669
size_t NumDescendants() const
Return the number of descendants of this node.
Definition: rectangle_tree_impl.hpp:966
size_t GetNearestChild(const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0)
Return the index of the nearest child node to the given query point.
Definition: rectangle_tree_impl.hpp:777
void serialize(Archive &ar, const uint32_t)
Serialize the tree.
Definition: rectangle_tree_impl.hpp:1395
ElemType MaxDistance(const RectangleTree &other) const
Return the maximum distance to another node.
Definition: rectangle_tree.hpp:493
const AuxiliaryInformationType< RectangleTree > & AuxiliaryInfo() const
Return the auxiliary information object of this node.
Definition: rectangle_tree.hpp:325
size_t NumPoints() const
Return the number of points in this node (returns 0 if this node is not a leaf).
Definition: rectangle_tree_impl.hpp:948
bool RemoveNode(const RectangleTree *node, std::vector< bool > &relevels)
Removes a node from the tree.
Definition: rectangle_tree_impl.hpp:684
bool Contains(const VecType &point) const
Determines if a point is within this bound.
Definition: hrectbound_impl.hpp:579
friend DescentType
Give friend access for DescentType.
Definition: rectangle_tree.hpp:580
size_t NumChildren() const
Return the number of child nodes. (One level beneath this one only.)
Definition: rectangle_tree.hpp:371
friend SplitType
Give friend access for SplitType.
Definition: rectangle_tree.hpp:583
MatType::elem_type ElemType
The element type held by the matrix type.
Definition: rectangle_tree.hpp:64
size_t MinNumChildren() const
Return the minimum number of children (in a non-leaf node).
Definition: rectangle_tree.hpp:350
void InsertPoint(const size_t point)
Inserts a point into the tree.
Definition: rectangle_tree_impl.hpp:474
size_t TreeDepth() const
Obtains the number of levels below this node in the tree, starting with this.
Definition: rectangle_tree_impl.hpp:739
bool ShrinkBoundForBound(const bound::HRectBound< MetricType > &changedBound)
Shrink the bound object of this node for the removal of a child node.
Definition: rectangle_tree_impl.hpp:1359
A rectangle type tree tree, such as an R-tree or X-tree.
Definition: rectangle_tree.hpp:54
size_t GetFurthestChild(const VecType &point, typename std::enable_if_t< IsVector< VecType >::value > *=0)
Return the index of the furthest child node to the given query point.
Definition: rectangle_tree_impl.hpp:810
size_t MaxLeafSize() const
Return the maximum leaf size.
Definition: rectangle_tree.hpp:335
void CondenseTree(const arma::vec &point, std::vector< bool > &relevels, const bool usePoint)
Condense the bounding rectangles for this node based on the removal of the point specified by the arm...
Definition: rectangle_tree_impl.hpp:1077
RectangleTree()
A default constructor.
Definition: rectangle_tree_impl.hpp:1048
void InsertNode(RectangleTree *node, const size_t level, std::vector< bool > &relevels)
Inserts a node into the tree, tracking which levels have been inserted into.
Definition: rectangle_tree_impl.hpp:551
#define CEREAL_POINTER(T)
Cereal does not support the serialization of raw pointer.
Definition: pointer_wrapper.hpp:96
size_t MaxNumChildren() const
Return the maximum number of children (in a non-leaf node).
Definition: rectangle_tree.hpp:345
size_t Dim() const
Gets the dimensionality.
Definition: hrectbound.hpp:96
bool IsLeaf() const
Return whether or not this node is a leaf (true if it has no children).
Definition: rectangle_tree_impl.hpp:760
RectangleTree & Child(const size_t child) const
Get the specified child.
Definition: rectangle_tree.hpp:437
ElemType ParentDistance() const
Return the distance from the center of this node to the center of the parent node.
Definition: rectangle_tree.hpp:427
size_t Descendant(const size_t index) const
Return the index (with reference to the dataset) of a particular descendant of this node...
Definition: rectangle_tree_impl.hpp:981
size_t MinLeafSize() const
Return the minimum leaf size.
Definition: rectangle_tree.hpp:340
bool ShrinkBoundForPoint(const arma::vec &point)
Shrink the bound object of this node for the removal of a point.
Definition: rectangle_tree_impl.hpp:1261
If value == true, then VecType is some sort of Armadillo vector or subview.
Definition: arma_traits.hpp:35
RectangleTree * Parent() const
Gets the parent of this node.
Definition: rectangle_tree.hpp:355
size_t Count() const
Return the number of points in this subset.
Definition: rectangle_tree.hpp:548