[mlpack-git] master: Simplify methods a little, and use int& instead of int*. (be993c6)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:58:49 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit be993c6a7717878554cdc73fa15830800516e530
Author: Ryan Curtin <ryan at ratml.org>
Date: Tue Aug 19 01:07:59 2014 +0000
Simplify methods a little, and use int& instead of int*.
>---------------------------------------------------------------
be993c6a7717878554cdc73fa15830800516e530
.../core/tree/rectangle_tree/r_tree_split.hpp | 4 +--
.../core/tree/rectangle_tree/r_tree_split_impl.hpp | 30 ++++++++--------------
2 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
index 4b2baa2..ea5ea95 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
@@ -46,12 +46,12 @@ class RTreeSplit
/**
* 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.
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 126f232..1905a91 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
@@ -50,7 +50,7 @@ void RTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
// 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 @@ bool RTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
int i = 0;
int j = 0;
- GetBoundSeeds(*tree, &i, &j);
+ GetBoundSeeds(*tree, i, j);
assert(i != j);
@@ -169,15 +169,13 @@ template<typename DescentType,
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 @@ void RTreeSplit<DescentType, StatisticType, MatType>::GetPointSeeds(
if (score > worstPairScore)
{
worstPairScore = score;
- worstI = i;
- worstJ = j;
+ iRet = i;
+ jRet = j;
}
}
}
-
- *iRet = worstI;
- *jRet = worstJ;
}
/**
@@ -207,12 +202,10 @@ template<typename DescentType,
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 @@ void RTreeSplit<DescentType, StatisticType, MatType>::GetBoundSeeds(
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-git
mailing list