[mlpack] 70/324: Use bool instead of int.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:21:57 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 766cba804fdf6a5d4e5413ed427bb551e1faa419
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Tue Jun 24 05:23:01 2014 +0000

    Use bool instead of int.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16701 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 src/mlpack/methods/decision_stump/decision_stump.hpp      |  2 +-
 src/mlpack/methods/decision_stump/decision_stump_impl.hpp | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mlpack/methods/decision_stump/decision_stump.hpp b/src/mlpack/methods/decision_stump/decision_stump.hpp
index ed1dbff..5db64be 100644
--- a/src/mlpack/methods/decision_stump/decision_stump.hpp
+++ b/src/mlpack/methods/decision_stump/decision_stump.hpp
@@ -56,7 +56,7 @@ class DecisionStump
   int splitCol;
 
   //! Flag value for distinct input class labels.
-  int oneClass;
+  bool oneClass;
 
   //! Size of bucket while determining splitting criterion.
   size_t bucketSize;
diff --git a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
index b3ef678..9c387c7 100644
--- a/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
+++ b/src/mlpack/methods/decision_stump/decision_stump_impl.hpp
@@ -43,14 +43,14 @@ DecisionStump<MatType>::DecisionStump(const MatType& data,
   {
     // If the classLabels are all identical, the default class is the only
     // class.
-    oneClass = 1;
+    oneClass = true;
     defaultClass = classLabels(0);
   }
 
   else
   {
     // If classLabels are not all identical, proceed with training.
-    oneClass = 0;
+    oneClass = false;
     int bestAtt = -1;
     double entropy;
     double bestEntropy = DBL_MAX;
@@ -96,14 +96,14 @@ template<typename MatType>
 void DecisionStump<MatType>::Classify(const MatType& test,
                                       arma::Row<size_t>& predictedLabels)
 {
-  int flag;
+  bool flag;
   double val;
   if (!oneClass)
   {
     for (int i = 0; i < test.n_cols; i++)
     {
       int j = 0;
-      flag = 0;
+      flag = false;
 
       val = test(splitCol,i);
       while ((j < split.n_rows) && (!flag))
@@ -111,19 +111,19 @@ void DecisionStump<MatType>::Classify(const MatType& test,
         if (val < split(j, 0) && (!j))
         {
           predictedLabels(i) = split(0, 1);
-          flag = 1;
+          flag = true;
         }
         else if (val >= split(j, 0))
         {
           if (j == split.n_rows - 1)
           {
             predictedLabels(i) = split(split.n_rows - 1, 1);
-            flag = 1;
+            flag = true;
           }
           else if (val < split(j + 1, 0))
           {
             predictedLabels(i) = split(j, 1);
-            flag = 1;
+            flag = true;
           }
         }
         j++;

-- 
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