[mlpack-git] master: Change template name to be similar to the definition of hrectbound. (8285c31)

gitdub at mlpack.org gitdub at mlpack.org
Fri May 27 20:21:36 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/3d1ed0fa731b4f34d0c02ae63c37d4106e23a9f8...2fe9e82b63507ef60440c22c93d85d058023535c

>---------------------------------------------------------------

commit 8285c31068b66c5bc5ebdefe8b1ea46010678176
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Fri May 27 21:18:41 2016 -0300

    Change template name to be similar to the definition of hrectbound.


>---------------------------------------------------------------

8285c31068b66c5bc5ebdefe8b1ea46010678176
 src/mlpack/core/tree/ballbound.hpp      | 18 +++----
 src/mlpack/core/tree/ballbound_impl.hpp | 94 ++++++++++++++++-----------------
 2 files changed, 55 insertions(+), 57 deletions(-)

diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp
index d61e88a..14f289a 100644
--- a/src/mlpack/core/tree/ballbound.hpp
+++ b/src/mlpack/core/tree/ballbound.hpp
@@ -16,13 +16,13 @@ namespace bound {
 
 /**
  * Ball bound encloses a set of points at a specific distance (radius) from a
- * specific point (center). TMetricType is the custom metric type that defaults
+ * specific point (center). MetricType is the custom metric type that defaults
  * to the Euclidean (L2) distance.
  *
- * @tparam TMetricType metric type used in the distance measure.
+ * @tparam MetricType metric type used in the distance measure.
  * @tparam VecType Type of vector (arma::vec or arma::sp_vec or similar).
  */
-template<typename TMetricType = metric::LMetric<2, true>,
+template<typename MetricType = metric::LMetric<2, true>,
          typename VecType = arma::vec>
 class BallBound
 {
@@ -31,8 +31,6 @@ class BallBound
   typedef typename VecType::elem_type ElemType;
   //! A public version of the vector type.
   typedef VecType Vec;
-  //! Needed for BinarySpaceTree.
-  typedef TMetricType MetricType;
 
  private:
   //! The radius of the ball bound.
@@ -40,7 +38,7 @@ class BallBound
   //! The center of the ball bound.
   VecType center;
   //! The metric used in this bound.
-  TMetricType* metric;
+  MetricType* metric;
 
   /**
    * To know whether this object allocated memory to the metric member
@@ -179,9 +177,9 @@ class BallBound
   ElemType Diameter() const { return 2 * radius; }
 
   //! Returns the distance metric used in this bound.
-  const TMetricType& Metric() const { return *metric; }
+  const MetricType& Metric() const { return *metric; }
   //! Modify the distance metric used in this bound.
-  TMetricType& Metric() { return *metric; }
+  MetricType& Metric() { return *metric; }
 
   //! Serialize the bound.
   template<typename Archive>
@@ -189,8 +187,8 @@ class BallBound
 };
 
 //! A specialization of BoundTraits for this bound type.
-template<typename TMetricType, typename VecType>
-struct BoundTraits<BallBound<TMetricType, VecType>>
+template<typename MetricType, typename VecType>
+struct BoundTraits<BallBound<MetricType, VecType>>
 {
   //! These bounds are potentially loose in some dimensions.
   const static bool HasTightBounds = false;
diff --git a/src/mlpack/core/tree/ballbound_impl.hpp b/src/mlpack/core/tree/ballbound_impl.hpp
index 3859156..885acb5 100644
--- a/src/mlpack/core/tree/ballbound_impl.hpp
+++ b/src/mlpack/core/tree/ballbound_impl.hpp
@@ -18,10 +18,10 @@ namespace mlpack {
 namespace bound {
 
 //! Empty Constructor.
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::BallBound() :
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::BallBound() :
     radius(std::numeric_limits<ElemType>::lowest()),
-    metric(new TMetricType()),
+    metric(new MetricType()),
     ownsMetric(true)
 { /* Nothing to do. */ }
 
@@ -30,11 +30,11 @@ BallBound<TMetricType, VecType>::BallBound() :
  *
  * @param dimension Dimensionality of ball bound.
  */
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::BallBound(const size_t dimension) :
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::BallBound(const size_t dimension) :
     radius(std::numeric_limits<ElemType>::lowest()),
     center(dimension),
-    metric(new TMetricType()),
+    metric(new MetricType()),
     ownsMetric(true)
 { /* Nothing to do. */ }
 
@@ -44,18 +44,18 @@ BallBound<TMetricType, VecType>::BallBound(const size_t dimension) :
  * @param radius Radius of ball bound.
  * @param center Center of ball bound.
  */
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::BallBound(const ElemType radius,
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::BallBound(const ElemType radius,
                                            const VecType& center) :
     radius(radius),
     center(center),
-    metric(new TMetricType()),
+    metric(new MetricType()),
     ownsMetric(true)
 { /* Nothing to do. */ }
 
 //! Copy Constructor. To prevent memory leaks.
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::BallBound(const BallBound& other) :
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::BallBound(const BallBound& other) :
     radius(other.radius),
     center(other.center),
     metric(other.metric),
@@ -63,8 +63,8 @@ BallBound<TMetricType, VecType>::BallBound(const BallBound& other) :
 { /* Nothing to do. */ }
 
 //! For the same reason as the copy constructor: to prevent memory leaks.
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>& BallBound<TMetricType, VecType>::operator=(
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>& BallBound<MetricType, VecType>::operator=(
     const BallBound& other)
 {
   radius = other.radius;
@@ -74,8 +74,8 @@ BallBound<TMetricType, VecType>& BallBound<TMetricType, VecType>::operator=(
 }
 
 //! Move constructor.
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::BallBound(BallBound&& other) :
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::BallBound(BallBound&& other) :
     radius(other.radius),
     center(other.center),
     metric(other.metric),
@@ -89,17 +89,17 @@ BallBound<TMetricType, VecType>::BallBound(BallBound&& other) :
 }
 
 //! Destructor to release allocated memory.
-template<typename TMetricType, typename VecType>
-BallBound<TMetricType, VecType>::~BallBound()
+template<typename MetricType, typename VecType>
+BallBound<MetricType, VecType>::~BallBound()
 {
   if (ownsMetric)
     delete metric;
 }
 
 //! Get the range in a certain dimension.
-template<typename TMetricType, typename VecType>
-math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
-BallBound<TMetricType, VecType>::operator[](const size_t i) const
+template<typename MetricType, typename VecType>
+math::RangeType<typename BallBound<MetricType, VecType>::ElemType>
+BallBound<MetricType, VecType>::operator[](const size_t i) const
 {
   if (radius < 0)
     return math::Range();
@@ -110,8 +110,8 @@ BallBound<TMetricType, VecType>::operator[](const size_t i) const
 /**
  * Determines if a point is within the bound.
  */
-template<typename TMetricType, typename VecType>
-bool BallBound<TMetricType, VecType>::Contains(const VecType& point) const
+template<typename MetricType, typename VecType>
+bool BallBound<MetricType, VecType>::Contains(const VecType& point) const
 {
   if (radius < 0)
     return false;
@@ -122,10 +122,10 @@ bool BallBound<TMetricType, VecType>::Contains(const VecType& point) const
 /**
  * Calculates minimum bound-to-point squared distance.
  */
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 template<typename OtherVecType>
-typename BallBound<TMetricType, VecType>::ElemType
-BallBound<TMetricType, VecType>::MinDistance(
+typename BallBound<MetricType, VecType>::ElemType
+BallBound<MetricType, VecType>::MinDistance(
     const OtherVecType& point,
     typename boost::enable_if<IsVector<OtherVecType>>* /* junk */) const
 {
@@ -138,9 +138,9 @@ BallBound<TMetricType, VecType>::MinDistance(
 /**
  * Calculates minimum bound-to-bound squared distance.
  */
-template<typename TMetricType, typename VecType>
-typename BallBound<TMetricType, VecType>::ElemType
-BallBound<TMetricType, VecType>::MinDistance(const BallBound& other)
+template<typename MetricType, typename VecType>
+typename BallBound<MetricType, VecType>::ElemType
+BallBound<MetricType, VecType>::MinDistance(const BallBound& other)
     const
 {
   if (radius < 0)
@@ -156,10 +156,10 @@ BallBound<TMetricType, VecType>::MinDistance(const BallBound& other)
 /**
  * Computes maximum distance.
  */
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 template<typename OtherVecType>
-typename BallBound<TMetricType, VecType>::ElemType
-BallBound<TMetricType, VecType>::MaxDistance(
+typename BallBound<MetricType, VecType>::ElemType
+BallBound<MetricType, VecType>::MaxDistance(
     const OtherVecType& point,
     typename boost::enable_if<IsVector<OtherVecType> >* /* junk */) const
 {
@@ -172,9 +172,9 @@ BallBound<TMetricType, VecType>::MaxDistance(
 /**
  * Computes maximum distance.
  */
-template<typename TMetricType, typename VecType>
-typename BallBound<TMetricType, VecType>::ElemType
-BallBound<TMetricType, VecType>::MaxDistance(const BallBound& other)
+template<typename MetricType, typename VecType>
+typename BallBound<MetricType, VecType>::ElemType
+BallBound<MetricType, VecType>::MaxDistance(const BallBound& other)
     const
 {
   if (radius < 0)
@@ -188,10 +188,10 @@ BallBound<TMetricType, VecType>::MaxDistance(const BallBound& other)
  *
  * Example: bound1.MinDistanceSq(other) for minimum squared distance.
  */
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 template<typename OtherVecType>
-math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
-BallBound<TMetricType, VecType>::RangeDistance(
+math::RangeType<typename BallBound<MetricType, VecType>::ElemType>
+BallBound<MetricType, VecType>::RangeDistance(
     const OtherVecType& point,
     typename boost::enable_if<IsVector<OtherVecType> >* /* junk */) const
 {
@@ -206,9 +206,9 @@ BallBound<TMetricType, VecType>::RangeDistance(
   }
 }
 
-template<typename TMetricType, typename VecType>
-math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
-BallBound<TMetricType, VecType>::RangeDistance(
+template<typename MetricType, typename VecType>
+math::RangeType<typename BallBound<MetricType, VecType>::ElemType>
+BallBound<MetricType, VecType>::RangeDistance(
     const BallBound& other) const
 {
   if (radius < 0)
@@ -226,9 +226,9 @@ BallBound<TMetricType, VecType>::RangeDistance(
 /**
  * Expand the bound to include the given bound.
  *
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 const BallBound<VecType>&
-BallBound<TMetricType, VecType>::operator|=(
+BallBound<MetricType, VecType>::operator|=(
     const BallBound<VecType>& other)
 {
   double dist = metric->Evaluate(center, other);
@@ -246,10 +246,10 @@ BallBound<TMetricType, VecType>::operator|=(
  * The difference lies in the way we initialize the ball bound. The way we
  * expand the bound is same.
  */
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 template<typename MatType>
-const BallBound<TMetricType, VecType>&
-BallBound<TMetricType, VecType>::operator|=(const MatType& data)
+const BallBound<MetricType, VecType>&
+BallBound<MetricType, VecType>::operator|=(const MatType& data)
 {
   if (radius < 0)
   {
@@ -277,9 +277,9 @@ BallBound<TMetricType, VecType>::operator|=(const MatType& data)
 }
 
 //! Serialize the BallBound.
-template<typename TMetricType, typename VecType>
+template<typename MetricType, typename VecType>
 template<typename Archive>
-void BallBound<TMetricType, VecType>::Serialize(
+void BallBound<MetricType, VecType>::Serialize(
     Archive& ar,
     const unsigned int /* version */)
 {




More information about the mlpack-git mailing list