[mlpack-git] master, mlpack-1.0.x: keep the root node at the same address. (ea8ff93)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:49:08 EST 2015


Repository : https://github.com/mlpack/mlpack

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit ea8ff931787fa159ed48302fdd0504fb2e125380
Author: andrewmw94 <andrewmw94 at gmail.com>
Date:   Thu Jun 19 20:34:24 2014 +0000

    keep the root node at the same address.


>---------------------------------------------------------------

ea8ff931787fa159ed48302fdd0504fb2e125380
 src/mlpack/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 565f7db..fdfc7bd 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<DescentType, StatisticType, MatType>::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<RTreeSplit<DescentType, StatisticType, MatType>, 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())] = &copy; // Because this was a leaf node, numChildren must be 0.
     return;
   }
   
@@ -100,8 +103,10 @@ bool RTreeSplit<DescentType, StatisticType, MatType>::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<RTreeSplit<DescentType, StatisticType, MatType>, DescentType,  StatisticType, MatType>(NULL);
-    
+    RectangleTree<RTreeSplit<DescentType, StatisticType, MatType>, 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())] = &copy; // Because this was a leaf node, numChildren must be 0.
     return true;
   }
   



More information about the mlpack-git mailing list