[mlpack-svn] r13543 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Sep 13 13:57:34 EDT 2012
Author: rcurtin
Date: 2012-09-13 13:57:34 -0400 (Thu, 13 Sep 2012)
New Revision: 13543
Modified:
mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp
mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
Log:
Update some documentation for clarity and coding standards.
Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp 2012-09-13 14:50:28 UTC (rev 13542)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp 2012-09-13 17:57:34 UTC (rev 13543)
@@ -73,36 +73,48 @@
void Centroid(arma::vec& centroid) const;
/**
- * Calculates minimum bound-to-point squared distance.
+ * Calculates minimum bound-to-point distance.
+ *
+ * @param point Point to which the minimum distance is requested.
*/
template<typename VecType>
double MinDistance(const VecType& point) const;
/**
- * Calculates minimum bound-to-bound squared distance.
+ * Calculates minimum bound-to-bound distance.
*
- * Example: bound1.MinDistanceSq(other) for minimum squared distance.
+ * @param other Bound to which the minimum distance is requested.
*/
double MinDistance(const HRectBound& other) const;
/**
* Calculates maximum bound-to-point squared distance.
+ *
+ * @param point Point to which the maximum distance is requested.
*/
template<typename VecType>
double MaxDistance(const VecType& point) const;
/**
* Computes maximum distance.
+ *
+ * @param other Bound to which the maximum distance is requested.
*/
double MaxDistance(const HRectBound& other) const;
/**
- * Calculates minimum and maximum bound-to-bound squared distance.
+ * Calculates minimum and maximum bound-to-bound distance.
+ *
+ * @param other Bound to which the minimum and maximum distances are
+ * requested.
*/
math::Range RangeDistance(const HRectBound& other) const;
/**
- * Calculates minimum and maximum bound-to-point squared distance.
+ * Calculates minimum and maximum bound-to-point distance.
+ *
+ * @param point Point to which the minimum and maximum distances are
+ * requested.
*/
template<typename VecType>
math::Range RangeDistance(const VecType& point) const;
@@ -129,7 +141,9 @@
bool Contains(const VecType& point) const;
private:
+ //! The dimensionality of the bound.
size_t dim;
+ //! The bounds for each dimension.
math::Range* bounds;
};
Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp 2012-09-13 14:50:28 UTC (rev 13542)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp 2012-09-13 17:57:34 UTC (rev 13543)
@@ -18,13 +18,13 @@
namespace bound {
/**
- * Empty constructor
+ * Empty constructor.
*/
template<int Power, bool TakeRoot>
HRectBound<Power, TakeRoot>::HRectBound() :
dim(0),
bounds(NULL)
-{ /* nothing to do */ }
+{ /* Nothing to do. */ }
/**
* Initializes to specified dimensionality with each dimension the empty
@@ -34,7 +34,7 @@
HRectBound<Power, TakeRoot>::HRectBound(const size_t dimension) :
dim(dimension),
bounds(new math::Range[dim])
-{ /* nothing to do */ }
+{ /* Nothing to do. */ }
/***
* Copy constructor necessary to prevent memory leaks.
@@ -56,13 +56,17 @@
HRectBound<Power, TakeRoot>& HRectBound<Power, TakeRoot>::operator=(
const HRectBound& other)
{
- if (bounds)
- delete[] bounds;
+ if (dim != other.Dim())
+ {
+ // Reallocation is necessary.
+ if (bounds)
+ delete[] bounds;
- // We can't just copy the bounds_ pointer like the default copy constructor
- // will!
- dim = other.Dim();
- bounds = new math::Range[dim];
+ dim = other.Dim();
+ bounds = new math::Range[dim];
+ }
+
+ // Now copy each of the bound values.
for (size_t i = 0; i < dim; i++)
bounds[i] = other[i];
More information about the mlpack-svn
mailing list