[mlpack] 06/58: First pass: make it 80 characters, fix a few coding conventions. No real changes.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Tue Sep 9 13:19:38 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 57cc0397e950e9f54d3c4e434ca5da999f7d9677
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Sun Aug 17 06:24:58 2014 +0000

    First pass: make it 80 characters, fix a few coding conventions.  No real
    changes.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17051 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../tree/rectangle_tree/single_tree_traverser.hpp  | 30 ++++++++--------
 .../rectangle_tree/single_tree_traverser_impl.hpp  | 42 ++++++++++++----------
 2 files changed, 39 insertions(+), 33 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,19 +44,19 @@ 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;
   }
-  
+
  private:
   //! Reference to the rules with which the tree will be traversed.
   RuleType& rule;
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
@@ -16,10 +16,10 @@
 
 namespace mlpack {
 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>::
@@ -39,36 +39,42 @@ SingleTreeTraverser<RuleType>::Traverse(
     const RectangleTree<SplitType, DescentType, StatisticType, MatType>&
         referenceNode)
 {
-  
+
   // 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

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