[mlpack-svn] r10358 - mlpack/trunk/src/mlpack/core/tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 23 03:04:35 EST 2011


Author: rcurtin
Date: 2011-11-23 03:04:35 -0500 (Wed, 23 Nov 2011)
New Revision: 10358

Modified:
   mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
   mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/dballbound.hpp
   mlpack/trunk/src/mlpack/core/tree/dballbound_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp
   mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
   mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/statistic.hpp
Log:
Fix formatting as per #153.


Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -44,7 +44,8 @@
  */
 template<typename Bound,
          typename Statistic = EmptyStatistic>
-class BinarySpaceTree {
+class BinarySpaceTree
+{
  private:
   //! The left child node.
   BinarySpaceTree *left_;

Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -24,7 +24,8 @@
     begin_(0), /* This root node starts at index 0, */
     count_(data.n_cols), /* and spans all of the dataset. */
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Do the actual splitting of this node.
   SplitNode(data);
 }
@@ -38,7 +39,8 @@
     begin_(0),
     count_(data.n_cols),
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Initialize old_from_new correctly.
   old_from_new.resize(data.n_cols);
   for (size_t i = 0; i < data.n_cols; i++)
@@ -58,7 +60,8 @@
     begin_(0),
     count_(data.n_cols),
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Initialize the old_from_new vector correctly.
   old_from_new.resize(data.n_cols);
   for (size_t i = 0; i < data.n_cols; i++)
@@ -83,7 +86,8 @@
     begin_(begin_in),
     count_(count_in),
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Perform the actual splitting.
   SplitNode(data);
 }
@@ -99,7 +103,8 @@
     begin_(begin_in),
     count_(count_in),
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Hopefully the vector is initialized correctly!  We can't check that
   // entirely but we can do a minor sanity check.
   assert(old_from_new.size() == data.n_cols);
@@ -120,7 +125,8 @@
     begin_(begin_in),
     count_(count_in),
     bound_(data.n_rows),
-    stat_() {
+    stat_()
+{
   // Hopefully the vector is initialized correctly!  We can't check that
   // entirely but we can do a minor sanity check.
   assert(old_from_new.size() == data.n_cols);
@@ -141,7 +147,8 @@
     begin_(0),
     count_(0),
     bound_(),
-    stat_() {
+    stat_()
+{
   // Nothing to do.
 }
 
@@ -151,7 +158,8 @@
  * nodes which are children of this one.
  */
 template<typename Bound, typename Statistic>
-BinarySpaceTree<Bound, Statistic>::~BinarySpaceTree() {
+BinarySpaceTree<Bound, Statistic>::~BinarySpaceTree()
+{
   if (left_)
     delete left_;
   if (right_)
@@ -172,8 +180,8 @@
 template<typename Bound, typename Statistic>
 const BinarySpaceTree<Bound, Statistic>*
 BinarySpaceTree<Bound, Statistic>::FindByBeginCount(size_t begin_q,
-                                                    size_t count_q) const {
-
+                                                    size_t count_q) const
+{
   mlpack::Log::Assert(begin_q >= begin_);
   mlpack::Log::Assert(count_q <= count_);
   if (begin_ == begin_q && count_ == count_q)
@@ -200,8 +208,8 @@
 template<typename Bound, typename Statistic>
 BinarySpaceTree<Bound, Statistic>*
 BinarySpaceTree<Bound, Statistic>::FindByBeginCount(size_t begin_q,
-                                                    size_t count_q) {
-
+                                                    size_t count_q)
+{
   mlpack::Log::Assert(begin_q >= begin_);
   mlpack::Log::Assert(count_q <= count_);
   if (begin_ == begin_q && count_ == count_q)
@@ -215,27 +223,32 @@
 }
 
 template<typename Bound, typename Statistic>
-const Bound& BinarySpaceTree<Bound, Statistic>::bound() const {
+inline const Bound& BinarySpaceTree<Bound, Statistic>::bound() const
+{
   return bound_;
 }
 
 template<typename Bound, typename Statistic>
-Bound& BinarySpaceTree<Bound, Statistic>::bound() {
+inline Bound& BinarySpaceTree<Bound, Statistic>::bound()
+{
   return bound_;
 }
 
 template<typename Bound, typename Statistic>
-const Statistic& BinarySpaceTree<Bound, Statistic>::stat() const {
+inline const Statistic& BinarySpaceTree<Bound, Statistic>::stat() const
+{
   return stat_;
 }
 
 template<typename Bound, typename Statistic>
-Statistic& BinarySpaceTree<Bound, Statistic>::stat() {
+inline Statistic& BinarySpaceTree<Bound, Statistic>::stat()
+{
   return stat_;
 }
 
 template<typename Bound, typename Statistic>
-bool BinarySpaceTree<Bound, Statistic>::is_leaf() const {
+inline bool BinarySpaceTree<Bound, Statistic>::is_leaf() const
+{
   return !left_;
 }
 
@@ -243,9 +256,9 @@
  * Gets the left branch of the tree.
  */
 template<typename Bound, typename Statistic>
-BinarySpaceTree<Bound, Statistic>*
-BinarySpaceTree<Bound, Statistic>::left() const {
-  // TODO: Const correctness
+inline BinarySpaceTree<Bound, Statistic>*
+BinarySpaceTree<Bound, Statistic>::left() const
+{
   return left_;
 }
 
@@ -253,9 +266,9 @@
  * Gets the right branch.
  */
 template<typename Bound, typename Statistic>
-BinarySpaceTree<Bound, Statistic>*
-BinarySpaceTree<Bound, Statistic>::right() const {
-  // TODO: Const correctness
+inline BinarySpaceTree<Bound, Statistic>*
+BinarySpaceTree<Bound, Statistic>::right() const
+{
   return right_;
 }
 
@@ -263,7 +276,8 @@
  * Gets the index of the begin point of this subset.
  */
 template<typename Bound, typename Statistic>
-size_t BinarySpaceTree<Bound, Statistic>::begin() const {
+inline size_t BinarySpaceTree<Bound, Statistic>::begin() const
+{
   return begin_;
 }
 
@@ -271,7 +285,8 @@
  * Gets the index one beyond the last index in the series.
  */
 template<typename Bound, typename Statistic>
-size_t BinarySpaceTree<Bound, Statistic>::end() const {
+inline size_t BinarySpaceTree<Bound, Statistic>::end() const
+{
   return begin_ + count_;
 }
 
@@ -279,22 +294,26 @@
  * Gets the number of points in this subset.
  */
 template<typename Bound, typename Statistic>
-size_t BinarySpaceTree<Bound, Statistic>::count() const {
+inline size_t BinarySpaceTree<Bound, Statistic>::count() const
+{
   return count_;
 }
 
 template<typename Bound, typename Statistic>
-void BinarySpaceTree<Bound, Statistic>::Print() const {
-  printf("node: %d to %d: %d points total\n",
-      begin_, begin_ + count_ - 1, count_);
-  if (!is_leaf()) {
+void BinarySpaceTree<Bound, Statistic>::Print() const
+{
+  printf("node: %d to %d: %d points total\n", begin_, begin_ + count_ - 1,
+      count_);
+  if (!is_leaf())
+  {
     left_->Print();
     right_->Print();
   }
 }
 
 template<typename Bound, typename Statistic>
-void BinarySpaceTree<Bound, Statistic>::SplitNode(arma::mat& data) {
+void BinarySpaceTree<Bound, Statistic>::SplitNode(arma::mat& data)
+{
   // This should be a single function for Bound.
   // We need to expand the bounds of this node properly.
   for (size_t i = begin_; i < (begin_ + count_); i++)
@@ -309,10 +328,12 @@
   double max_width = -1;
 
   // Find the split dimension.
-  for (size_t d = 0; d < data.n_rows; d++) {
+  for (size_t d = 0; d < data.n_rows; d++)
+  {
     double width = bound_[d].width();
 
-    if (width > max_width) {
+    if (width > max_width)
+    {
       max_width = width;
       split_dim = d;
     }
@@ -341,7 +362,8 @@
 template<typename Bound, typename Statistic>
 void BinarySpaceTree<Bound, Statistic>::SplitNode(
     arma::mat& data,
-    std::vector<size_t>& old_from_new) {
+    std::vector<size_t>& old_from_new)
+{
   // This should be a single function for Bound.
   // We need to expand the bounds of this node properly.
   for (size_t i = begin_; i < (begin_ + count_); i++)
@@ -356,10 +378,12 @@
   double max_width = -1;
 
   // Find the split dimension.
-  for (size_t d = 0; d < data.n_rows; d++) {
+  for (size_t d = 0; d < data.n_rows; d++)
+  {
     double width = bound_[d].width();
 
-    if (width > max_width) {
+    if (width > max_width)
+    {
       max_width = width;
       split_dim = d;
     }
@@ -389,7 +413,8 @@
 size_t BinarySpaceTree<Bound, Statistic>::GetSplitIndex(
     arma::mat& data,
     int split_dim,
-    double split_val) {
+    double split_val)
+{
   // This method modifies the input dataset.  We loop both from the left and
   // right sides of the points contained in this node.  The points less than
   // split_val should be on the left side of the matrix, and the points greater
@@ -404,7 +429,8 @@
   while ((data(split_dim, right) >= split_val) && (left <= right))
     right--;
 
-  while(left <= right) {
+  while(left <= right)
+  {
     // Swap columns.
     data.swap_cols(left, right);
 
@@ -432,7 +458,8 @@
     arma::mat& data,
     int split_dim,
     double split_val,
-    std::vector<size_t>& old_from_new) {
+    std::vector<size_t>& old_from_new)
+{
   // This method modifies the input dataset.  We loop both from the left and
   // right sides of the points contained in this node.  The points less than
   // split_val should be on the left side of the matrix, and the points greater
@@ -447,7 +474,8 @@
   while ((data(split_dim, right) >= split_val) && (left <= right))
     right--;
 
-  while(left <= right) {
+  while(left <= right)
+  {
     // Swap columns.
     data.swap_cols(left, right);
 

Modified: mlpack/trunk/src/mlpack/core/tree/dballbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/dballbound.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/dballbound.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -1,5 +1,5 @@
 /**
- * @file tree/dballbound.h
+ * @file dballbound.hpp
  *
  * Bounds that are useful for binary space partitioning trees.
  * Interface to a ball bound that works in arbitrary metric spaces.
@@ -25,109 +25,111 @@
  * To initialize this, set the radius with @c set_radius
  * and set the point by initializing @c point() directly.
  */
-template<typename TMetric = mlpack::metric::SquaredEuclideanDistance, typename TPoint = arma::vec>
-class DBallBound {
-  public:
-    typedef TPoint Point;
-    typedef TMetric Metric;
+template<typename TMetric = mlpack::metric::SquaredEuclideanDistance,
+         typename TPoint = arma::vec>
+class DBallBound
+{
+ public:
+  typedef TPoint Point;
+  typedef TMetric Metric;
 
-  private:
-    double radius_;
-    TPoint center_;
+ private:
+  double radius_;
+  TPoint center_;
 
-  public:
-    /***
-     * Return the radius of the ball bound.
-     */
-    double radius() const { return radius_; }
+ public:
+  /**
+   * Return the radius of the ball bound.
+   */
+  double radius() const { return radius_; }
 
-    /***
-     * Set the radius of the bound.
-     */
-    void set_radius(double d) { radius_ = d; }
+  /**
+   * Set the radius of the bound.
+   */
+  void set_radius(double d) { radius_ = d; }
 
-    /***
-     * Return the center point.
-     */
-    const TPoint& center() const { return center_; }
+  /**
+   * Return the center point.
+   */
+  const TPoint& center() const { return center_; }
 
-    /***
-     * Return the center point.
-     */
-    TPoint& center() { return center_; }
+  /**
+   * Return the center point.
+   */
+  TPoint& center() { return center_; }
 
-    /**
-     * Determines if a point is within this bound.
-     */
-    bool Contains(const Point& point) const;
+  /**
+   * Determines if a point is within this bound.
+   */
+  bool Contains(const Point& point) const;
 
-    /**
-     * Gets the center.
-     *
-     * Don't really use this directly.  This is only here for consistency
-     * with DHrectBound, so it can plug in more directly if a "centroid"
-     * is needed.
-     */
-    void CalculateMidpoint(Point *centroid) const;
+  /**
+   * Gets the center.
+   *
+   * Don't really use this directly.  This is only here for consistency
+   * with DHrectBound, so it can plug in more directly if a "centroid"
+   * is needed.
+   */
+  void CalculateMidpoint(Point *centroid) const;
 
-    /**
-     * Calculates minimum bound-to-point squared distance.
-     */
-    double MinDistance(const Point& point) const;
-    double MinDistanceSq(const Point& point) const;
+  /**
+   * Calculates minimum bound-to-point squared distance.
+   */
+  double MinDistance(const Point& point) const;
+  double MinDistanceSq(const Point& point) const;
 
-    /**
-     * Calculates minimum bound-to-bound squared distance.
-     */
-    double MinDistance(const DBallBound& other) const;
-    double MinDistanceSq(const DBallBound& other) const;
+  /**
+   * Calculates minimum bound-to-bound squared distance.
+   */
+  double MinDistance(const DBallBound& other) const;
+  double MinDistanceSq(const DBallBound& other) const;
 
-    /**
-     * Computes maximum distance.
-     */
-    double MaxDistance(const Point& point) const;
-    double MaxDistanceSq(const Point& point) const;
+  /**
+   * Computes maximum distance.
+   */
+  double MaxDistance(const Point& point) const;
+  double MaxDistanceSq(const Point& point) const;
 
-    /**
-     * Computes maximum distance.
-     */
-    double MaxDistance(const DBallBound& other) const;
-    double MaxDistanceSq(const DBallBound& other) const;
+  /**
+   * Computes maximum distance.
+   */
+  double MaxDistance(const DBallBound& other) const;
+  double MaxDistanceSq(const DBallBound& other) const;
 
-    /**
-     * Calculates minimum and maximum bound-to-bound squared distance.
-     *
-     * Example: bound1.MinDistanceSq(other) for minimum squared distance.
-     */
-    math::Range RangeDistance(const DBallBound& other) const;
-    math::Range RangeDistanceSq(const DBallBound& other) const;
+  /**
+   * Calculates minimum and maximum bound-to-bound squared distance.
+   *
+   * Example: bound1.MinDistanceSq(other) for minimum squared distance.
+   */
+  math::Range RangeDistance(const DBallBound& other) const;
+  math::Range RangeDistanceSq(const DBallBound& other) const;
 
-    /**
-     * Calculates closest-to-their-midpoint bounding box distance,
-     * i.e. calculates their midpoint and finds the minimum box-to-point
-     * distance.
-     *
-     * Equivalent to:
-     * <code>
-     * other.CalcMidpoint(&other_midpoint)
-     * return MinDistanceSqToPoint(other_midpoint)
-     * </code>
-     */
-    double MinToMid(const DBallBound& other) const;
-    double MinToMidSq(const DBallBound& other) const;
+  /**
+   * Calculates closest-to-their-midpoint bounding box distance,
+   * i.e. calculates their midpoint and finds the minimum box-to-point
+   * distance.
+   *
+   * Equivalent to:
+   * <code>
+   * other.CalcMidpoint(&other_midpoint)
+   * return MinDistanceSqToPoint(other_midpoint)
+   * </code>
+   */
+  double MinToMid(const DBallBound& other) const;
+  double MinToMidSq(const DBallBound& other) const;
 
-    /**
-     * Computes minimax distance, where the other node is trying to avoid me.
-     */
-    double MinimaxDistance(const DBallBound& other) const;
-    double MinimaxDistanceSq(const DBallBound& other) const;
+  /**
+   * Computes minimax distance, where the other node is trying to avoid me.
+   */
+  double MinimaxDistance(const DBallBound& other) const;
+  double MinimaxDistanceSq(const DBallBound& other) const;
 
-    /**
-     * Calculates midpoint-to-midpoint bounding box distance.
-     */
-    double MidDistance(const DBallBound& other) const;
-    double MidDistanceSq(const DBallBound& other) const;
-    double MidDistance(const Point& point) const;
+  /**
+   * Calculates midpoint-to-midpoint bounding box distance.
+   */
+  double MidDistance(const DBallBound& other) const;
+  double MidDistanceSq(const DBallBound& other) const;
+  double MidDistance(const Point& point) const;
 };
 
 }; // namespace bound

Modified: mlpack/trunk/src/mlpack/core/tree/dballbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/dballbound_impl.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/dballbound_impl.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -1,5 +1,5 @@
 /**
- * @file tree/dballbound_impl.h
+ * @file dballbound_impl.hpp
  *
  * Bounds that are useful for binary space partitioning trees.
  * Implementation of DBallBound ball bound metric policy class.
@@ -18,7 +18,8 @@
  * Determines if a point is within the bound.
  */
 template<typename TMetric, typename TPoint>
-bool DBallBound<TMetric, TPoint>::Contains(const Point& point) const {
+bool DBallBound<TMetric, TPoint>::Contains(const Point& point) const
+{
   return MidDistance(point) <= radius_;
 }
 
@@ -30,7 +31,8 @@
  * is needed.
  */
 template<typename TMetric, typename TPoint>
-void DBallBound<TMetric, TPoint>::CalculateMidpoint(Point *centroid) const {
+void DBallBound<TMetric, TPoint>::CalculateMidpoint(Point *centroid) const
+{
   (*centroid) = center_;
 }
 
@@ -38,12 +40,14 @@
  * Calculates minimum bound-to-point squared distance.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinDistance(const Point& point) const {
+double DBallBound<TMetric, TPoint>::MinDistance(const Point& point) const
+{
   return math::ClampNonNegative(MidDistance(point) - radius_);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinDistanceSq(const Point& point) const {
+double DBallBound<TMetric, TPoint>::MinDistanceSq(const Point& point) const
+{
   return std::pow(MinDistance(point), 2);
 }
 
@@ -51,13 +55,15 @@
  * Calculates minimum bound-to-bound squared distance.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinDistance(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinDistance(const DBallBound& other) const
+{
   double delta = MidDistance(other.center_) - radius_ - other.radius_;
   return math::ClampNonNegative(delta);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinDistanceSq(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinDistanceSq(const DBallBound& other) const
+{
   return std::pow(MinDistance(other), 2);
 }
 
@@ -65,12 +71,14 @@
  * Computes maximum distance.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MaxDistance(const Point& point) const {
+double DBallBound<TMetric, TPoint>::MaxDistance(const Point& point) const
+{
   return MidDistance(point) + radius_;
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MaxDistanceSq(const Point& point) const {
+double DBallBound<TMetric, TPoint>::MaxDistanceSq(const Point& point) const
+{
   return std::pow(MaxDistance(point), 2);
 }
 
@@ -78,12 +86,14 @@
  * Computes maximum distance.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MaxDistance(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MaxDistance(const DBallBound& other) const
+{
   return MidDistance(other.center_) + radius_ + other.radius_;
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MaxDistanceSq(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MaxDistanceSq(const DBallBound& other) const
+{
   return std::pow(MaxDistance(other), 2);
 }
 
@@ -93,7 +103,9 @@
  * Example: bound1.MinDistanceSq(other) for minimum squared distance.
  */
 template<typename TMetric, typename TPoint>
-math::Range DBallBound<TMetric, TPoint>::RangeDistance(const DBallBound& other) const {
+math::Range DBallBound<TMetric, TPoint>::RangeDistance(
+    const DBallBound& other) const
+{
   double delta = MidDistance(other.center_);
   double sumradius = radius_ + other.radius_;
   return math::Range(
@@ -102,7 +114,9 @@
 }
 
 template<typename TMetric, typename TPoint>
-math::Range DBallBound<TMetric, TPoint>::RangeDistanceSq(const DBallBound& other) const {
+math::Range DBallBound<TMetric, TPoint>::RangeDistanceSq(
+    const DBallBound& other) const
+{
   double delta = MidDistance(other.center_);
   double sumradius = radius_ + other.radius_;
   return math::Range(
@@ -122,13 +136,15 @@
  * </code>
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinToMid(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinToMid(const DBallBound& other) const
+{
   double delta = MidDistance(other.center_) - radius_;
   return math::ClampNonNegative(delta);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinToMidSq(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinToMidSq(const DBallBound& other) const
+{
   return std::pow(MinToMid(other), 2);
 }
 
@@ -136,13 +152,17 @@
  * Computes minimax distance, where the other node is trying to avoid me.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinimaxDistance(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinimaxDistance(
+    const DBallBound& other) const
+{
   double delta = MidDistance(other.center_) + other.radius_ - radius_;
   return math::ClampNonNegative(delta);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MinimaxDistanceSq(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MinimaxDistanceSq(
+    const DBallBound& other) const
+{
   return std::pow(MinimaxDistance(other), 2);
 }
 
@@ -150,17 +170,20 @@
  * Calculates midpoint-to-midpoint bounding box distance.
  */
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MidDistance(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MidDistance(const DBallBound& other) const
+{
   return MidDistance(other.center_);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MidDistanceSq(const DBallBound& other) const {
+double DBallBound<TMetric, TPoint>::MidDistanceSq(const DBallBound& other) const
+{
   return std::pow(MidDistance(other), 2);
 }
 
 template<typename TMetric, typename TPoint>
-double DBallBound<TMetric, TPoint>::MidDistance(const Point& point) const {
+double DBallBound<TMetric, TPoint>::MidDistance(const Point& point) const
+{
   return Metric::Evaluate(center_, point);
 }
 

Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -1,5 +1,5 @@
 /**
- * @file tree/hrectbound.h
+ * @file hrectbound.hpp
  *
  * Bounds that are useful for binary space partitioning trees.
  *
@@ -8,7 +8,6 @@
  *
  * @experimental
  */
-
 #ifndef __MLPACK_CORE_TREE_HRECTBOUND_HPP
 #define __MLPACK_CORE_TREE_HRECTBOUND_HPP
 
@@ -24,7 +23,8 @@
  * Template parameter t_pow is the metric to use; use 2 for Euclidean (L2).
  */
 template<int t_pow = 2>
-class HRectBound {
+class HRectBound
+{
  public:
   /**
    * Empty constructor; creates a bound of dimensionality 0.

Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -1,5 +1,5 @@
 /**
- * @file tree/hrectbound_impl.h
+ * @file hrectbound_impl.hpp
  *
  * Implementation of hyper-rectangle bound policy class.
  * Template parameter t_pow is the metric to use; use 2 for Euclidean (L2).
@@ -25,7 +25,8 @@
 template<int t_pow>
 HRectBound<t_pow>::HRectBound() :
     dim_(0),
-    bounds_(NULL) { /* nothing to do */ }
+    bounds_(NULL)
+{ /* nothing to do */ }
 
 /**
  * Initializes to specified dimensionality with each dimension the empty
@@ -34,7 +35,8 @@
 template<int t_pow>
 HRectBound<t_pow>::HRectBound(size_t dimension) :
     dim_(dimension),
-    bounds_(new math::Range[dim_]) { /* nothing to do */ }
+    bounds_(new math::Range[dim_])
+{ /* nothing to do */ }
 
 /***
  * Copy constructor necessary to prevent memory leaks.
@@ -42,7 +44,8 @@
 template<int t_pow>
 HRectBound<t_pow>::HRectBound(const HRectBound& other) :
     dim_(other.dim()),
-    bounds_(new math::Range[dim_]) {
+    bounds_(new math::Range[dim_])
+{
   // Copy other bounds over.
   for (size_t i = 0; i < dim_; i++)
     bounds_[i] = other[i];
@@ -52,7 +55,8 @@
  * Same as the copy constructor.
  */
 template<int t_pow>
-HRectBound<t_pow>& HRectBound<t_pow>::operator=(const HRectBound& other) {
+HRectBound<t_pow>& HRectBound<t_pow>::operator=(const HRectBound& other)
+{
   if (bounds_)
     delete[] bounds_;
 
@@ -70,7 +74,8 @@
  * Destructor: clean up memory
  */
 template<int t_pow>
-HRectBound<t_pow>::~HRectBound() {
+HRectBound<t_pow>::~HRectBound()
+{
   if (bounds_)
     delete[] bounds_;
 }
@@ -79,17 +84,18 @@
  * Resets all dimensions to the empty set.
  */
 template<int t_pow>
-void HRectBound<t_pow>::Clear() {
-  for (size_t i = 0; i < dim_; i++) {
+void HRectBound<t_pow>::Clear()
+{
+  for (size_t i = 0; i < dim_; i++)
     bounds_[i] = math::Range();
-  }
 }
 
 /**
  * Gets the range for a particular dimension.
  */
 template<int t_pow>
-const math::Range HRectBound<t_pow>::operator[](size_t i) const {
+const math::Range HRectBound<t_pow>::operator[](size_t i) const
+{
   return bounds_[i];
 }
 
@@ -97,7 +103,8 @@
  * Sets the range for the given dimension.
  */
 template<int t_pow>
-math::Range& HRectBound<t_pow>::operator[](size_t i) {
+math::Range& HRectBound<t_pow>::operator[](size_t i)
+{
   return bounds_[i];
 }
 
@@ -107,28 +114,30 @@
  * @param centroid Vector which the centroid will be written to.
  */
 template<int t_pow>
-void HRectBound<t_pow>::Centroid(arma::vec& centroid) const {
+void HRectBound<t_pow>::Centroid(arma::vec& centroid) const
+{
   // set size correctly if necessary
-  if(!(centroid.n_elem == dim_))
+  if (!(centroid.n_elem == dim_))
     centroid.set_size(dim_);
 
-  for(size_t i = 0; i < dim_; i++) {
+  for (size_t i = 0; i < dim_; i++)
     centroid(i) = bounds_[i].mid();
-  }
 }
 
 /**
  * Calculates minimum bound-to-point squared distance.
  */
 template<int t_pow>
-double HRectBound<t_pow>::MinDistance(const arma::vec& point) const {
+double HRectBound<t_pow>::MinDistance(const arma::vec& point) const
+{
   assert(point.n_elem == dim_);
 
   double sum = 0;
   const math::Range* mbound = bounds_;
 
   double lower, higher;
-  for(size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     lower = mbound->lo - point[d]; // negative if point[d] > bounds_[d]
     higher = point[d] - mbound->hi; // negative if point[d] < bounds_[d]
 
@@ -153,7 +162,8 @@
  * Example: bound1.MinDistanceSq(other) for minimum squared distance.
  */
 template<int t_pow>
-double HRectBound<t_pow>::MinDistance(const HRectBound& other) const {
+double HRectBound<t_pow>::MinDistance(const HRectBound& other) const
+{
   assert(dim_ == other.dim_);
 
   double sum = 0;
@@ -161,7 +171,8 @@
   const math::Range* obound = other.bounds_;
 
   double lower, higher;
-  for (size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     lower = obound->lo - mbound->hi;
     higher = mbound->lo - obound->hi;
     // We invoke the following:
@@ -181,15 +192,16 @@
  * Calculates maximum bound-to-point squared distance.
  */
 template<int t_pow>
-double HRectBound<t_pow>::MaxDistance(const arma::vec& point) const {
+double HRectBound<t_pow>::MaxDistance(const arma::vec& point) const
+{
   double sum = 0;
 
   assert(point.n_elem == dim_);
 
-  for (size_t d = 0; d < dim_; d++) {
-    double v = fabs(std::max(
-      point[d] - bounds_[d].lo,
-      bounds_[d].hi - point[d]));
+  for (size_t d = 0; d < dim_; d++)
+  {
+    double v = fabs(std::max(point[d] - bounds_[d].lo,
+        bounds_[d].hi - point[d]));
     sum += pow(v, (double) t_pow);
   }
 
@@ -200,17 +212,18 @@
  * Computes maximum distance.
  */
 template<int t_pow>
-double HRectBound<t_pow>::MaxDistance(const HRectBound& other) const {
+double HRectBound<t_pow>::MaxDistance(const HRectBound& other) const
+{
   double sum = 0;
 
   assert(dim_ == other.dim_);
 
   double v;
-  for(size_t d = 0; d < dim_; d++) {
-    v = fabs(std::max(
-      other.bounds_[d].hi - bounds_[d].lo,
-      bounds_[d].hi - other.bounds_[d].lo));
-    sum += pow(v, (double) t_pow); // v is non-negative
+  for (size_t d = 0; d < dim_; d++)
+  {
+    v = fabs(std::max(other.bounds_[d].hi - bounds_[d].lo,
+        bounds_[d].hi - other.bounds_[d].lo));
+    sum += pow(v, (double) t_pow); // v is non-negative.
   }
 
   return pow(sum, 2.0 / (double) t_pow);
@@ -220,56 +233,69 @@
  * Calculates minimum and maximum bound-to-bound squared distance.
  */
 template<int t_pow>
-math::Range HRectBound<t_pow>::RangeDistance(const HRectBound& other) const {
+math::Range HRectBound<t_pow>::RangeDistance(const HRectBound& other) const
+{
   double sum_lo = 0;
   double sum_hi = 0;
 
   assert(dim_ == other.dim_);
 
   double v1, v2, v_lo, v_hi;
-  for (size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     v1 = other.bounds_[d].lo - bounds_[d].hi;
     v2 = bounds_[d].lo - other.bounds_[d].hi;
-    // one of v1 or v2 is negative
-    if(v1 >= v2) {
-      v_hi = -v2; // make it nonnegative
-      v_lo = (v1 > 0) ? v1 : 0; // force to be 0 if negative
-    } else {
-      v_hi = -v1; // make it nonnegative
-      v_lo = (v2 > 0) ? v2 : 0; // force to be 0 if negative
+    // One of v1 or v2 is negative.
+    if (v1 >= v2)
+    {
+      v_hi = -v2; // Make it nonnegative.
+      v_lo = (v1 > 0) ? v1 : 0; // Force to be 0 if negative.
     }
+    else
+    {
+      v_hi = -v1; // Make it nonnegative.
+      v_lo = (v2 > 0) ? v2 : 0; // Force to be 0 if negative.
+    }
 
     sum_lo += pow(v_lo, (double) t_pow);
     sum_hi += pow(v_hi, (double) t_pow);
   }
 
   return math::Range(pow(sum_lo, 2.0 / (double) t_pow),
-                pow(sum_hi, 2.0 / (double) t_pow));
+      pow(sum_hi, 2.0 / (double) t_pow));
 }
 
 /**
  * Calculates minimum and maximum bound-to-point squared distance.
  */
 template<int t_pow>
-math::Range HRectBound<t_pow>::RangeDistance(const arma::vec& point) const {
+math::Range HRectBound<t_pow>::RangeDistance(const arma::vec& point) const
+{
   double sum_lo = 0;
   double sum_hi = 0;
 
   assert(point.n_elem == dim_);
 
   double v1, v2, v_lo, v_hi;
-  for(size_t d = 0; d < dim_; d++) {
+  for(size_t d = 0; d < dim_; d++)
+  {
     v1 = bounds_[d].lo - point[d]; // Negative if point[d] > lo.
     v2 = point[d] - bounds_[d].hi; // Negative if point[d] < hi.
     // One of v1 or v2 (or both) is negative.
-    if(v1 >= 0) { // point[d] <= bounds_[d].lo.
+    if (v1 >= 0) // point[d] <= bounds_[d].lo.
+    {
       v_hi = -v2; // v2 will be larger but must be negated.
       v_lo = v1;
-    } else { // point[d] is between lo and hi, or greater than hi.
-      if (v2 >= 0) {
+    }
+    else // point[d] is between lo and hi, or greater than hi.
+    {
+      if (v2 >= 0)
+      {
         v_hi = -v1; // v1 will be larger, but must be negated.
         v_lo = v2;
-      } else {
+      }
+      else
+      {
         v_hi = -std::min(v1, v2); // Both are negative, but we need the larger.
         v_lo = 0;
       }
@@ -280,19 +306,19 @@
   }
 
   return math::Range(pow(sum_lo, 2.0 / (double) t_pow),
-                pow(sum_hi, 2.0 / (double) t_pow));
+      pow(sum_hi, 2.0 / (double) t_pow));
 }
 
 /**
  * Expands this region to include a new point.
  */
 template<int t_pow>
-HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const arma::vec& vector) {
+HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const arma::vec& vector)
+{
   Log::Assert(vector.n_elem == dim_);
 
-  for (size_t i = 0; i < dim_; i++) {
+  for (size_t i = 0; i < dim_; i++)
     bounds_[i] |= vector[i];
-  }
 
   return *this;
 }
@@ -301,12 +327,12 @@
  * Expands this region to encompass another bound.
  */
 template<int t_pow>
-HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const HRectBound& other) {
+HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const HRectBound& other)
+{
   assert(other.dim_ == dim_);
 
-  for (size_t i = 0; i < dim_; i++) {
+  for (size_t i = 0; i < dim_; i++)
     bounds_[i] |= other.bounds_[i];
-  }
 
   return *this;
 }
@@ -315,11 +341,12 @@
  * Determines if a point is within this bound.
  */
 template<int t_pow>
-bool HRectBound<t_pow>::Contains(const arma::vec& point) const {
-  for (size_t i = 0; i < point.n_elem; i++) {
-    if (!bounds_[i].Contains(point(i))) {
+bool HRectBound<t_pow>::Contains(const arma::vec& point) const
+{
+  for (size_t i = 0; i < point.n_elem; i++)
+  {
+    if (!bounds_[i].Contains(point(i)))
       return false;
-    }
   }
 
   return true;

Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -20,7 +20,8 @@
  * Template parameter t_pow is the metric to use; use 2 for Euclidean (L2).
  */
 template<int t_pow = 2>
-class PeriodicHRectBound {
+class PeriodicHRectBound
+{
  public:
   /**
    * Empty constructor.

Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -25,7 +25,8 @@
 PeriodicHRectBound<t_pow>::PeriodicHRectBound() :
       bounds_(NULL),
       dim_(0),
-      box_(/* empty */) { /* nothing to do */ }
+      box_(/* empty */)
+{ /* nothing to do */ }
 
 /**
  * Specifies the box size, but not dimensionality.
@@ -34,13 +35,15 @@
 PeriodicHRectBound<t_pow>::PeriodicHRectBound(arma::vec box) :
       bounds_(new math::Range[box.n_rows]),
       dim_(box.n_rows),
-      box_(box) { /* nothing to do */ }
+      box_(box)
+{ /* nothing to do */ }
 
 /***
  * Copy constructor.
  */
 template<int t_pow>
-PeriodicHRectBound<t_pow>::PeriodicHRectBound(const PeriodicHRectBound& other) {
+PeriodicHRectBound<t_pow>::PeriodicHRectBound(const PeriodicHRectBound& other)
+{
   // not done yet
 }
 
@@ -49,7 +52,8 @@
  */
 template<int t_pow>
 PeriodicHRectBound<t_pow>& PeriodicHRectBound<t_pow>::operator=(
-    const PeriodicHRectBound& other) {
+    const PeriodicHRectBound& other)
+{
   // not done yet
 
   return *this;
@@ -59,7 +63,8 @@
  * Destructor: clean up memory
  */
 template<int t_pow>
-PeriodicHRectBound<t_pow>::~PeriodicHRectBound() {
+PeriodicHRectBound<t_pow>::~PeriodicHRectBound()
+{
   if(bounds_)
     delete[] bounds_;
 }
@@ -68,7 +73,8 @@
  * Modifies the box_ to the desired dimenstions.
  */
 template<int t_pow>
-void PeriodicHRectBound<t_pow>::SetBoxSize(arma::vec box) {
+void PeriodicHRectBound<t_pow>::SetBoxSize(arma::vec box)
+{
   box_ = box;
 }
 
@@ -76,7 +82,8 @@
  * Resets all dimensions to the empty set.
  */
 template<int t_pow>
-void PeriodicHRectBound<t_pow>::Clear() {
+void PeriodicHRectBound<t_pow>::Clear()
+{
   for (size_t i = 0; i < dim_; i++)
     bounds_[i] = math::Range();
 }
@@ -85,7 +92,8 @@
  * Gets the range for a particular dimension.
  */
 template<int t_pow>
-const math::Range PeriodicHRectBound<t_pow>::operator[](size_t i) const {
+const math::Range PeriodicHRectBound<t_pow>::operator[](size_t i) const
+{
   return bounds_[i];
 }
 
@@ -93,18 +101,20 @@
  * Sets the range for the given dimension.
  */
 template<int t_pow>
-math::Range& PeriodicHRectBound<t_pow>::operator[](size_t i) {
+math::Range& PeriodicHRectBound<t_pow>::operator[](size_t i)
+{
   return bounds_[i];
 }
 
 /** Calculates the midpoint of the range */
 template<int t_pow>
-void PeriodicHRectBound<t_pow>::Centroid(arma::vec& centroid) const {
+void PeriodicHRectBound<t_pow>::Centroid(arma::vec& centroid) const
+{
   // set size correctly if necessary
-  if(!(centroid.n_elem == dim_))
+  if (!(centroid.n_elem == dim_))
     centroid.set_size(dim_);
 
-  for(size_t i = 0; i < dim_; i++)
+  for (size_t i = 0; i < dim_; i++)
     centroid(i) = bounds_[i].mid();
 }
 
@@ -112,18 +122,22 @@
  * Calculates minimum bound-to-point squared distance.
  */
 template<int t_pow>
-double PeriodicHRectBound<t_pow>::MinDistance(const arma::vec& point) const {
+double PeriodicHRectBound<t_pow>::MinDistance(const arma::vec& point) const
+{
   double sum = 0;
 
-  for (size_t d = 0; d < dim_; d++){
+  for (size_t d = 0; d < dim_; d++)
+  {
     double a = point[d];
     double v = 0, bh;
     bh = bounds_[d].hi - bounds_[d].lo;
     bh = bh - floor(bh / box_[d]) * box_[d];
     a = a - bounds_[d].lo;
     a = a - floor(a / box_[d]) * box_[d];
+
     if (bh > a)
       v = std::min( a - bh, box_[d]-a);
+
     sum += pow(v, (double) t_pow);
   }
 
@@ -137,22 +151,32 @@
  */
 template<int t_pow>
 double PeriodicHRectBound<t_pow>::MinDistance(
-    const PeriodicHRectBound& other) const {
+    const PeriodicHRectBound& other) const
+{
   double sum = 0;
 
   mlpack::Log::Assert(dim_ == other.dim_);
 
   for (size_t d = 0; d < dim_; d++){
     double v = 0, d1, d2, d3;
-    d1 = ((bounds_[d].hi > bounds_[d].lo) | (other.bounds_[d].hi > other.bounds_[d].lo)) *
-      std::min(other.bounds_[d].lo - bounds_[d].hi, bounds_[d].lo - other.bounds_[d].hi);
-    d2 = ((bounds_[d].hi > bounds_[d].lo) & (other.bounds_[d].hi > other.bounds_[d].lo)) *
-      std::min(other.bounds_[d].lo - bounds_[d].hi, bounds_[d].lo - other.bounds_[d].hi + box_[d]);
-    d3 = ((bounds_[d].hi > bounds_[d].lo) & (other.bounds_[d].hi > other.bounds_[d].lo)) *
-      std::min(other.bounds_[d].lo - bounds_[d].hi + box_[d], bounds_[d].lo - other.bounds_[d].hi);
+    d1 = ((bounds_[d].hi > bounds_[d].lo) |
+          (other.bounds_[d].hi > other.bounds_[d].lo)) *
+        std::min(other.bounds_[d].lo - bounds_[d].hi,
+                 bounds_[d].lo - other.bounds_[d].hi);
+    d2 = ((bounds_[d].hi > bounds_[d].lo) &
+          (other.bounds_[d].hi > other.bounds_[d].lo)) *
+        std::min(other.bounds_[d].lo - bounds_[d].hi,
+                 bounds_[d].lo - other.bounds_[d].hi + box_[d]);
+    d3 = ((bounds_[d].hi > bounds_[d].lo) &
+          (other.bounds_[d].hi > other.bounds_[d].lo)) *
+        std::min(other.bounds_[d].lo - bounds_[d].hi + box_[d],
+                 bounds_[d].lo - other.bounds_[d].hi);
+
     v = (d1 + fabs(d1)) + (d2 + fabs(d2)) + (d3 + fabs(d3));
+
     sum += pow(v, (double) t_pow);
   }
+
   return pow(sum, 2.0 / (double) t_pow) / 4.0;
 }
 
@@ -160,26 +184,35 @@
  * Calculates maximum bound-to-point squared distance.
  */
 template<int t_pow>
-double PeriodicHRectBound<t_pow>::MaxDistance(const arma::vec& point) const {
+double PeriodicHRectBound<t_pow>::MaxDistance(const arma::vec& point) const
+{
   double sum = 0;
 
-  for (size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     double b = point[d];
     double v = box_[d] / 2.0;
     double ah, al;
+
     ah = bounds_[d].hi - b;
     ah = ah - floor(ah / box_[d]) * box_[d];
-    if (ah < v) {
+
+    if (ah < v)
+    {
       v = ah;
-    } else {
+    }
+    else
+    {
       al = bounds_[d].lo - b;
       al = al - floor(al / box_[d]) * box_[d];
-      if (al > v) {
+
+      if (al > v)
         v = (2 * v) - al;
-      }
     }
+
     sum += pow(fabs(v), (double) t_pow);
   }
+
   return pow(sum, 2.0 / (double) t_pow);
 }
 
@@ -188,14 +221,17 @@
  */
 template<int t_pow>
 double PeriodicHRectBound<t_pow>::MaxDistance(
-    const PeriodicHRectBound& other) const {
+    const PeriodicHRectBound& other) const
+{
   double sum = 0;
 
   mlpack::Log::Assert(dim_ == other.dim_);
 
-  for (size_t d = 0; d < dim_; d++){
+  for (size_t d = 0; d < dim_; d++)
+  {
     double v = box_[d] / 2.0;
     double dh, dl;
+
     dh = bounds_[d].hi - other.bounds_[d].lo;
     dh = dh - floor(dh / box_[d]) * box_[d];
     dl = other.bounds_[d].hi - bounds_[d].lo;
@@ -204,6 +240,7 @@
 
     sum += pow(v, (double) t_pow);
   }
+
   return pow(sum, 2.0 / (double) t_pow);
 }
 
@@ -211,21 +248,27 @@
  * Calculates minimum and maximum bound-to-point squared distance.
  */
 template<int t_pow>
-math::Range PeriodicHRectBound<t_pow>::RangeDistance(const arma::vec& point) const {
+math::Range PeriodicHRectBound<t_pow>::RangeDistance(
+    const arma::vec& point) const
+{
   double sum_lo = 0;
   double sum_hi = 0;
 
   mlpack::Log::Assert(point.n_elem == dim_);
 
   double v1, v2, v_lo, v_hi;
-  for(size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     v1 = bounds_[d].lo - point[d];
     v2 = point[d] - bounds_[d].hi;
-    // one of v1 or v2 is negative
-    if(v1 >= 0) {
+    // One of v1 or v2 is negative.
+    if (v1 >= 0)
+    {
       v_hi = -v2;
       v_lo = v1;
-    } else {
+    }
+    else
+    {
       v_hi = -v1;
       v_lo = v2;
     }
@@ -235,7 +278,7 @@
   }
 
   return math::Range(pow(sum_lo, 2.0 / (double) t_pow),
-                pow(sum_hi, 2.0 / (double) t_pow));
+      pow(sum_hi, 2.0 / (double) t_pow));
 }
 
 /**
@@ -243,31 +286,36 @@
  */
 template<int t_pow>
 math::Range PeriodicHRectBound<t_pow>::RangeDistance(
-    const PeriodicHRectBound& other) const {
+    const PeriodicHRectBound& other) const
+{
   double sum_lo = 0;
   double sum_hi = 0;
 
   mlpack::Log::Assert(dim_ == other.dim_);
 
   double v1, v2, v_lo, v_hi;
-  for (size_t d = 0; d < dim_; d++) {
+  for (size_t d = 0; d < dim_; d++)
+  {
     v1 = other.bounds_[d].lo - bounds_[d].hi;
     v2 = bounds_[d].lo - other.bounds_[d].hi;
-    // one of v1 or v2 is negative
-    if(v1 >= v2) {
-      v_hi = -v2; // make it nonnegative
-      v_lo = (v1 > 0) ? v1 : 0; // force to be 0 if negative
-    } else {
-      v_hi = -v1; // make it nonnegative
-      v_lo = (v2 > 0) ? v2 : 0; // force to be 0 if negative
+    // One of v1 or v2 is negative.
+    if(v1 >= v2)
+    {
+      v_hi = -v2; // Make it nonnegative.
+      v_lo = (v1 > 0) ? v1 : 0; // Force to be 0 if negative.
     }
+    else
+    {
+      v_hi = -v1; // Make it nonnegative.
+      v_lo = (v2 > 0) ? v2 : 0; // Force to be 0 if negative.
+    }
 
     sum_lo += pow(v_lo, (double) t_pow);
     sum_hi += pow(v_hi, (double) t_pow);
   }
 
   return math::Range(pow(sum_lo, 2.0 / (double) t_pow),
-                pow(sum_hi, 2.0 / (double) t_pow));
+      pow(sum_hi, 2.0 / (double) t_pow));
 }
 
 /**
@@ -275,12 +323,12 @@
  */
 template<int t_pow>
 PeriodicHRectBound<t_pow>& PeriodicHRectBound<t_pow>::operator|=(
-    const arma::vec& vector) {
+    const arma::vec& vector)
+{
   assert(vector.n_elem == dim_);
 
-  for (size_t i = 0; i < dim_; i++) {
+  for (size_t i = 0; i < dim_; i++)
     bounds_[i] |= vector[i];
-  }
 
   return *this;
 }
@@ -290,7 +338,8 @@
  */
 template<int t_pow>
 PeriodicHRectBound<t_pow>& PeriodicHRectBound<t_pow>::operator|=(
-    const PeriodicHRectBound& other) {
+    const PeriodicHRectBound& other)
+{
   assert(other.dim_ == dim_);
 
   for (size_t i = 0; i < dim_; i++)
@@ -303,7 +352,8 @@
  * Determines if a point is within this bound.
  */
 template<int t_pow>
-bool PeriodicHRectBound<t_pow>::Contains(const arma::vec& point) const {
+bool PeriodicHRectBound<t_pow>::Contains(const arma::vec& point) const
+{
   for (size_t i = 0; i < point.n_elem; i++)
     if (!bounds_[i].Contains(point(i)))
       return false;

Modified: mlpack/trunk/src/mlpack/core/tree/statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/statistic.hpp	2011-11-23 07:39:04 UTC (rev 10357)
+++ mlpack/trunk/src/mlpack/core/tree/statistic.hpp	2011-11-23 08:04:35 UTC (rev 10358)
@@ -17,7 +17,8 @@
  *
  * @experimental
  */
-class EmptyStatistic {
+class EmptyStatistic
+{
   public:
     EmptyStatistic() {}
     ~EmptyStatistic() {}




More information about the mlpack-svn mailing list