[mlpack] 312/324: First pass: make lines 80 characters long, tabs to spaces, and bracket surgery (or something).

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

    First pass: make lines 80 characters long, tabs to spaces, and bracket surgery
    (or something).
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17025 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../core/tree/rectangle_tree/rectangle_tree.hpp    | 212 +++---
 .../tree/rectangle_tree/rectangle_tree_impl.hpp    | 719 ++++++++++++---------
 2 files changed, 533 insertions(+), 398 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index e9b144c..ec92bb3 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -2,7 +2,8 @@
  * @file rectangle_tree.hpp
  * @author Andrew Wells
  *
- * Definition of generalized rectangle type trees (r_tree, r_star_tree, x_tree, and hilbert_r_tree).
+ * Definition of generalized rectangle type trees (r_tree, r_star_tree, x_tree,
+ * and hilbert_r_tree).
  */
 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_HPP
 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_HPP
@@ -30,32 +31,33 @@ using bound::HRectBound;
  *     for the necessary skeleton interface.
  * @tparam MatType The dataset class.
  * @tparam SplitType The type of split to use when inserting points.
- * @tparam DescentType The heuristic to use when descending the tree to insert points.
+ * @tparam DescentType The heuristic to use when descending the tree to insert
+ *    points.
  */
 
 template<typename SplitType,
-	 typename DescentType,
-	 typename StatisticType = EmptyStatistic,
-	 typename MatType = arma::mat>
+         typename DescentType,
+         typename StatisticType = EmptyStatistic,
+         typename MatType = arma::mat>
 class RectangleTree
 {
  public:
   /**
-   * The X tree requires that the tree records it's "split history".  To make this easy, we
-   * use the following structure.
+   * The X tree requires that the tree records it's "split history".  To make
+   * this easy, we use the following structure.
    */
-  typedef struct SplitHistoryStruct {
+  typedef struct SplitHistoryStruct
+  {
     int lastDimension;
     std::vector<bool> history;
-    SplitHistoryStruct(int dim):
-      history(dim)
+
+    SplitHistoryStruct(int dim) : history(dim)
     {
-      for(int i = 0; i < dim; i++)
+      for (int i = 0; i < dim; i++)
         history[i] = false;
     }
-    
-  } SplitHistoryStruct;  
-  
+  } SplitHistoryStruct;
+
  private:
   //! The max number of child nodes a non-leaf node can have.
   size_t maxNumChildren;
@@ -97,7 +99,6 @@ class RectangleTree
   MatType* localDataset;
 
  public:
-   
   //! So other classes can use TreeType::Mat.
   typedef MatType Mat;
 
@@ -116,32 +117,37 @@ class RectangleTree
    * @param data Dataset from which to create the tree.  This will be modified!
    * @param maxLeafSize Maximum size of each leaf in the tree.
    * @param minLeafSize Minimum size of each leaf in the tree.
-   * @param maxNumChildren The maximum number of child nodes a non-leaf node may have.
-   * @param minNumChildren The minimum number of child nodes a non-leaf node may have.
-   * @param firstDataIndex The index of the first data point.  UNUSED UNLESS WE ADD SUPPORT FOR HAVING A
-   * "CENTERAL" DATA MATRIX.
+   * @param maxNumChildren The maximum number of child nodes a non-leaf node may
+   *      have.
+   * @param minNumChildren The minimum number of child nodes a non-leaf node may
+   *      have.
+   * @param firstDataIndex The index of the first data point.  UNUSED UNLESS WE
+   *      ADD SUPPORT FOR HAVING A "CENTERAL" DATA MATRIX.
    */
   RectangleTree(MatType& data,
-    const size_t maxLeafSize = 20,
-    const size_t minLeafSize = 8,
-    const size_t maxNumChildren = 5,
-    const size_t minNumChildren = 2,
-    const size_t firstDataIndex = 0
-  );
-  
+                const size_t maxLeafSize = 20,
+                const size_t minLeafSize = 8,
+                const size_t maxNumChildren = 5,
+                const size_t minNumChildren = 2,
+                const size_t firstDataIndex = 0);
+
   /**
-   * Construct this as an empty node with the specified parent.  Copying the parameters
-   * (maxLeafSize, minLeafSize, maxNumChildren, minNumChildren, firstDataIndex) from the parent.
+   * Construct this as an empty node with the specified parent.  Copying the
+   * parameters (maxLeafSize, minLeafSize, maxNumChildren, minNumChildren,
+   * firstDataIndex) from the parent.
    *
    * @param parentNode The parent of the node that is being constructed.
    */
-  explicit RectangleTree(RectangleTree<SplitType, DescentType, StatisticType, MatType>* parentNode);
-  
+  explicit RectangleTree(
+      RectangleTree<SplitType, DescentType, StatisticType, MatType>*
+      parentNode);
+
   /**
    * Create a rectangle tree by copying the other tree.  Be careful!  This can
    * take a long time and use a lot of memory.
-   * 
+   *
    * @param other The tree to be copied.
+   * @param deepCopy If false, the children are not recursively copied.
    */
   RectangleTree(const RectangleTree& other, const bool deepCopy = true);
 
@@ -154,8 +160,8 @@ class RectangleTree
 
   /**
    * Delete this node of the tree, but leave the stuff contained in it intact.
-   * This is used when splitting a node, where the data in this tree is moved to two
-   * other trees.
+   * This is used when splitting a node, where the data in this tree is moved to
+   * two other trees.
    */
   void SoftDelete();
 
@@ -166,55 +172,64 @@ class RectangleTree
 
   /**
    * Inserts a point into the tree. The point will be copied to the data matrix
-   * of the leaf node where it is finally inserted, but we pass by reference since
-   * it may be passed many times before it actually reaches a leaf.
+   * of the leaf node where it is finally inserted, but we pass by reference
+   * since it may be passed many times before it actually reaches a leaf.
+   *
    * @param point The point (arma::vec&) to be inserted.
    */
   void InsertPoint(const size_t point);
-  
+
   /**
-   * Inserts a point into the tree, tracking which levels have been inserted into.
-   * The point will be copied to the data matrix of the leaf node where it is 
-   * finally inserted, but we pass by reference since it may be passed many times
-   * before it actually reaches a leaf.
+   * Inserts a point into the tree, tracking which levels have been inserted
+   * into.  The point will be copied to the data matrix of the leaf node where
+   * it is finally inserted, but we pass by reference since it may be passed
+   * many times before it actually reaches a leaf.
+   *
    * @param point The point (arma::vec&) to be inserted.
-   * @param relevels The levels that have been reinserted to on this top level insertion.
+   * @param relevels The levels that have been reinserted to on this top level
+   *      insertion.
    */
   void InsertPoint(const size_t point, std::vector<bool>& relevels);
-  
+
   /**
-   * Inserts a node into the tree, tracking which levels have been inserted into.
-   * The node will be inserted so that the tree remains valid.
+   * Inserts a node into the tree, tracking which levels have been inserted
+   * into.  The node will be inserted so that the tree remains valid.
+   *
    * @param node The node to be inserted.
-   * @param level The depth that should match the node where this node is finally inserted.
-   * This should be the number returned by calling TreeDepth() from the node that originally
-   * contained "node".
-   * @param relevels The levels that have been reinserted to on this top level insertion.
+   * @param level The depth that should match the node where this node is
+   *      finally inserted.  This should be the number returned by calling
+   *      TreeDepth() from the node that originally contained "node".
+   * @param relevels The levels that have been reinserted to on this top level
+   *      insertion.
    */
-  void InsertNode(RectangleTree* node, const size_t level, std::vector<bool>& relevels);
+  void InsertNode(RectangleTree* node,
+                  const size_t level,
+                  std::vector<bool>& relevels);
 
   /**
-   * Deletes a point in the tree.  The point will be removed from the data matrix
-   * of the leaf node where it is store and the bounding rectangles will be updated.
-   * However, the point will be kept in the centeral dataset. (The user may remove it
-   * from there if he wants, but he must not change the indices of the other points.)
-   * Returns true if the point is successfully removed and false if it is not.
-   * (ie. the point is not in the tree)
+   * Deletes a point in the tree.  The point will be removed from the data
+   * matrix of the leaf node where it is store and the bounding rectangles will
+   * be updated.  However, the point will be kept in the centeral dataset. (The
+   * user may remove it from there if he wants, but he must not change the
+   * indices of the other points.) Returns true if the point is successfully
+   * removed and false if it is not.  (ie. the point is not in the tree)
    */
   bool DeletePoint(const size_t point);
-  
+
   /**
-   * Deletes a point in the tree, tracking levels.  The point will be removed from the data matrix
-   * of the leaf node where it is store and the bounding rectangles will be updated.
-   * However, the point will be kept in the centeral dataset. (The user may remove it
-   * from there if he wants, but he must not change the indices of the other points.)
-   * Returns true if the point is successfully removed and false if it is not.
-   * (ie. the point is not in the tree)
+   * Deletes a point in the tree, tracking levels.  The point will be removed
+   * from the data matrix of the leaf node where it is store and the bounding
+   * rectangles will be updated.  However, the point will be kept in the
+   * centeral dataset. (The user may remove it from there if he wants, but he
+   * must not change the indices of the other points.) Returns true if the point
+   * is successfully removed and false if it is not.  (ie. the point is not in
+   * the tree)
    */
   bool DeletePoint(const size_t point, std::vector<bool>& relevels);
-  
+
   /**
-   * Removes a node from the tree.  You are responsible for deleting it if you wish to do so.
+   * Removes a node from the tree.  You are responsible for deleting it if you
+   * wish to do so.
    */
   bool RemoveNode(const RectangleTree* node, std::vector<bool>& relevels);
 
@@ -253,7 +268,7 @@ class RectangleTree
   const StatisticType& Stat() const { return stat; }
   //! Modify the statistic object for this node.
   StatisticType& Stat() { return stat; }
-  
+
   //! Return the split history object of this node.
   const SplitHistoryStruct& SplitHistory() const { return splitHistory; }
   //! Modify the split history object of this node.
@@ -346,28 +361,29 @@ class RectangleTree
   double& ParentDistance() { return parentDistance; }
 
   /**
-    * Get the specified child.
-    *
-    * @param child Index of child to return.
-    */
-  inline RectangleTree<SplitType, DescentType, StatisticType, MatType>&
-    Child(const size_t child) const
+   * Get the specified child.
+   *
+   * @param child Index of child to return.
+   */
+  inline RectangleTree<SplitType, DescentType, StatisticType, MatType>& Child(
+      const size_t child) const
   {
     return *children[child];
   }
 
   /**
    * Modify the specified child.
-    *
-    * @param child Index of child to return.
+   *
+   * @param child Index of child to return.
    */
-  inline RectangleTree<SplitType, DescentType, StatisticType, MatType>&
-    Child(const size_t child)
+  inline RectangleTree<SplitType, DescentType, StatisticType, MatType>& Child(
+      const size_t child)
   {
     return *children[child];
   }
 
-  //! Return the number of points in this node (returns 0 if this node is not a leaf).
+  //! Return the number of points in this node (returns 0 if this node is not a
+  //! leaf).
   size_t NumPoints() const;
 
   /**
@@ -414,7 +430,6 @@ class RectangleTree
     return bound.RangeDistance(other->Bound());
   }
 
-
   //! Return the minimum distance to another point.
   template<typename VecType>
   double MinDistance(const VecType& point,
@@ -442,7 +457,7 @@ class RectangleTree
     return bound.RangeDistance(point);
   }
 
- /**
+  /**
    * Obtains the number of nodes in the tree, starting with this.
    */
   size_t TreeSize() const;
@@ -472,10 +487,10 @@ class RectangleTree
    * specified level.  TO BE REMOVED
    */
   RectangleTree(const size_t begin,
-                  const size_t count,
-                  HRectBound<> bound,
-                  StatisticType stat,
-                  const int maxLeafSize = 20) :
+                const size_t count,
+                HRectBound<> bound,
+                StatisticType stat,
+                const int maxLeafSize = 20) :
       begin(begin),
       count(count),
       bound(bound),
@@ -496,46 +511,47 @@ class RectangleTree
 
  public:
   /**
-   * Condense the bounding rectangles for this node based on the removal of
-   * the point specified by the arma::vec&.  This recurses up the tree.  If a node
+   * Condense the bounding rectangles for this node based on the removal of the
+   * point specified by the arma::vec&.  This recurses up the tree.  If a node
    * goes below the minimum fill, this function will fix the tree.
    *
    * @param point The arma::vec& of the point that was removed to require this
-   * condesation of the tree.
-   * @param usePoint True if we use the optimized version of the algorithm that is
-   * possible when we now what point was deleted.  False otherwise (eg. if we 
-   * deleted a node instead of a point).
+   *      condesation of the tree.
+   * @param usePoint True if we use the optimized version of the algorithm that
+   *      is possible when we now what point was deleted.  False otherwise (eg.
+   *      if we deleted a node instead of a point).
    */
-  void CondenseTree(const arma::vec& point, std::vector<bool>& relevels, const bool usePoint);
-    
+  void CondenseTree(const arma::vec& point,
+                    std::vector<bool>& relevels,
+                    const bool usePoint);
+
   /**
    * Shrink the bound object of this node for the removal of a point.
    *
-   * @param point  The arma::vec& of the point that was removed to require this
-   * shrinking.
+   * @param point The arma::vec& of the point that was removed to require this
+   *      shrinking.
    * @return true if the bound needed to be changed, false if it did not.
    */
   bool ShrinkBoundForPoint(const arma::vec& point);
-   
+
   /**
    * Shrink the bound object of this node for the removal of a child node.
    *
-   * @param bound  The HRectBound<>& of the bound that was removed to reqire this
-   * shrinking.
+   * @param bound The HRectBound<>& of the bound that was removed to reqire this
+   *      shrinking.
    * @return true if the bound needed to be changed, false if it did not.
    */
   bool ShrinkBoundForBound(const HRectBound<>& changedBound);
-  
+
   /**
    * Make an exact copy of this node, pointers and everything.
    */
   RectangleTree* ExactClone();
-  
+
   /**
    * Returns a string representation of this object.
    */
   std::string ToString() const;
-
 };
 
 }; // namespace tree
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index 485237e..88a0124 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -18,63 +18,63 @@ namespace mlpack {
 namespace tree {
 
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 RectangleTree<SplitType, DescentType, StatisticType, MatType>::RectangleTree(
-        MatType& data,
-        const size_t maxLeafSize,
-        const size_t minLeafSize,
-        const size_t maxNumChildren,
-        const size_t minNumChildren,
-        const size_t firstDataIndex) :
-maxNumChildren(maxNumChildren),
-minNumChildren(minNumChildren),
-numChildren(0),
-children(maxNumChildren + 1), // Add one to make splitting the node simpler
-parent(NULL),
-begin(0),
-count(0),
-maxLeafSize(maxLeafSize),
-minLeafSize(minLeafSize),
-bound(data.n_rows),
-splitHistory(bound.Dim()),
-parentDistance(0),
-dataset(data),
-points(maxLeafSize + 1), // Add one to make splitting the node simpler.
-localDataset(new MatType(data.n_rows, static_cast<int> (maxLeafSize) + 1)) // Add one to make splitting the node simpler
+    MatType& data,
+    const size_t maxLeafSize,
+    const size_t minLeafSize,
+    const size_t maxNumChildren,
+    const size_t minNumChildren,
+    const size_t firstDataIndex) :
+    maxNumChildren(maxNumChildren),
+    minNumChildren(minNumChildren),
+    numChildren(0),
+    children(maxNumChildren + 1), // Add one to make splitting the node simpler.
+    parent(NULL),
+    begin(0),
+    count(0),
+    maxLeafSize(maxLeafSize),
+    minLeafSize(minLeafSize),
+    bound(data.n_rows),
+    splitHistory(bound.Dim()),
+    parentDistance(0),
+    dataset(data),
+    points(maxLeafSize + 1), // Add one to make splitting the node simpler.
+    localDataset(new MatType(data.n_rows, static_cast<int> (maxLeafSize) + 1))
 {
   stat = StatisticType(*this);
 
   // For now, just insert the points in order.
   RectangleTree* root = this;
 
-  for (size_t i = firstDataIndex; i < data.n_cols; i++) {
+  for (size_t i = firstDataIndex; i < data.n_cols; i++)
     root->InsertPoint(i);
-  }
 }
 
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 RectangleTree<SplitType, DescentType, StatisticType, MatType>::RectangleTree(
-        RectangleTree<SplitType, DescentType, StatisticType, MatType>* parentNode) :
-maxNumChildren(parentNode->MaxNumChildren()),
-minNumChildren(parentNode->MinNumChildren()),
-numChildren(0),
-children(maxNumChildren + 1),
-parent(parentNode),
-begin(0),
-count(0),
-maxLeafSize(parentNode->MaxLeafSize()),
-minLeafSize(parentNode->MinLeafSize()),
-bound(parentNode->Bound().Dim()),
-splitHistory(bound.Dim()),
-parentDistance(0),
-dataset(parentNode->Dataset()),
-points(maxLeafSize + 1), // Add one to make splitting the node simpler.
-localDataset(new MatType(static_cast<int> (parentNode->Bound().Dim()), static_cast<int> (maxLeafSize) + 1)) // Add one to make splitting the node simpler
+    RectangleTree<SplitType, DescentType, StatisticType, MatType>* parentNode) :
+    maxNumChildren(parentNode->MaxNumChildren()),
+    minNumChildren(parentNode->MinNumChildren()),
+    numChildren(0),
+    children(maxNumChildren + 1),
+    parent(parentNode),
+    begin(0),
+    count(0),
+    maxLeafSize(parentNode->MaxLeafSize()),
+    minLeafSize(parentNode->MinLeafSize()),
+    bound(parentNode->Bound().Dim()),
+    splitHistory(bound.Dim()),
+    parentDistance(0),
+    dataset(parentNode->Dataset()),
+    points(maxLeafSize + 1), // Add one to make splitting the node simpler.
+    localDataset(new MatType(static_cast<int> (parentNode->Bound().Dim()),
+                             static_cast<int> (maxLeafSize) + 1))
 {
   stat = StatisticType(*this);
 }
@@ -84,38 +84,46 @@ localDataset(new MatType(static_cast<int> (parentNode->Bound().Dim()), static_ca
  * take a long time and use a lot of memory.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 RectangleTree<SplitType, DescentType, StatisticType, MatType>::RectangleTree(
-  const RectangleTree& other, const bool deepCopy) :
-  maxNumChildren(other.MaxNumChildren()),
-  minNumChildren(other.MinNumChildren()),
-  numChildren(other.NumChildren()),
-  children(maxNumChildren + 1),
-  parent(other.Parent()),
-  begin(other.Begin()),
-  count(other.Count()),
-  maxLeafSize(other.MaxLeafSize()),
-  minLeafSize(other.MinLeafSize()),
-  bound(other.bound),
-  splitHistory(other.SplitHistory()),
-  parentDistance(other.ParentDistance()),
-  dataset(other.dataset),
-  points(other.Points()),
-  localDataset(NULL)
+    const RectangleTree& other,
+    const bool deepCopy) :
+    maxNumChildren(other.MaxNumChildren()),
+    minNumChildren(other.MinNumChildren()),
+    numChildren(other.NumChildren()),
+    children(maxNumChildren + 1),
+    parent(other.Parent()),
+    begin(other.Begin()),
+    count(other.Count()),
+    maxLeafSize(other.MaxLeafSize()),
+    minLeafSize(other.MinLeafSize()),
+    bound(other.bound),
+    splitHistory(other.SplitHistory()),
+    parentDistance(other.ParentDistance()),
+    dataset(other.dataset),
+    points(other.Points()),
+    localDataset(NULL)
 {
-  if(deepCopy) {
-    if(numChildren > 0) {
-      for(size_t i = 0; i < numChildren; i++) {
+  if (deepCopy)
+  {
+    if (numChildren > 0)
+    {
+      for (size_t i = 0; i < numChildren; i++)
+      {
         children[i] = new RectangleTree(*(other.Children()[i]));
       }
-    } else {
+    }
+    else
+    {
       localDataset = new MatType(other.LocalDataset());
     }
-  } else {
+  }
+  else
+  {
     children = other.Children();
-    arma::mat& otherData = const_cast<arma::mat&> (other.LocalDataset());
+    arma::mat& otherData = const_cast<arma::mat&>(other.LocalDataset());
     localDataset = &otherData;
   }
 }
@@ -126,15 +134,14 @@ RectangleTree<SplitType, DescentType, StatisticType, MatType>::RectangleTree(
  * to any nodes which are children of this one.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-~RectangleTree()
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+RectangleTree<SplitType, DescentType, StatisticType, MatType>::~RectangleTree()
 {
-  for (int i = 0; i < numChildren; i++) {
+  for (int i = 0; i < numChildren; i++)
     delete children[i];
-  }
+
   delete localDataset;
 }
 
@@ -143,16 +150,16 @@ RectangleTree<SplitType, DescentType, StatisticType, MatType>::
  * split nodes and remove nodes (inserting and deleting points).
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-SoftDelete()
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::SoftDelete()
 {
   parent = NULL;
-  for (int i = 0; i < children.size(); i++) {
+
+  for (int i = 0; i < children.size(); i++)
     children[i] = NULL;
-  }
+
   numChildren = 0;
   delete this;
 }
@@ -161,11 +168,11 @@ SoftDelete()
  * Set the local dataset to null.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 void RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-NullifyData()
+    NullifyData()
 {
   localDataset = NULL;
 }
@@ -175,11 +182,11 @@ NullifyData()
  * by the heuristic.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-InsertPoint(const size_t point)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertPoint(
+    const size_t point)
 {
   // Expand the bound regardless of whether it is a leaf node.
   bound |= dataset.col(point);
@@ -187,8 +194,10 @@ InsertPoint(const size_t point)
   std::vector<bool> lvls(TreeDepth());
   for (int i = 0; i < lvls.size(); i++)
     lvls[i] = true;
+
   // If this is a leaf node, we stop here and add the point.
-  if (numChildren == 0) {
+  if (numChildren == 0)
+  {
     localDataset->col(count) = dataset.col(point);
     points[count++] = point;
     SplitNode(lvls);
@@ -197,26 +206,31 @@ InsertPoint(const size_t point)
 
   // If it is not a leaf node, we use the DescentHeuristic to choose a child
   // to which we recurse.
-  children[DescentType::ChooseDescentNode(this, dataset.col(point))]->InsertPoint(point, lvls);
+  const size_t descentNode = DescentType::ChooseDescentType(this,
+      dataset.col(point));
+  children[descentNode]->InsertPoint(point, lvls);
 }
 
 /**
  * Inserts a point into the tree, tracking which levels have been inserted into.
- * The point will be copied to the data matrix
- * of the leaf node where it is finally inserted, but we pass by reference since
- * it may be passed many times before it actually reaches a leaf.
+ * The point will be copied to the data matrix of the leaf node where it is
+ * finally inserted, but we pass by reference since it may be passed many times
+ * before it actually reaches a leaf.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertPoint(const size_t point, std::vector<bool>& relevels)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertPoint(
+    const size_t point,
+    std::vector<bool>& relevels)
 {
   // Expand the bound regardless of whether it is a leaf node.
   bound |= dataset.col(point);
 
   // If this is a leaf node, we stop here and add the point.
-  if (numChildren == 0) {
+  if (numChildren == 0)
+  {
     localDataset->col(count) = dataset.col(point);
     points[count++] = point;
     SplitNode(relevels);
@@ -225,29 +239,40 @@ void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertPoint(
 
   // If it is not a leaf node, we use the DescentHeuristic to choose a child
   // to which we recurse.
-  children[DescentType::ChooseDescentNode(this, dataset.col(point))]->InsertPoint(point, relevels);
+  const size_t descentNode = DescentType::ChooseDescentNode(this,
+      dataset.col(point));
+  children[descentNode]->InsertPoint(point, relevels);
 }
 
 /**
  * Inserts a node into the tree, tracking which levels have been inserted into.
+ *
  * @param node The node to be inserted.
  * @param level The level on which this node should be inserted.
- * @param relevels The levels that have been reinserted to on this top level insertion.
+ * @param relevels The levels that have been reinserted to on this top level
+ *      insertion.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertNode(RectangleTree* node, const size_t level, std::vector<bool>& relevels)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertNode(
+    RectangleTree* node,
+    const size_t level,
+    std::vector<bool>& relevels)
 {
   // Expand the bound regardless of the level.
   bound |= node->Bound();
-  if (level == TreeDepth()) {
+  if (level == TreeDepth())
+  {
     children[numChildren++] = node;
     node->Parent() = this;
     SplitNode(relevels);
-  } else {
-    children[DescentType::ChooseDescentNode(this, node)]->InsertNode(node, level, relevels);
+  }
+  else
+  {
+    const size_t descentNode = DescentType::ChooseDescentNode(this, node);
+    children[descentNode]->InsertNode(node, level, relevels);
   }
 }
 
@@ -256,34 +281,42 @@ void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertNode(R
  * shrink the rectangles if necessary.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-DeletePoint(const size_t point)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::DeletePoint(
+    const size_t point)
 {
-  //It is possible that this will cause a reinsertion, so we need to handle the lvls properly.
+  // It is possible that this will cause a reinsertion, so we need to handle the
+  // levels properly.
   RectangleTree* root = this;
   while (root->Parent() != NULL)
     root = root->Parent();
+
   std::vector<bool> lvls(root->TreeDepth());
   for (int i = 0; i < lvls.size(); i++)
     lvls[i] = true;
-  if (numChildren == 0) {
-    for (size_t i = 0; i < count; i++) {
-      if (points[i] == point) {
-        localDataset->col(i) = localDataset->col(--count); // decrement count
+
+  if (numChildren == 0)
+  {
+    for (size_t i = 0; i < count; i++)
+    {
+      if (points[i] == point)
+      {
+        localDataset->col(i) = localDataset->col(--count); // Decrement count.
         points[i] = points[count];
-        CondenseTree(dataset.col(point), lvls, true); // This function will ensure that minFill is satisfied.
+        // This function wil ensure that minFill is satisfied.
+        CondenseTree(dataset.col(point), lvls, true);
         return true;
       }
     }
   }
-  for (size_t i = 0; i < numChildren; i++) {
+
+  for (size_t i = 0; i < numChildren; i++)
     if (children[i]->Bound().Contains(dataset.col(point)))
       if (children[i]->DeletePoint(point, lvls))
         return true;
-  }
+
   return false;
 }
 
@@ -292,27 +325,33 @@ DeletePoint(const size_t point)
  * shrink the rectangles if necessary.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-DeletePoint(const size_t point, std::vector<bool>& relevels)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::DeletePoint(
+    const size_t point,
+    std::vector<bool>& relevels)
 {
-  if (numChildren == 0) {
-    for (size_t i = 0; i < count; i++) {
-      if (points[i] == point) {
-        localDataset->col(i) = localDataset->col(--count); // decrement count
+  if (numChildren == 0)
+  {
+    for (size_t i = 0; i < count; i++)
+    {
+      if (points[i] == point)
+      {
+        localDataset->col(i) = localDataset->col(--count);
         points[i] = points[count];
-        CondenseTree(dataset.col(point), relevels, true); // This function will ensure that minFill is satisfied.
+        // This function will ensure that minFill is satisfied.
+        CondenseTree(dataset.col(point), relevels, true);
         return true;
       }
     }
   }
-  for (size_t i = 0; i < numChildren; i++) {
+
+  for (size_t i = 0; i < numChildren; i++)
     if (children[i]->Bound().Contains(dataset.col(point)))
       if (children[i]->DeletePoint(point, relevels))
         return true;
-  }
+
   return false;
 }
 
@@ -321,68 +360,76 @@ DeletePoint(const size_t point, std::vector<bool>& relevels)
  * shrink the rectangles if necessary.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-RemoveNode(const RectangleTree* node, std::vector<bool>& relevels)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::RemoveNode(
+    const RectangleTree* node,
+    std::vector<bool>& relevels)
 {
-  for (size_t i = 0; i < numChildren; i++) {
-    if (children[i] == node) {
-      children[i] = children[--numChildren]; // Decrement numChildren
+  for (size_t i = 0; i < numChildren; i++)
+  {
+    if (children[i] == node)
+    {
+      children[i] = children[--numChildren]; // Decrement numChildren.
       CondenseTree(arma::vec(), relevels, false);
       return true;
     }
+
     bool contains = true;
-    for (size_t j = 0; j < node->Bound().Dim(); j++) {
+    for (size_t j = 0; j < node->Bound().Dim(); j++)
       contains &= Children()[i]->Bound()[j].Contains(node->Bound()[j]);
-    }
+
     if (contains)
       if (children[i]->RemoveNode(node, relevels))
         return true;
   }
+
   return false;
 }
 
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-TreeSize() const
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::TreeSize()
+    const
 {
   int n = 0;
-  for (int i = 0; i < numChildren; i++) {
+  for (int i = 0; i < numChildren; i++)
     n += children[i]->TreeSize();
-  }
-  return n + 1; // we add one for this node
+
+  return n + 1; // Add one for this node.
 }
 
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-TreeDepth() const
+    TreeDepth() const
 {
   int n = 1;
   RectangleTree<SplitType, DescentType, StatisticType, MatType>* currentNode =
-          const_cast<RectangleTree*> (this);
-  while (!currentNode->IsLeaf()) {
+      const_cast<RectangleTree*> (this);
+
+  while (!currentNode->IsLeaf())
+  {
     currentNode = currentNode->Children()[0];
     n++;
   }
+
   return n;
 }
 
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-IsLeaf() const
+    IsLeaf() const
 {
-  return numChildren == 0;
+  return (numChildren == 0);
 }
 
 /**
@@ -390,11 +437,11 @@ IsLeaf() const
  * This returns 0 unless the node is a leaf.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline double RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-FurthestPointDistance() const
+    FurthestPointDistance() const
 {
   if (!IsLeaf())
     return 0.0;
@@ -411,25 +458,26 @@ FurthestPointDistance() const
  * it will never be greater than this).
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline double RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-FurthestDescendantDistance() const
+    FurthestDescendantDistance() const
 {
-  //return the distance from the centroid to a corner of the bound.
+  // Return the distance from the centroid to a corner of the bound.
   return 0.5 * bound.Diameter();
 }
 
 /**
- * Return the number of points contained in this node.  Zero if it is a non-leaf node.
+ * Return the number of points contained in this node.  Zero if it is a non-leaf
+ * node.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-NumPoints() const
+    NumPoints() const
 {
   if (numChildren != 0) // This is not a leaf node.
     return 0;
@@ -441,19 +489,22 @@ NumPoints() const
  * Return the number of descendants under or in this node.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-NumDescendants() const
+    NumDescendants() const
 {
   if (numChildren == 0)
+  {
     return count;
-  else {
+  }
+  else
+  {
     size_t n = 0;
-    for (int i = 0; i < numChildren; i++) {
+    for (int i = 0; i < numChildren; i++)
       n += children[i]->NumDescendants();
-    }
+
     return n;
   }
 }
@@ -462,11 +513,11 @@ NumDescendants() const
  * Return the index of a particular descendant contained in this node.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-Descendant(const size_t index) const
+    Descendant(const size_t index) const
 {
   return (points[index]);
 }
@@ -475,124 +526,156 @@ Descendant(const size_t index) const
  * Return the index of a particular point contained in this node.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
 inline size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
-Point(const size_t index) const
+    Point(const size_t index) const
 {
   return points[index];
 }
 
 /**
- * Split the tree.  This calls the SplitType code to split a node.  This method should only
- * be called on a leaf node.
+ * Split the tree.  This calls the SplitType code to split a node.  This method
+ * should only be called on a leaf node.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::SplitNode(std::vector<bool>& relevels)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::SplitNode(
+    std::vector<bool>& relevels)
 {
-  if (numChildren == 0) {
-
+  if (numChildren == 0)
+  {
     // Check to see if we are full.
     if (count <= maxLeafSize)
       return; // We don't need to split.
 
-    // If we are full, then we need to split (or at least try).  The SplitType takes
-    // care of this and of moving up the tree if necessary.
+    // If we are full, then we need to split (or at least try).  The SplitType
+    // takes care of this and of moving up the tree if necessary.
     SplitType::SplitLeafNode(this, relevels);
-  } else {
+  }
+  else
+  {
     // Check to see if we are full.
     if (numChildren <= maxNumChildren)
       return; // We don't need to split.
 
-    // If we are full, then we need to split (or at least try).  The SplitType takes
-    // care of this and of moving up the tree if necessary.
+    // If we are full, then we need to split (or at least try).  The SplitType
+    // takes care of this and of moving up the tree if necessary.
     SplitType::SplitNonLeafNode(this, relevels);
   }
 }
 
 /**
- * Condense the tree.  This shrinks the bounds and moves up the tree if applicable.
- * If a node goes below minimum fill, this code will deal with it.
+ * Condense the tree.  This shrinks the bounds and moves up the tree if
+ * applicable.  If a node goes below minimum fill, this code will deal with it.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-void RectangleTree<SplitType, DescentType, StatisticType, MatType>::CondenseTree(const arma::vec& point, std::vector<bool>& relevels, const bool usePoint)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+void RectangleTree<SplitType, DescentType, StatisticType, MatType>::
+    CondenseTree(const arma::vec& point,
+                 std::vector<bool>& relevels,
+                 const bool usePoint)
 {
-  // First delete the node if we need to.  There's no point in shrinking the bound first.
-  if (IsLeaf() && count < minLeafSize && parent != NULL) { //We can't delete the root node
-    
-for (size_t i = 0; i < parent->NumChildren(); i++) {
-      if (parent->Children()[i] == this) {
-        parent->Children()[i] = parent->Children()[--parent->NumChildren()]; // decrement numChildren
-        
+  // First delete the node if we need to.  There's no point in shrinking the
+  // bound first.
+  if (IsLeaf() && count < minLeafSize && parent != NULL)
+  {
+    // We can't delete the root node.
+    for (size_t i = 0; i < parent->NumChildren(); i++)
+    {
+      if (parent->Children()[i] == this)
+      {
+        // Decrement numChildren.
+        parent->Children()[i] = parent->Children()[--parent->NumChildren()];
+
         // We find the root and shrink bounds at the same time.
-	bool stillShrinking = true;
-        RectangleTree<SplitType, DescentType, StatisticType, MatType>* root = parent;
-        while (root->Parent() != NULL) {
-	  if(stillShrinking)
-	    stillShrinking = root->ShrinkBoundForBound(bound);
+        bool stillShrinking = true;
+        RectangleTree<SplitType, DescentType, StatisticType, MatType>* root =
+            parent;
+        while (root->Parent() != NULL)
+        {
+          if (stillShrinking)
+            stillShrinking = root->ShrinkBoundForBound(bound);
           root = root->Parent();
-	}
-        if(stillShrinking)
+        }
+        if (stillShrinking)
           stillShrinking = root->ShrinkBoundForBound(bound);
 
-	// Reinsert the points at the root node.
-        for (size_t j = 0; j < count; j++) {
+        // Reinsert the points at the root node.
+        for (size_t j = 0; j < count; j++)
           root->InsertPoint(points[j], relevels);
-        }
 
-        parent->CondenseTree(point, relevels, usePoint); // This will check the MinFill of the parent.
-        //Now it should be safe to delete this node.
+        // This will check the minFill of the parent.
+        parent->CondenseTree(point, relevels, usePoint);
+        // Now it should be safe to delete this node.
         SoftDelete();
+
         return;
       }
     }
     // Control should never reach here.
-    assert(true == false);
-  } else if (!IsLeaf() && numChildren < minNumChildren) {
-    if (parent != NULL) { // The normal case.  We need to be careful with the root.
-      for (size_t j = 0; j < parent->NumChildren(); j++) {
-        if (parent->Children()[j] == this) {
-          parent->Children()[j] = parent->Children()[--parent->NumChildren()]; // decrement numChildren
+    assert(false);
+  }
+  else if (!IsLeaf() && numChildren < minNumChildren)
+  {
+    if (parent != NULL)
+    {
+      // The normal case.  We need to be careful with the root.
+      for (size_t j = 0; j < parent->NumChildren(); j++)
+      {
+        if (parent->Children()[j] == this)
+        {
+          // Decrement numChildren.
+          parent->Children()[j] = parent->Children()[--parent->NumChildren()];
           size_t level = TreeDepth();
 
           // We find the root and shrink bounds at the same time.
-	  bool stillShrinking = true;
-          RectangleTree<SplitType, DescentType, StatisticType, MatType>* root = parent;
-          while (root->Parent() != NULL) {
-	    if(stillShrinking)
-	      stillShrinking = root->ShrinkBoundForBound(bound);
+          bool stillShrinking = true;
+          RectangleTree<SplitType, DescentType, StatisticType, MatType>* root =
+              parent;
+          while (root->Parent() != NULL)
+          {
+            if (stillShrinking)
+              stillShrinking = root->ShrinkBoundForBound(bound);
             root = root->Parent();
-	  }
-          if(stillShrinking)
+          }
+          if (stillShrinking)
             stillShrinking = root->ShrinkBoundForBound(bound);
 
-	  // Reinsert the nodes at the root node.
-	  for (size_t i = 0; i < numChildren; i++)
+          // Reinsert the nodes at the root node.
+          for (size_t i = 0; i < numChildren; i++)
             root->InsertNode(children[i], level, relevels);
 
-          parent->CondenseTree(point, relevels, usePoint); // This will check the MinFill of the parent.
-          //Now it should be safe to delete this node.
+          // This will check the minFill of the point.
+          parent->CondenseTree(point, relevels, usePoint);
+          // Now it should be safe to delete this node.
           SoftDelete();
+
           return;
         }
       }
-    } else if (numChildren == 1) { // If there are multiple children, we can't do anything to the root.
-      RectangleTree<SplitType, DescentType, StatisticType, MatType>* child = children[0];
-      for (size_t i = 0; i < child->NumChildren(); i++) {
+    }
+    else if (numChildren == 1)
+    {
+      // If there are multiple children, we can't do anything to the root.
+      RectangleTree<SplitType, DescentType, StatisticType, MatType>* child =
+          children[0];
+      for (size_t i = 0; i < child->NumChildren(); i++)
         children[i] = child->Children()[i];
-      }
       numChildren = child->NumChildren();
-      for (size_t i = 0; i < child->Count(); i++) { // In case the tree has a height of two.
+
+      for (size_t i = 0; i < child->Count(); i++)
+      {
+        // In case the tree has a height of two.
         points[i] = child->Points()[i];
         localDataset->col(i) = child->LocalDataset().col(i);
       }
+
       count = child->Count();
       child->SoftDelete();
       return;
@@ -600,76 +683,104 @@ for (size_t i = 0; i < parent->NumChildren(); i++) {
   }
 
   // If we didn't delete it, shrink the bound if we need to.
-  if (usePoint && ShrinkBoundForPoint(point) && parent != NULL) {
+  if (usePoint && ShrinkBoundForPoint(point) && parent != NULL)
     parent->CondenseTree(point, relevels, usePoint);
-  } else if (!usePoint && ShrinkBoundForBound(bound) && parent != NULL) {
+  else if (!usePoint && ShrinkBoundForBound(bound) && parent != NULL)
     parent->CondenseTree(point, relevels, usePoint);
-  }
 }
 
 /**
  * Shrink the bound so it fits tightly after the removal of this point.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::ShrinkBoundForPoint(const arma::vec& point)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
+    ShrinkBoundForPoint(const arma::vec& point)
 {
   bool shrunk = false;
-  if (IsLeaf()) {
-    for (size_t i = 0; i < bound.Dim(); i++) {
-      if (bound[i].Lo() == point[i]) {
+  if (IsLeaf())
+  {
+    for (size_t i = 0; i < bound.Dim(); i++)
+    {
+      if (bound[i].Lo() == point[i])
+      {
         double min = DBL_MAX;
-        for (size_t j = 0; j < count; j++) {
+        for (size_t j = 0; j < count; j++)
+        {
           if (localDataset->col(j)[i] < min)
             min = localDataset->col(j)[i];
         }
-        if (bound[i].Lo() < min) {
+
+        if (bound[i].Lo() < min)
+        {
           shrunk = true;
           bound[i].Lo() = min;
-        } else if (min < bound[i].Lo()) {
-          assert(true == false); // we have a problem.
         }
-      } else if (bound[i].Hi() == point[i]) {
+        else if (min < bound[i].Lo())
+        {
+          assert(false); // We have a problem.
+        }
+      }
+      else if (bound[i].Hi() == point[i])
+      {
         double max = -1 * DBL_MAX;
-        for (size_t j = 0; j < count; j++) {
+        for (size_t j = 0; j < count; j++)
+        {
           if (localDataset->col(j)[i] > max)
             max = localDataset->col(j)[i];
         }
-        if (bound[i].Hi() > max) {
+
+        if (bound[i].Hi() > max)
+        {
           shrunk = true;
           bound[i].Hi() = max;
-        } else if (max > bound[i].Hi()) {
-          assert(true == false); // we have a problem.
+        }
+        else if (max > bound[i].Hi())
+        {
+          assert(false); // We have a problem.
         }
       }
     }
-  } else {
-    for (size_t i = 0; i < bound.Dim(); i++) {
-      if (bound[i].Lo() == point[i]) {
+  }
+  else
+  {
+    for (size_t i = 0; i < bound.Dim(); i++)
+    {
+      if (bound[i].Lo() == point[i])
+      {
         double min = DBL_MAX;
-        for (size_t j = 0; j < numChildren; j++) {
+        for (size_t j = 0; j < numChildren; j++)
+        {
           if (children[j]->Bound()[i].Lo() < min)
             min = children[j]->Bound()[i].Lo();
         }
-        if (bound[i].Lo() < min) {
+
+        if (bound[i].Lo() < min)
+        {
           shrunk = true;
           bound[i].Lo() = min;
         }
-      } else if(bound[i].Hi() == point[i]) {
-        double max = -1 * DBL_MAX;
-        for (size_t j = 0; j < numChildren; j++) {
+      }
+      else if (bound[i].Hi() == point[i])
+      {
+        double max = -DBL_MAX;
+        for (size_t j = 0; j < numChildren; j++)
+        {
           if (children[j]->Bound()[i].Hi() > max)
             max = children[j]->Bound()[i].Hi();
         }
-        if (bound[i].Hi() > max) {
+
+        if (bound[i].Hi() > max)
+        {
           shrunk = true;
           bound[i].Hi() = max;
         }
       }
     }
   }
+
   return shrunk;
 }
 
@@ -677,21 +788,28 @@ bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::ShrinkBoundF
  * Shrink the bound so it fits tightly after the removal of another bound.
  */
 template<typename SplitType,
-typename DescentType,
-typename StatisticType,
-typename MatType>
-bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::ShrinkBoundForBound(const HRectBound<>& /* unused */)
+         typename DescentType,
+         typename StatisticType,
+         typename MatType>
+bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::
+    ShrinkBoundForBound(const HRectBound<>& /* unused */)
 {
-  double sum = 0; // Using the sum is safe since none of the dimensions can increase.
-  //I think it may be faster to just recalculate the whole thing.
-  for (size_t i = 0; i < bound.Dim(); i++) {
+  // Using the sum is safe since none of the dimensions can increase.
+  double sum = 0;
+
+  // I think it may be faster to just recalculate the whole thing.
+  for (size_t i = 0; i < bound.Dim(); i++)
+  {
     sum += bound[i].Width();
     bound[i].Lo() = DBL_MAX;
-    bound[i].Hi() = -1 * DBL_MAX;
+    bound[i].Hi() = -DBL_MAX;
   }
-  for (size_t i = 0; i < numChildren; i++) {
+
+  for (size_t i = 0; i < numChildren; i++)
+  {
     bound |= children[i]->Bound();
   }
+
   double sum2 = 0;
   for (size_t i = 0; i < bound.Dim(); i++)
     sum2 += bound[i].Width();
@@ -706,7 +824,8 @@ template<typename SplitType,
 typename DescentType,
 typename StatisticType,
 typename MatType>
-std::string RectangleTree<SplitType, DescentType, StatisticType, MatType>::ToString() const
+std::string RectangleTree<SplitType, DescentType, StatisticType, MatType>::
+    ToString() const
 {
   std::ostringstream convert;
   convert << "RectangleTree [" << this << "]" << std::endl;
@@ -723,16 +842,16 @@ std::string RectangleTree<SplitType, DescentType, StatisticType, MatType>::ToStr
   convert << "  Min num of children: " << minNumChildren << std::endl;
   convert << "  Parent address: " << parent << std::endl;
 
-  // How many levels should we print?  This will print the top 3 levels (counting the root).
-  if (parent == NULL || parent->Parent() == NULL) {
-    for (int i = 0; i < numChildren; i++) {
+  // How many levels should we print?  This will print the top 3 levels
+  // (counting the root).
+  if (parent == NULL || parent->Parent() == NULL)
+    for (int i = 0; i < numChildren; i++)
       convert << children[i]->ToString();
-    }
-  }
+
   return convert.str();
 }
 
-}; //namespace tree
-}; //namespace mlpack
+}; // namespace tree
+}; // namespace mlpack
 
 #endif

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