[mlpack-git] master: Set proper template order. To work with binary space trees, the metric template parameter must be the first. (9e5d9c2)
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/1f562a1aba7ae55475afcc95659511c2b7f694e5...5b8fdce471328f722fcd8c0f22a6d995ce22c98b
>---------------------------------------------------------------
commit 9e5d9c28ad46c1bb21e395df7a6f7249cd17e011
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Fri May 27 21:01:06 2016 -0300
Set proper template order. To work with binary space trees, the metric template parameter must be the first.
>---------------------------------------------------------------
9e5d9c28ad46c1bb21e395df7a6f7249cd17e011
src/mlpack/core/tree/ballbound.hpp | 10 ++--
src/mlpack/core/tree/ballbound_impl.hpp | 88 ++++++++++++++++-----------------
2 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp
index 68a16d7..d61e88a 100644
--- a/src/mlpack/core/tree/ballbound.hpp
+++ b/src/mlpack/core/tree/ballbound.hpp
@@ -19,11 +19,11 @@ namespace bound {
* specific point (center). TMetricType is the custom metric type that defaults
* to the Euclidean (L2) distance.
*
- * @tparam VecType Type of vector (arma::vec or arma::sp_vec or similar).
* @tparam TMetricType metric type used in the distance measure.
+ * @tparam VecType Type of vector (arma::vec or arma::sp_vec or similar).
*/
-template<typename VecType = arma::vec,
- typename TMetricType = metric::LMetric<2, true>>
+template<typename TMetricType = metric::LMetric<2, true>,
+ typename VecType = arma::vec>
class BallBound
{
public:
@@ -189,8 +189,8 @@ class BallBound
};
//! A specialization of BoundTraits for this bound type.
-template<typename VecType, typename TMetricType>
-struct BoundTraits<BallBound<VecType, TMetricType>>
+template<typename TMetricType, typename VecType>
+struct BoundTraits<BallBound<TMetricType, 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 8e0e658..3859156 100644
--- a/src/mlpack/core/tree/ballbound_impl.hpp
+++ b/src/mlpack/core/tree/ballbound_impl.hpp
@@ -18,8 +18,8 @@ namespace mlpack {
namespace bound {
//! Empty Constructor.
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::BallBound() :
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::BallBound() :
radius(std::numeric_limits<ElemType>::lowest()),
metric(new TMetricType()),
ownsMetric(true)
@@ -30,8 +30,8 @@ BallBound<VecType, TMetricType>::BallBound() :
*
* @param dimension Dimensionality of ball bound.
*/
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::BallBound(const size_t dimension) :
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::BallBound(const size_t dimension) :
radius(std::numeric_limits<ElemType>::lowest()),
center(dimension),
metric(new TMetricType()),
@@ -44,8 +44,8 @@ BallBound<VecType, TMetricType>::BallBound(const size_t dimension) :
* @param radius Radius of ball bound.
* @param center Center of ball bound.
*/
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::BallBound(const ElemType radius,
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::BallBound(const ElemType radius,
const VecType& center) :
radius(radius),
center(center),
@@ -54,8 +54,8 @@ BallBound<VecType, TMetricType>::BallBound(const ElemType radius,
{ /* Nothing to do. */ }
//! Copy Constructor. To prevent memory leaks.
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::BallBound(const BallBound& other) :
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::BallBound(const BallBound& other) :
radius(other.radius),
center(other.center),
metric(other.metric),
@@ -63,8 +63,8 @@ BallBound<VecType, TMetricType>::BallBound(const BallBound& other) :
{ /* Nothing to do. */ }
//! For the same reason as the copy constructor: to prevent memory leaks.
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>& BallBound<VecType, TMetricType>::operator=(
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>& BallBound<TMetricType, VecType>::operator=(
const BallBound& other)
{
radius = other.radius;
@@ -74,8 +74,8 @@ BallBound<VecType, TMetricType>& BallBound<VecType, TMetricType>::operator=(
}
//! Move constructor.
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::BallBound(BallBound&& other) :
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::BallBound(BallBound&& other) :
radius(other.radius),
center(other.center),
metric(other.metric),
@@ -89,17 +89,17 @@ BallBound<VecType, TMetricType>::BallBound(BallBound&& other) :
}
//! Destructor to release allocated memory.
-template<typename VecType, typename TMetricType>
-BallBound<VecType, TMetricType>::~BallBound()
+template<typename TMetricType, typename VecType>
+BallBound<TMetricType, VecType>::~BallBound()
{
if (ownsMetric)
delete metric;
}
//! Get the range in a certain dimension.
-template<typename VecType, typename TMetricType>
-math::RangeType<typename BallBound<VecType, TMetricType>::ElemType>
-BallBound<VecType, TMetricType>::operator[](const size_t i) const
+template<typename TMetricType, typename VecType>
+math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
+BallBound<TMetricType, VecType>::operator[](const size_t i) const
{
if (radius < 0)
return math::Range();
@@ -110,8 +110,8 @@ BallBound<VecType, TMetricType>::operator[](const size_t i) const
/**
* Determines if a point is within the bound.
*/
-template<typename VecType, typename TMetricType>
-bool BallBound<VecType, TMetricType>::Contains(const VecType& point) const
+template<typename TMetricType, typename VecType>
+bool BallBound<TMetricType, VecType>::Contains(const VecType& point) const
{
if (radius < 0)
return false;
@@ -122,10 +122,10 @@ bool BallBound<VecType, TMetricType>::Contains(const VecType& point) const
/**
* Calculates minimum bound-to-point squared distance.
*/
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
template<typename OtherVecType>
-typename BallBound<VecType, TMetricType>::ElemType
-BallBound<VecType, TMetricType>::MinDistance(
+typename BallBound<TMetricType, VecType>::ElemType
+BallBound<TMetricType, VecType>::MinDistance(
const OtherVecType& point,
typename boost::enable_if<IsVector<OtherVecType>>* /* junk */) const
{
@@ -138,9 +138,9 @@ BallBound<VecType, TMetricType>::MinDistance(
/**
* Calculates minimum bound-to-bound squared distance.
*/
-template<typename VecType, typename TMetricType>
-typename BallBound<VecType, TMetricType>::ElemType
-BallBound<VecType, TMetricType>::MinDistance(const BallBound& other)
+template<typename TMetricType, typename VecType>
+typename BallBound<TMetricType, VecType>::ElemType
+BallBound<TMetricType, VecType>::MinDistance(const BallBound& other)
const
{
if (radius < 0)
@@ -156,10 +156,10 @@ BallBound<VecType, TMetricType>::MinDistance(const BallBound& other)
/**
* Computes maximum distance.
*/
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
template<typename OtherVecType>
-typename BallBound<VecType, TMetricType>::ElemType
-BallBound<VecType, TMetricType>::MaxDistance(
+typename BallBound<TMetricType, VecType>::ElemType
+BallBound<TMetricType, VecType>::MaxDistance(
const OtherVecType& point,
typename boost::enable_if<IsVector<OtherVecType> >* /* junk */) const
{
@@ -172,9 +172,9 @@ BallBound<VecType, TMetricType>::MaxDistance(
/**
* Computes maximum distance.
*/
-template<typename VecType, typename TMetricType>
-typename BallBound<VecType, TMetricType>::ElemType
-BallBound<VecType, TMetricType>::MaxDistance(const BallBound& other)
+template<typename TMetricType, typename VecType>
+typename BallBound<TMetricType, VecType>::ElemType
+BallBound<TMetricType, VecType>::MaxDistance(const BallBound& other)
const
{
if (radius < 0)
@@ -188,10 +188,10 @@ BallBound<VecType, TMetricType>::MaxDistance(const BallBound& other)
*
* Example: bound1.MinDistanceSq(other) for minimum squared distance.
*/
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
template<typename OtherVecType>
-math::RangeType<typename BallBound<VecType, TMetricType>::ElemType>
-BallBound<VecType, TMetricType>::RangeDistance(
+math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
+BallBound<TMetricType, VecType>::RangeDistance(
const OtherVecType& point,
typename boost::enable_if<IsVector<OtherVecType> >* /* junk */) const
{
@@ -206,9 +206,9 @@ BallBound<VecType, TMetricType>::RangeDistance(
}
}
-template<typename VecType, typename TMetricType>
-math::RangeType<typename BallBound<VecType, TMetricType>::ElemType>
-BallBound<VecType, TMetricType>::RangeDistance(
+template<typename TMetricType, typename VecType>
+math::RangeType<typename BallBound<TMetricType, VecType>::ElemType>
+BallBound<TMetricType, VecType>::RangeDistance(
const BallBound& other) const
{
if (radius < 0)
@@ -226,9 +226,9 @@ BallBound<VecType, TMetricType>::RangeDistance(
/**
* Expand the bound to include the given bound.
*
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
const BallBound<VecType>&
-BallBound<VecType, TMetricType>::operator|=(
+BallBound<TMetricType, VecType>::operator|=(
const BallBound<VecType>& other)
{
double dist = metric->Evaluate(center, other);
@@ -246,10 +246,10 @@ BallBound<VecType, TMetricType>::operator|=(
* The difference lies in the way we initialize the ball bound. The way we
* expand the bound is same.
*/
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
template<typename MatType>
-const BallBound<VecType, TMetricType>&
-BallBound<VecType, TMetricType>::operator|=(const MatType& data)
+const BallBound<TMetricType, VecType>&
+BallBound<TMetricType, VecType>::operator|=(const MatType& data)
{
if (radius < 0)
{
@@ -277,9 +277,9 @@ BallBound<VecType, TMetricType>::operator|=(const MatType& data)
}
//! Serialize the BallBound.
-template<typename VecType, typename TMetricType>
+template<typename TMetricType, typename VecType>
template<typename Archive>
-void BallBound<VecType, TMetricType>::Serialize(
+void BallBound<TMetricType, VecType>::Serialize(
Archive& ar,
const unsigned int /* version */)
{
More information about the mlpack-git
mailing list