[mlpack] 23/58: Simplify methods a little, and use int& instead of int*.
Barak A. Pearlmutter
barak+git at cs.nuim.ie
Tue Sep 9 13:19:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch svn-trunk
in repository mlpack.
commit 33f03fabbac1ae48239c04fe6dd1e4663ce2e989
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date: Tue Aug 19 01:07:59 2014 +0000
Simplify methods a little, and use int& instead of int*.
git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17071 9d5b8971-822b-0410-80eb-d18c1038ef23
---
.../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,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list