[mlpack-git] master: Refactor to match TreeType API. (b3bf0db)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Jul 29 16:41:37 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/f8ceffae0613b350f4d6bdd46c6c8633a40b4897...6ee21879488fe98612a4619b17f8b51e8da5215b
>---------------------------------------------------------------
commit b3bf0db5f45e81e9969d02b80e9e15e442afb932
Author: ryan <ryan at ratml.org>
Date: Wed Jul 22 22:07:19 2015 -0400
Refactor to match TreeType API.
>---------------------------------------------------------------
b3bf0db5f45e81e9969d02b80e9e15e442afb932
.../tree/binary_space_tree/binary_space_tree.hpp | 33 +--
.../binary_space_tree/binary_space_tree_impl.hpp | 224 ++++++++++++---------
.../breadth_first_dual_tree_traverser.hpp | 13 +-
.../breadth_first_dual_tree_traverser_impl.hpp | 33 +--
.../tree/binary_space_tree/dual_tree_traverser.hpp | 13 +-
.../binary_space_tree/dual_tree_traverser_impl.hpp | 19 +-
.../binary_space_tree/single_tree_traverser.hpp | 9 +-
.../single_tree_traverser_impl.hpp | 16 +-
src/mlpack/core/tree/binary_space_tree/traits.hpp | 8 +-
9 files changed, 210 insertions(+), 158 deletions(-)
diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
index 1f350ad..61bcee2 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
@@ -27,20 +27,24 @@ namespace tree /** Trees and tree-building procedures. */ {
* This tree does take one runtime parameter in the constructor, which is the
* max leaf size to be used.
*
- * @tparam BoundType The bound used for each node. The valid types of bounds
- * and the necessary skeleton interface for this class can be found in
- * bounds/.
+ * @tparam MetricType The metric used for tree-building. The BoundType may
+ * place restrictions on the metrics that can be used.
* @tparam StatisticType Extra data contained in the node. See statistic.hpp
* for the necessary skeleton interface.
* @tparam MatType The dataset class.
+ * @tparam BoundType The bound used for each node. HRectBound, the default,
+ * requires that an LMetric<> is used for MetricType (so, EuclideanDistance,
+ * ManhattanDistance, etc.).
* @tparam SplitType The class that partitions the dataset/points at a
* particular node into two parts. Its definition decides the way this split
* is done.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType = EmptyStatistic,
typename MatType = arma::mat,
- typename SplitType = MidpointSplit<BoundType, MatType>>
+ template<typename BoundMetricType> class BoundType = bound::HRectBound,
+ template<typename BoundType, typename MatType> class SplitType =
+ MidpointSplit>
class BinarySpaceTree
{
private:
@@ -57,7 +61,7 @@ class BinarySpaceTree
//! children).
size_t count;
//! The bound object for this node.
- BoundType bound;
+ BoundType<MetricType> bound;
//! Any extra data contained in the node.
StatisticType stat;
//! The distance from the centroid of this node to the centroid of the parent.
@@ -147,7 +151,7 @@ class BinarySpaceTree
BinarySpaceTree(BinarySpaceTree* parent,
const size_t begin,
const size_t count,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize = 20);
/**
@@ -172,7 +176,7 @@ class BinarySpaceTree
const size_t begin,
const size_t count,
std::vector<size_t>& oldFromNew,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize = 20);
/**
@@ -201,7 +205,7 @@ class BinarySpaceTree
const size_t count,
std::vector<size_t>& oldFromNew,
std::vector<size_t>& newFromOld,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize = 20);
/**
@@ -230,9 +234,9 @@ class BinarySpaceTree
~BinarySpaceTree();
//! Return the bound object for this node.
- const BoundType& Bound() const { return bound; }
+ const BoundType<MetricType>& Bound() const { return bound; }
//! Return the bound object for this node.
- BoundType& Bound() { return bound; }
+ BoundType<MetricType>& Bound() { return bound; }
//! Return the statistic object for this node.
const StatisticType& Stat() const { return stat; }
@@ -263,7 +267,7 @@ class BinarySpaceTree
MatType& Dataset() { return *dataset; }
//! Get the metric that the tree uses.
- typename BoundType::MetricType Metric() const { return bound.Metric(); }
+ MetricType Metric() const { return MetricType(); }
//! Return the number of children in this node.
size_t NumChildren() const;
@@ -401,7 +405,8 @@ class BinarySpaceTree
* @param maxLeafSize Maximum number of points held in a leaf.
* @param splitter Instantiated SplitType object.
*/
- void SplitNode(const size_t maxLeafSize, SplitType& splitter);
+ void SplitNode(const size_t maxLeafSize,
+ SplitType<BoundType<MetricType>, MatType>& splitter);
/**
* Splits the current node, assigning its left and right children recursively.
@@ -413,7 +418,7 @@ class BinarySpaceTree
*/
void SplitNode(std::vector<size_t>& oldFromNew,
const size_t maxLeafSize,
- SplitType& splitter);
+ SplitType<BoundType<MetricType>, MatType>& splitter);
protected:
/**
diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
index 36c91a8..8d0de01 100644
--- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
@@ -19,11 +19,13 @@ namespace tree {
// Each of these overloads is kept as a separate function to keep the overhead
// from the two std::vectors out, if possible.
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
const MatType& data,
const size_t maxLeafSize) :
left(NULL),
@@ -36,18 +38,20 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
dataset(new MatType(data)) // Copies the dataset.
{
// Do the actual splitting of this node.
- SplitType splitter;
+ SplitType<BoundType<MetricType>, MatType> splitter;
SplitNode(maxLeafSize, splitter);
// Create the statistic depending on if we are a leaf or not.
stat = StatisticType(*this);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
const MatType& data,
std::vector<size_t>& oldFromNew,
const size_t maxLeafSize) :
@@ -66,18 +70,20 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
oldFromNew[i] = i; // Fill with unharmed indices.
// Now do the actual splitting.
- SplitType splitter;
+ SplitType<BoundType<MetricType>, MatType> splitter;
SplitNode(oldFromNew, maxLeafSize, splitter);
// Create the statistic depending on if we are a leaf or not.
stat = StatisticType(*this);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
const MatType& data,
std::vector<size_t>& oldFromNew,
std::vector<size_t>& newFromOld,
@@ -97,7 +103,7 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
oldFromNew[i] = i; // Fill with unharmed indices.
// Now do the actual splitting.
- SplitType splitter;
+ SplitType<BoundType<MetricType>, MatType> splitter;
SplitNode(oldFromNew, maxLeafSize, splitter);
// Create the statistic depending on if we are a leaf or not.
@@ -109,15 +115,17 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
newFromOld[oldFromNew[i]] = i;
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
BinarySpaceTree* parent,
const size_t begin,
const size_t count,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize) :
left(NULL),
right(NULL),
@@ -134,16 +142,18 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
stat = StatisticType(*this);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
BinarySpaceTree* parent,
const size_t begin,
const size_t count,
std::vector<size_t>& oldFromNew,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize) :
left(NULL),
right(NULL),
@@ -164,17 +174,19 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
stat = StatisticType(*this);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
BinarySpaceTree* parent,
const size_t begin,
const size_t count,
std::vector<size_t>& oldFromNew,
std::vector<size_t>& newFromOld,
- SplitType& splitter,
+ SplitType<BoundType<MetricType>, MatType>& splitter,
const size_t maxLeafSize) :
left(NULL),
right(NULL),
@@ -204,11 +216,13 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
* Create a binary space tree by copying the other tree. Be careful! This can
* take a long time and use a lot of memory.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+BinarySpaceTree(
const BinarySpaceTree& other) :
left(NULL),
right(NULL),
@@ -260,12 +274,13 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::BinarySpaceTree(
/**
* Initialize the tree from an archive.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename Archive>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
BinarySpaceTree(
Archive& ar,
const typename boost::enable_if<typename Archive::is_loading>::type*) :
@@ -281,11 +296,12 @@ BinarySpaceTree(
* destructors in turn. This will invalidate any pointers or references to any
* nodes which are children of this one.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
~BinarySpaceTree()
{
if (left)
@@ -298,12 +314,13 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
delete dataset;
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline bool BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- IsLeaf() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline bool BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::IsLeaf() const
{
return !left;
}
@@ -311,12 +328,13 @@ inline bool BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Returns the number of children in this node.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- NumChildren() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline size_t BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::NumChildren() const
{
if (left && right)
return 2;
@@ -330,12 +348,13 @@ inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
* Return a bound on the furthest point in the node from the center. This
* returns 0 unless the node is a leaf.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- FurthestPointDistance() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline double BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::FurthestPointDistance() const
{
if (!IsLeaf())
return 0.0;
@@ -351,23 +370,25 @@ inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
* furthest descendant distance may be less than what this method returns (but
* it will never be greater than this).
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- FurthestDescendantDistance() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline double BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::FurthestDescendantDistance() const
{
return furthestDescendantDistance;
}
//! Return the minimum distance from the center to any bound edge.
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- MinimumBoundDistance() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline double BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::MinimumBoundDistance() const
{
return bound.MinWidth() / 2.0;
}
@@ -375,13 +396,15 @@ inline double BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Return the specified child.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>&
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- Child(const size_t child) const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>&
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::Child(const size_t child) const
{
if (child == 0)
return *left;
@@ -392,12 +415,13 @@ inline BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>&
/**
* Return the number of points contained in this node.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- NumPoints() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline size_t BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::NumPoints() const
{
if (left)
return 0;
@@ -408,12 +432,13 @@ inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Return the number of descendants contained in the node.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- NumDescendants() const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline size_t BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::NumDescendants() const
{
return count;
}
@@ -421,12 +446,13 @@ inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Return the index of a particular descendant contained in this node.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- Descendant(const size_t index) const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline size_t BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::Descendant(const size_t index) const
{
return (begin + index);
}
@@ -434,23 +460,25 @@ inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Return the index of a particular point contained in this node.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-inline size_t BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- Point(const size_t index) const
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+inline size_t BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::Point(const size_t index) const
{
return (begin + index);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
- const size_t maxLeafSize,
- SplitType& splitter)
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+ SplitNode(const size_t maxLeafSize,
+ SplitType<BoundType<MetricType>, MatType>& splitter)
{
// We need to expand the bounds of this node properly.
bound |= dataset->cols(begin, begin + count - 1);
@@ -498,14 +526,15 @@ void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
right->ParentDistance() = rightParentDistance;
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
- std::vector<size_t>& oldFromNew,
- const size_t maxLeafSize,
- SplitType& splitter)
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SplitNode(std::vector<size_t>& oldFromNew,
+ const size_t maxLeafSize,
+ SplitType<BoundType<MetricType>, MatType>& splitter)
{
// This should be a single function for Bound.
// We need to expand the bounds of this node properly.
@@ -555,11 +584,12 @@ void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::SplitNode(
}
// Default constructor (private), for boost::serialization.
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
BinarySpaceTree() :
left(NULL),
right(NULL),
@@ -577,14 +607,14 @@ BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
/**
* Serialize the tree.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename Archive>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::Serialize(
- Archive& ar,
- const unsigned int /* version */)
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+ Serialize(Archive& ar, const unsigned int /* version */)
{
using data::CreateNVP;
@@ -656,11 +686,13 @@ void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::Serialize(
/**
* Returns a string representation of this object.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-std::string BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+std::string BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::
ToString() const
{
std::ostringstream convert;
diff --git a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp
index 1df5f94..8649701 100644
--- a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser.hpp
@@ -28,13 +28,14 @@ struct QueueFrame
TraversalInfoType traversalInfo;
};
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-class BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- BreadthFirstDualTreeTraverser
+class BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::BreadthFirstDualTreeTraverser
{
public:
/**
@@ -98,8 +99,8 @@ class BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
typename RuleType::TraversalInfoType traversalInfo;
};
-}; // namespace tree
-}; // namespace mlpack
+} // namespace tree
+} // namespace mlpack
// Include implementation.
#include "breadth_first_dual_tree_traverser_impl.hpp"
diff --git a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser_impl.hpp b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser_impl.hpp
index 4ae92c1..375b2b7 100644
--- a/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/breadth_first_dual_tree_traverser_impl.hpp
@@ -15,12 +15,13 @@
namespace mlpack {
namespace tree {
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
BreadthFirstDualTreeTraverser<RuleType>::BreadthFirstDualTreeTraverser(
RuleType& rule) :
rule(rule),
@@ -41,15 +42,17 @@ bool operator<(const QueueFrame<TreeType, TraversalInfoType>& a,
return false;
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
BreadthFirstDualTreeTraverser<RuleType>::Traverse(
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>& queryRoot,
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>&
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
+ queryRoot,
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
referenceRoot)
{
// Increment the visit counter.
@@ -78,14 +81,16 @@ BreadthFirstDualTreeTraverser<RuleType>::Traverse(
Traverse(queryRoot, queue);
}
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
BreadthFirstDualTreeTraverser<RuleType>::Traverse(
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>& queryNode,
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
+ queryNode,
std::priority_queue<QueueFrameType>& referenceQueue)
{
// Store queues for the children. We will recurse into the children once our
@@ -191,7 +196,7 @@ BreadthFirstDualTreeTraverser<RuleType>::Traverse(
Traverse(*queryNode.Right(), rightChildQueue);
}
-}; // namespace tree
-}; // namespace mlpack
+} // namespace tree
+} // namespace mlpack
#endif // __MLPACK_CORE_TREE_BINARY_SPACE_TREE_BREADTH_FIRST_DUAL_TREE_TRAVERSER_IMPL_HPP
diff --git a/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser.hpp b/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser.hpp
index 7cd1871..b9846e0 100644
--- a/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser.hpp
@@ -17,13 +17,14 @@
namespace mlpack {
namespace tree {
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-class BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- DualTreeTraverser
+class BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::DualTreeTraverser
{
public:
/**
@@ -82,8 +83,8 @@ class BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
typename RuleType::TraversalInfoType traversalInfo;
};
-}; // namespace tree
-}; // namespace mlpack
+} // namespace tree
+} // namespace mlpack
// Include implementation.
#include "dual_tree_traverser_impl.hpp"
diff --git a/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser_impl.hpp b/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser_impl.hpp
index 7769dca..4e61276 100644
--- a/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/dual_tree_traverser_impl.hpp
@@ -15,12 +15,13 @@
namespace mlpack {
namespace tree {
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
DualTreeTraverser<RuleType>::DualTreeTraverser(RuleType& rule) :
rule(rule),
numPrunes(0),
@@ -29,15 +30,17 @@ DualTreeTraverser<RuleType>::DualTreeTraverser(RuleType& rule) :
numBaseCases(0)
{ /* Nothing to do. */ }
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
DualTreeTraverser<RuleType>::Traverse(
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>& queryNode,
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>&
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
+ queryNode,
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
referenceNode)
{
// Increment the visit counter.
diff --git a/src/mlpack/core/tree/binary_space_tree/single_tree_traverser.hpp b/src/mlpack/core/tree/binary_space_tree/single_tree_traverser.hpp
index 69f2a04..fdaca58 100644
--- a/src/mlpack/core/tree/binary_space_tree/single_tree_traverser.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/single_tree_traverser.hpp
@@ -16,13 +16,14 @@
namespace mlpack {
namespace tree {
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-class BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
- SingleTreeTraverser
+class BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>::SingleTreeTraverser
{
public:
/**
diff --git a/src/mlpack/core/tree/binary_space_tree/single_tree_traverser_impl.hpp b/src/mlpack/core/tree/binary_space_tree/single_tree_traverser_impl.hpp
index 7826957..026509d 100644
--- a/src/mlpack/core/tree/binary_space_tree/single_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/single_tree_traverser_impl.hpp
@@ -17,26 +17,28 @@
namespace mlpack {
namespace tree {
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
rule(rule),
numPrunes(0)
{ /* Nothing to do. */ }
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
template<typename RuleType>
-void BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>::
+void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
SingleTreeTraverser<RuleType>::Traverse(
const size_t queryIndex,
- BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>&
+ BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
referenceNode)
{
// If we are a leaf, run the base case as necessary.
diff --git a/src/mlpack/core/tree/binary_space_tree/traits.hpp b/src/mlpack/core/tree/binary_space_tree/traits.hpp
index f809a5d..3054941 100644
--- a/src/mlpack/core/tree/binary_space_tree/traits.hpp
+++ b/src/mlpack/core/tree/binary_space_tree/traits.hpp
@@ -18,11 +18,13 @@ namespace tree {
* help write tree-independent (but still optimized) tree-based algorithms. See
* mlpack/core/tree/tree_traits.hpp for more information.
*/
-template<typename BoundType,
+template<typename MetricType,
typename StatisticType,
typename MatType,
- typename SplitType>
-class TreeTraits<BinarySpaceTree<BoundType, StatisticType, MatType, SplitType>>
+ template<typename BoundMetricType> class BoundType,
+ template<typename BoundType, typename MatType> class SplitType>
+class TreeTraits<BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
+ SplitType>>
{
public:
/**
More information about the mlpack-git
mailing list