[mlpack] 316/324: First pass: make things 80 characters, minor style fixes.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:22:22 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 b3b83f4b5fb6ca14c8ea9d038abe27f160321abb
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Thu Aug 14 17:34:14 2014 +0000

    First pass: make things 80 characters, minor style fixes.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17029 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../rectangle_tree/r_tree_descent_heuristic.hpp    |  36 +++++---
 .../r_tree_descent_heuristic_impl.hpp              | 100 +++++++++++++++------
 2 files changed, 97 insertions(+), 39 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
index da5b7a8..f917884 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic.hpp
@@ -2,8 +2,8 @@
  * @file r_tree_descent_heuristic.hpp
  * @author Andrew Wells
  *
- * Definition of RTreeDescentHeuristic, a class that chooses the best child of a node in
- * an R tree when inserting a new point.
+ * Definition of RTreeDescentHeuristic, a class that chooses the best child of a
+ * node in an R tree when inserting a new point.
  */
 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_HPP
 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_HPP
@@ -11,28 +11,42 @@
 #include <mlpack/core.hpp>
 
 namespace mlpack {
-namespace tree /** Trees and tree-building procedures. */ {
+namespace tree {
 
 /**
- * When descending a Rectangle tree to insert a point, we need to have a way to choose
- * a child node when the point isn't enclosed by any of them.  This heuristic is used to do so.
+ * When descending a RectangleTree to insert a point, we need to have a way to
+ * choose a child node when the point isn't enclosed by any of them.  This
+ * heuristic is used to do so.
  */
 class RTreeDescentHeuristic
 {
  public:
   /**
-   * Evaluate the node using a hueristic.  The heuristic guarantees two things:
-   * 1.  If point is contained in (or on) bound, the value returned is zero.
-   * 2.  If the point is not contained in (or on) bound, the value returned is greater than zero. 
+   * Evaluate the node using a heuristic.  The heuristic guarantees two things:
    *
-   * @param bound The bound used for the node that is being evaluated.
+   * 1. If point is contained in (or on) the bound, the value returned is zero.
+   * 2. If the point is not contained in (or on) the bound, the value returned
+   *    is greater than zero.
+   *
+   * @param node The node that is being evaluated.
    * @param point The point that is being inserted.
    */
   template<typename TreeType>
   static size_t ChooseDescentNode(const TreeType* node, const arma::vec& point);
-  
+
+  /**
+   * Evaluate the node using a heuristic.  The heuristic guarantees two things:
+   *
+   * 1. If point is contained in (or on) the bound, the value returned is zero.
+   * 2. If the point is not contained in (or on) the bound, the value returned
+   *    is greater than zero.
+   *
+   * @param node The node that is being evaluated.
+   * @param insertedNode The node that is being inserted.
+   */
   template<typename TreeType>
-  static size_t ChooseDescentNode(const TreeType* node, const TreeType* insertedNode);
+  static size_t ChooseDescentNode(const TreeType* node,
+                                  const TreeType* insertedNode);
 };
 
 }; // namespace tree
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
index 5767062..c8b21e9 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_descent_heuristic_impl.hpp
@@ -2,8 +2,8 @@
  * @file r_tree_descent_heuristic_impl.hpp
  * @author Andrew Wells
  *
- * Implementation of RTreeDescentHeuristic, a class that chooses the best child of a node in
- * an R tree when inserting a new point.
+ * Implementation of RTreeDescentHeuristic, a class that chooses the best child
+ * of a node in an R tree when inserting a new point.
  */
 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP
 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP
@@ -14,7 +14,8 @@ namespace mlpack {
 namespace tree {
 
 template<typename TreeType>
-inline size_t RTreeDescentHeuristic::ChooseDescentNode(const TreeType* node, const arma::vec& point)
+inline size_t RTreeDescentHeuristic::ChooseDescentNode(const TreeType* node,
+                                                       const arma::vec& point)
 {
   std::vector<double> scores(node->NumChildren());
   std::vector<int> vols(node->NumChildren());
@@ -22,77 +23,120 @@ inline size_t RTreeDescentHeuristic::ChooseDescentNode(const TreeType* node, con
   int bestIndex = 0;
   bool tied = false;
 
-  for (size_t i = 0; i < node->NumChildren(); i++) {
+  for (size_t i = 0; i < node->NumChildren(); i++)
+  {
     double v1 = 1.0;
     double v2 = 1.0;
-    for (size_t j = 0; j < node->Children()[i]->Bound().Dim(); j++) {
+    for (size_t j = 0; j < node->Children()[i]->Bound().Dim(); j++)
+    {
       v1 *= node->Children()[i]->Bound()[j].Width();
-      v2 *= node->Children()[i]->Bound()[j].Contains(point[j]) ? node->Children()[i]->Bound()[j].Width() : (node->Children()[i]->Bound()[j].Hi() < point[j] ? (point[j] - node->Children()[i]->Bound()[j].Lo()) :
+      v2 *= node->Children()[i]->Bound()[j].Contains(point[j]) ?
+          node->Children()[i]->Bound()[j].Width() :
+          (node->Children()[i]->Bound()[j].Hi() < point[j] ?
+              (point[j] - node->Children()[i]->Bound()[j].Lo()) :
               (node->Children()[i]->Bound()[j].Hi() - point[j]));
     }
+
     assert(v2 - v1 >= 0);
+
     vols[i] = v1;
-    scores[i] = v2-v1;
-    if (v2 - v1 < minScore) {
+    scores[i] = v2 - v1;
+
+    if (v2 - v1 < minScore)
+    {
       minScore = v2 - v1;
       bestIndex = i;
-    } else if(v2 - v1 == minScore)
+    }
+    else if (v2 - v1 == minScore)
+    {
       tied = true;
+    }
   }
-  if(tied) { // We break ties by choosing the smallest bound.
+
+  if (tied)
+  {
+    // We break ties by choosing the smallest bound.
     double minVol = DBL_MAX;
     bestIndex = 0;
-    for(int i = 0; i < scores.size(); i++) {
-      if(scores[i] == minScore) {
-        if(vols[i] < minVol) {
+    for (int i = 0; i < scores.size(); i++)
+    {
+      if (scores[i] == minScore)
+      {
+        if (vols[i] < minVol)
+        {
           minVol = vols[i];
           bestIndex = i;
         }
       }
     }
-  }  
+  }
+
   return bestIndex;
 }
 
 template<typename TreeType>
-inline size_t RTreeDescentHeuristic::ChooseDescentNode(const TreeType* node, const TreeType* insertedNode)
+inline size_t RTreeDescentHeuristic::ChooseDescentNode(
+    const TreeType* node,
+    const TreeType* insertedNode)
 {
   std::vector<double> scores(node->NumChildren());
   std::vector<int> vols(node->NumChildren());
+
   double minScore = DBL_MAX;
   int bestIndex = 0;
   bool tied = false;
-  
-  for (size_t i = 0; i < node->NumChildren(); i++) {
+
+  for (size_t i = 0; i < node->NumChildren(); i++)
+  {
     double v1 = 1.0;
     double v2 = 1.0;
-    for (size_t j = 0; j < node->Children()[i]->Bound().Dim(); j++) {
+    for (size_t j = 0; j < node->Children()[i]->Bound().Dim(); j++)
+    {
       v1 *= node->Children()[i]->Bound()[j].Width();
-      v2 *= node->Children()[i]->Bound()[j].Contains(insertedNode->Bound()[j]) ? node->Children()[i]->Bound()[j].Width() :
-              (insertedNode->Bound()[j].Contains(node->Children()[i]->Bound()[j]) ? insertedNode->Bound()[j].Width() : (insertedNode->Bound()[j].Lo() < node->Children()[i]->Bound()[j].Lo() ? (node->Children()[i]->Bound()[j].Hi() - insertedNode->Bound()[j].Lo()) : (insertedNode->Bound()[j].Hi() - node->Children()[i]->Bound()[j].Lo())));
+      v2 *= node->Children()[i]->Bound()[j].Contains(insertedNode->Bound()[j]) ?
+          node->Children()[i]->Bound()[j].Width() :
+          (insertedNode->Bound()[j].Contains(node->Children()[i]->Bound()[j]) ?
+          insertedNode->Bound()[j].Width() :
+          (insertedNode->Bound()[j].Lo() < node->Children()[i]->Bound()[j].Lo()
+          ? (node->Children()[i]->Bound()[j].Hi() -
+          insertedNode->Bound()[j].Lo()) : (insertedNode->Bound()[j].Hi() -
+          node->Children()[i]->Bound()[j].Lo())));
     }
+
     assert(v2 - v1 >= 0);
+
     vols[i] = v1;
-    scores[i] = v2-v1;
-    if (v2 - v1 < minScore) {
+    scores[i] = v2 - v1;
+
+    if (v2 - v1 < minScore)
+    {
       minScore = v2 - v1;
       bestIndex = i;
-    } else if(v2 - v1 == minScore)
+    }
+    else if (v2 - v1 == minScore)
+    {
       tied = true;
+    }
   }
-  if(tied) { // We break ties by choosing the smallest bound.
+
+  if (tied)
+  {
+    // We break ties by choosing the smallest bound.
     double minVol = DBL_MAX;
     bestIndex = 0;
-    for(int i = 0; i < scores.size(); i++) {
-      if(scores[i] == minScore) {
-        if(vols[i] < minVol) {
+    for (int i = 0; i < scores.size(); i++)
+    {
+      if (scores[i] == minScore)
+      {
+        if(vols[i] < minVol)
+        {
           minVol = vols[i];
           bestIndex = i;
         }
       }
     }
   }
-  
+
   return bestIndex;
 }
 

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