From ea8ff931787fa159ed48302fdd0504fb2e125380 Mon Sep 17 00:00:00 2001 From: andrewmw94 Date: Thu, 19 Jun 2014 20:34:24 +0000 Subject: [PATCH] keep the root node at the same address. --- .../core/tree/rectangle_tree/r_tree_split_impl.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp index 565f7dbf40..fdfc7bdb9a 100644 --- a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp @@ -35,7 +35,10 @@ void RTreeSplit::SplitLeafNode( // If we are splitting the root node, we need will do things differently so that the constructor // and other methods don't confuse the end user by giving an address of another node. if(tree->Parent() == NULL) { - + RectangleTree, DescentType, StatisticType, MatType> copy = *tree; // We actually want to copy this way. Pointers and everything. + copy.Parent() = tree; + tree->Count() = 0; + tree->Children()[++(tree->NumChildren())] = © // Because this was a leaf node, numChildren must be 0. return; } @@ -100,8 +103,10 @@ bool RTreeSplit::SplitNonLeafNode( // If we are splitting the root node, we need will do things differently so that the constructor // and other methods don't confuse the end user by giving an address of another node. if(tree->Parent() == NULL) { - //tree->Parent() = new RectangleTree, DescentType, StatisticType, MatType>(NULL); - + RectangleTree, DescentType, StatisticType, MatType> copy = *tree; // We actually want to copy this way. Pointers and everything. + copy.Parent() = tree; + tree->NumChildren() = 0; + tree->Children()[++(tree->NumChildren())] = © // Because this was a leaf node, numChildren must be 0. return true; }