[mlpack-svn] r17071 - mlpack/trunk/src/mlpack/core/tree/rectangle_tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Aug 18 21:07:59 EDT 2014


Author: rcurtin
Date: Mon Aug 18 21:07:59 2014
New Revision: 17071

Log:
Simplify methods a little, and use int& instead of int*.


Modified:
   mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
   mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp

Modified: mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp	Mon Aug 18 21:07:59 2014
@@ -46,12 +46,12 @@
   /**
    * Get the seeds for splitting a leaf node.
    */
-  static void GetPointSeeds(const TreeType& tree, int* i, int* j);
+  static void GetPointSeeds(const TreeType& tree, int& i, int& j);
 
   /**
    * Get the seeds for splitting a non-leaf node.
    */
-  static void GetBoundSeeds(const TreeType& tree, int* i, int* j);
+  static void GetBoundSeeds(const TreeType& tree, int& i, int& j);
 
   /**
    * Assign points to the two new nodes.

Modified: mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp	Mon Aug 18 21:07:59 2014
@@ -50,7 +50,7 @@
   // rectangles, only points.  We assume that the tree uses Euclidean Distance.
   int i = 0;
   int j = 0;
-  GetPointSeeds(*tree, &i, &j);
+  GetPointSeeds(*tree, i, j);
 
   TreeType* treeOne = new TreeType(tree->Parent());
   TreeType* treeTwo = new TreeType(tree->Parent());
@@ -112,7 +112,7 @@
 
   int i = 0;
   int j = 0;
-  GetBoundSeeds(*tree, &i, &j);
+  GetBoundSeeds(*tree, i, j);
 
   assert(i != j);
 
@@ -169,15 +169,13 @@
          typename MatType>
 void RTreeSplit<DescentType, StatisticType, MatType>::GetPointSeeds(
     const TreeType& tree,
-    int* iRet,
-    int* jRet)
+    int& iRet,
+    int& jRet)
 {
   // Here we want to find the pair of points that it is worst to place in the
   // same node.  Because we are just using points, we will simply choose the two
   // that would create the most voluminous hyperrectangle.
   double worstPairScore = -1.0;
-  int worstI = 0;
-  int worstJ = 0;
   for (int i = 0; i < tree.Count(); i++)
   {
     for (int j = i + 1; j < tree.Count(); j++)
@@ -188,14 +186,11 @@
       if (score > worstPairScore)
       {
         worstPairScore = score;
-        worstI = i;
-        worstJ = j;
+        iRet = i;
+        jRet = j;
       }
     }
   }
-
-  *iRet = worstI;
-  *jRet = worstJ;
 }
 
 /**
@@ -207,12 +202,10 @@
          typename MatType>
 void RTreeSplit<DescentType, StatisticType, MatType>::GetBoundSeeds(
     const TreeType& tree,
-    int* iRet,
-    int* jRet)
+    int& iRet,
+    int& jRet)
 {
   double worstPairScore = -1.0;
-  int worstI = 0;
-  int worstJ = 0;
   for (int i = 0; i < tree.NumChildren(); i++)
   {
     for (int j = i + 1; j < tree.NumChildren(); j++)
@@ -230,14 +223,11 @@
       if (score > worstPairScore)
       {
         worstPairScore = score;
-        worstI = i;
-        worstJ = j;
+        iRet = i;
+        jRet = j;
       }
     }
   }
-
-  *iRet = worstI;
-  *jRet = worstJ;
 }
 
 template<typename DescentType,



More information about the mlpack-svn mailing list