[mlpack-git] master: Fix some more signed/unsigned comparison warnings that I introduced with the previous revision. (81e6589)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:00:09 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 81e65892ce9678dc6521f885904d6d967e97cc1d
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Sep 12 19:02:56 2014 +0000

    Fix some more signed/unsigned comparison warnings that I introduced with the
    previous revision.


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

81e65892ce9678dc6521f885904d6d967e97cc1d
 src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp |  6 +++---
 src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp      |  6 +++---
 src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp      | 10 ++++++----
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
index 2d771c0..8aef253 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
@@ -132,7 +132,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
       // tree->MinLeafSize() + i points in one rectangle and the rest in
       // another.  Then we calculate the three scores for that distribution.
 
-      int cutOff = tree->MinLeafSize() + i;
+      size_t cutOff = tree->MinLeafSize() + i;
 
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
@@ -396,7 +396,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       // tree->MinNumChildren() + i points in one rectangle and the rest in
       // another.  Then we calculate the three scores for that distribution.
 
-      int cutOff = tree->MinNumChildren() + i;
+      size_t cutOff = tree->MinNumChildren() + i;
 
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
@@ -508,7 +508,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       // tree->MinNumChildren() + i points in one rectangle and the rest in
       // another.  Then we calculate the three scores for that distribution.
 
-      int cutOff = tree->MinNumChildren() + i;
+      size_t cutOff = tree->MinNumChildren() + i;
 
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
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 22aa7a1..417b5ff 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
@@ -240,7 +240,7 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignPointDestNode(
     const int intI,
     const int intJ)
 {
-  int end = oldTree->Count();
+  size_t end = oldTree->Count();
 
   assert(end > 1); // If this isn't true, the tree is really weird.
 
@@ -294,7 +294,7 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignPointDestNode(
     // First, calculate the starting volume.
     double volOne = 1.0;
     double volTwo = 1.0;
-    for (int i = 0; i < oldTree->Bound().Dim(); i++)
+    for (size_t i = 0; i < oldTree->Bound().Dim(); i++)
     {
       volOne *= treeOne->Bound()[i].Width();
       volTwo *= treeTwo->Bound()[i].Width();
@@ -382,7 +382,7 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignNodeDestNode(
     const int intJ)
 {
 
-  int end = oldTree->NumChildren();
+  size_t end = oldTree->NumChildren();
   assert(end > 1); // If this isn't true, the tree is really weird.
 
   assert(intI != intJ);
diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
index 5ab24ff..3f527cf 100644
--- a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
@@ -415,7 +415,8 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     }
 
     // Track the minOverlapSplit data
-    if(minOverlapSplitDimension != -1 && j == minOverlapSplitDimension) {
+    if(minOverlapSplitDimension != tree->Bound().Dim() &&
+       j == minOverlapSplitDimension) {
       for(size_t i = 0; i < overlapedAreas.size(); i++) {
         if(overlapedAreas[i] < bestScoreMinOverlapSplit) {
           bestScoreMinOverlapSplit = overlapedAreas[i];
@@ -516,7 +517,8 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     }
 
     // Track the minOverlapSplit data
-    if(minOverlapSplitDimension != -1 && j == minOverlapSplitDimension) {
+    if(minOverlapSplitDimension != tree->Bound().Dim() &&
+       j == minOverlapSplitDimension) {
       for(size_t i = 0; i < overlapedAreas.size(); i++) {
         if(overlapedAreas[i] < bestScoreMinOverlapSplit) {
           minOverlapSplitUsesHi = true;
@@ -576,7 +578,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   // a "super node" (more accurately we resize this one to make it a super node).
   if(useMinOverlapSplit) {
     // If there is a dimension that might work, try that.
-    if(minOverlapSplitDimension != -1 && bestScoreMinOverlapSplit / areaOfBestMinOverlapSplit < MAX_OVERLAP) {
+    if(minOverlapSplitDimension != tree->Bound().Dim() && bestScoreMinOverlapSplit / areaOfBestMinOverlapSplit < MAX_OVERLAP) {
       std::vector<sortStruct> sorted2(tree->NumChildren());
       if (minOverlapSplitUsesHi) {
         for (size_t i = 0; i < sorted2.size(); i++) {
@@ -584,7 +586,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
           sorted2[i].n = i;
         }
       } else {
-        for (int i = 0; i < sorted2.size(); i++) {
+        for (size_t i = 0; i < sorted2.size(); i++) {
           sorted2[i].d = tree->Children()[i]->Bound()[bestAxis].Lo();
           sorted2[i].n = i;
         }



More information about the mlpack-git mailing list