[mlpack-git] master: First pass: make it 80 characters, fix a few coding conventions. No real changes. (ee0d6e2)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:58:15 EST 2015


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

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

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

commit ee0d6e25aad1d80f6b1354a834eb8f39e0b7f6c0
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sun Aug 17 06:24:58 2014 +0000

    First pass: make it 80 characters, fix a few coding conventions.  No real
    changes.


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

ee0d6e25aad1d80f6b1354a834eb8f39e0b7f6c0
 .../tree/rectangle_tree/single_tree_traverser.hpp  | 28 +++++++++----------
 .../rectangle_tree/single_tree_traverser_impl.hpp  | 32 +++++++++++++---------
 2 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser.hpp b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser.hpp
index e8620e4..6eaf452 100644
--- a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser.hpp
@@ -26,17 +26,17 @@ class RectangleTree<SplitType, DescentType, StatisticType, MatType>::
 {
  public:
   /**
-    * Instantiate the traverser with the given rule set.
-    */
-    SingleTreeTraverser(RuleType& rule);
+   * Instantiate the traverser with the given rule set.
+   */
+  SingleTreeTraverser(RuleType& rule);
 
   /**
-    * Traverse the tree with the given point.
-    *
-    * @param queryIndex The index of the point in the query set which is being
-    *     used as the query point.
-    * @param referenceNode The tree node to be traversed.
-    */
+   * Traverse the tree with the given point.
+   *
+   * @param queryIndex The index of the point in the query set which is being
+   *     used as the query point.
+   * @param referenceNode The tree node to be traversed.
+   */
   void Traverse(const size_t queryIndex, const RectangleTree& referenceNode);
 
   //! Get the number of prunes.
@@ -44,15 +44,15 @@ class RectangleTree<SplitType, DescentType, StatisticType, MatType>::
   //! Modify the number of prunes.
   size_t& NumPrunes() { return numPrunes; }
 
-  //We use this struct and this function to make the sorting and scoring easy and efficient:
-  class NodeAndScore {
-  public:
+  // We use this struct and this function to make the sorting and scoring easy
+  // and efficient:
+  struct NodeAndScore
+  {
     RectangleTree<SplitType, DescentType, StatisticType, MatType>* node;
     double score;
   };
 
-  static bool nodeComparator(const NodeAndScore& obj1,
-                      const NodeAndScore& obj2)
+  static bool NodeComparator(const NodeAndScore& obj1, const NodeAndScore& obj2)
   {
     return obj1.score < obj2.score;
   }
diff --git a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
index 5168fc0..2bae871 100644
--- a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
@@ -19,7 +19,7 @@ namespace tree {
 
 template<typename SplitType,
          typename DescentType,
-	 typename StatisticType,
+         typename StatisticType,
          typename MatType>
 template<typename RuleType>
 RectangleTree<SplitType, DescentType, StatisticType, MatType>::
@@ -30,7 +30,7 @@ SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
 
 template<typename SplitType,
          typename DescentType,
-	 typename StatisticType,
+         typename StatisticType,
          typename MatType>
 template<typename RuleType>
 void RectangleTree<SplitType, DescentType, StatisticType, MatType>::
@@ -41,34 +41,40 @@ SingleTreeTraverser<RuleType>::Traverse(
 {
 
   // If we reach a leaf node, we need to run the base case.
-  if(referenceNode.IsLeaf()) {
-    for(size_t i = 0; i < referenceNode.Count(); i++) {
+  if (referenceNode.IsLeaf())
+  {
+    for (size_t i = 0; i < referenceNode.Count(); i++)
       rule.BaseCase(queryIndex, referenceNode.Points()[i]);
-    }
+
     return;
   }
 
-  // This is not a leaf node so we sort the children of this node by their scores.    
+  // This is not a leaf node so we sort the children of this node by their
+  // scores.
   std::vector<NodeAndScore> nodesAndScores(referenceNode.NumChildren());
-  for(int i = 0; i < referenceNode.NumChildren(); i++) {
+  for (int i = 0; i < referenceNode.NumChildren(); i++)
+  {
     nodesAndScores[i].node = referenceNode.Children()[i];
     nodesAndScores[i].score = rule.Score(queryIndex, *nodesAndScores[i].node);
   }
 
-  std::sort(nodesAndScores.begin(), nodesAndScores.end(), nodeComparator);
+  std::sort(nodesAndScores.begin(), nodesAndScores.end(), NodeComparator);
 
   // Now iterate through them starting with the best and stopping when we reach
   // one that isn't good enough.
-  for(int i = 0; i < referenceNode.NumChildren(); i++) {
-    if(rule.Rescore(queryIndex, *nodesAndScores[i].node, nodesAndScores[i].score) != DBL_MAX)
+  for (int i = 0; i < referenceNode.NumChildren(); i++)
+  {
+    if (rule.Rescore(queryIndex, *nodesAndScores[i].node,
+        nodesAndScores[i].score) != DBL_MAX)
+    {
       Traverse(queryIndex, *nodesAndScores[i].node);
-    else {
+    }
+    else
+    {
       numPrunes += referenceNode.NumChildren() - i;
       return;
     }
   }
-  // We only get here if we couldn't prune any of them.
-  return;
 }
 
 }; // namespace tree



More information about the mlpack-git mailing list