[mlpack-git] master: Remove unnecessary BoundType template parameter. (723bec5)
gitdub at mlpack.org
gitdub at mlpack.org
Thu Aug 18 13:39:48 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0
>---------------------------------------------------------------
commit 723bec52928e256e8a0a685f9a1f3671653a69b0
Author: MarcosPividori <marcos.pividori at gmail.com>
Date: Tue Jul 26 22:55:24 2016 -0300
Remove unnecessary BoundType template parameter.
>---------------------------------------------------------------
723bec52928e256e8a0a685f9a1f3671653a69b0
.../core/tree/spill_tree/dual_tree_traverser.hpp | 5 +-
.../tree/spill_tree/dual_tree_traverser_impl.hpp | 3 +-
.../core/tree/spill_tree/single_tree_traverser.hpp | 5 +-
.../tree/spill_tree/single_tree_traverser_impl.hpp | 8 +-
src/mlpack/core/tree/spill_tree/spill_tree.hpp | 14 +---
.../core/tree/spill_tree/spill_tree_impl.hpp | 89 +++++++++-------------
src/mlpack/core/tree/spill_tree/traits.hpp | 4 +-
src/mlpack/core/tree/spill_tree/typedef.hpp | 37 ---------
8 files changed, 47 insertions(+), 118 deletions(-)
diff --git a/src/mlpack/core/tree/spill_tree/dual_tree_traverser.hpp b/src/mlpack/core/tree/spill_tree/dual_tree_traverser.hpp
index 80ec452..a0b63b2 100644
--- a/src/mlpack/core/tree/spill_tree/dual_tree_traverser.hpp
+++ b/src/mlpack/core/tree/spill_tree/dual_tree_traverser.hpp
@@ -21,12 +21,11 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename RuleType>
-class SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::DualTreeTraverser
+class SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ DualTreeTraverser
{
public:
/**
diff --git a/src/mlpack/core/tree/spill_tree/dual_tree_traverser_impl.hpp b/src/mlpack/core/tree/spill_tree/dual_tree_traverser_impl.hpp
index f47dc4a..b2eae9f 100644
--- a/src/mlpack/core/tree/spill_tree/dual_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/spill_tree/dual_tree_traverser_impl.hpp
@@ -19,11 +19,10 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename RuleType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
DualTreeTraverser<RuleType>::DualTreeTraverser(RuleType& rule) :
rule(rule),
numPrunes(0),
diff --git a/src/mlpack/core/tree/spill_tree/single_tree_traverser.hpp b/src/mlpack/core/tree/spill_tree/single_tree_traverser.hpp
index 31de071..fd41c13 100644
--- a/src/mlpack/core/tree/spill_tree/single_tree_traverser.hpp
+++ b/src/mlpack/core/tree/spill_tree/single_tree_traverser.hpp
@@ -20,12 +20,11 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename RuleType>
-class SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::SingleTreeTraverser
+class SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ SingleTreeTraverser
{
public:
/**
diff --git a/src/mlpack/core/tree/spill_tree/single_tree_traverser_impl.hpp b/src/mlpack/core/tree/spill_tree/single_tree_traverser_impl.hpp
index 3beed23..a94b063 100644
--- a/src/mlpack/core/tree/spill_tree/single_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/spill_tree/single_tree_traverser_impl.hpp
@@ -19,11 +19,10 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename RuleType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
rule(rule),
numPrunes(0)
@@ -32,14 +31,13 @@ SingleTreeTraverser<RuleType>::SingleTreeTraverser(RuleType& rule) :
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename RuleType>
-void SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+void SpillTree<MetricType, StatisticType, MatType, SplitType>::
SingleTreeTraverser<RuleType>::Traverse(
const size_t queryIndex,
- SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
+ SpillTree<MetricType, StatisticType, MatType, SplitType>&
referenceNode)
{
// If we are a leaf, run the base case as necessary.
diff --git a/src/mlpack/core/tree/spill_tree/spill_tree.hpp b/src/mlpack/core/tree/spill_tree/spill_tree.hpp
index 795839b..eca4770 100644
--- a/src/mlpack/core/tree/spill_tree/spill_tree.hpp
+++ b/src/mlpack/core/tree/spill_tree/spill_tree.hpp
@@ -50,14 +50,10 @@ namespace tree /** Trees and tree-building procedures. */ {
* }
* @endcode
*
- * @tparam MetricType The metric used for tree-building. The BoundType may
- * place restrictions on the metrics that can be used.
+ * @tparam MetricType The metric used for tree-building.
* @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.
@@ -65,8 +61,6 @@ namespace tree /** Trees and tree-building procedures. */ {
template<typename MetricType,
typename StatisticType = EmptyStatistic,
typename MatType = arma::mat,
- template<typename BoundMetricType, typename...> class BoundType =
- bound::HRectBound,
template<typename SplitBoundType, typename SplitMatType>
class SplitType = MidpointSplit>
class SpillTree
@@ -93,7 +87,7 @@ class SpillTree
//! Flag to distinguish overlapping nodes from non-overlapping nodes.
bool overlappingNode;
//! The bound object for this node.
- BoundType<MetricType> bound;
+ bound::HRectBound<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.
@@ -202,9 +196,9 @@ class SpillTree
~SpillTree();
//! Return the bound object for this node.
- const BoundType<MetricType>& Bound() const { return bound; }
+ const bound::HRectBound<MetricType>& Bound() const { return bound; }
//! Return the bound object for this node.
- BoundType<MetricType>& Bound() { return bound; }
+ bound::HRectBound<MetricType>& Bound() { return bound; }
//! Return the statistic object for this node.
const StatisticType& Stat() const { return stat; }
diff --git a/src/mlpack/core/tree/spill_tree/spill_tree_impl.hpp b/src/mlpack/core/tree/spill_tree/spill_tree_impl.hpp
index 7eb823a..de35140 100644
--- a/src/mlpack/core/tree/spill_tree/spill_tree_impl.hpp
+++ b/src/mlpack/core/tree/spill_tree/spill_tree_impl.hpp
@@ -15,10 +15,9 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(
const MatType& data,
const double tau,
@@ -49,10 +48,9 @@ SpillTree(
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(
MatType&& data,
const double tau,
@@ -83,10 +81,9 @@ SpillTree(
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(
SpillTree* parent,
std::vector<size_t>& points,
@@ -117,10 +114,9 @@ SpillTree(
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(const SpillTree& other) :
left(NULL),
right(NULL),
@@ -180,10 +176,9 @@ SpillTree(const SpillTree& other) :
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(SpillTree&& other) :
left(other.left),
right(other.right),
@@ -216,11 +211,10 @@ SpillTree(SpillTree&& other) :
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename Archive>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree(
Archive& ar,
const typename boost::enable_if<typename Archive::is_loading>::type*) :
@@ -239,10 +233,9 @@ SpillTree(
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
~SpillTree()
{
delete left;
@@ -257,11 +250,10 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline bool SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::IsLeaf() const
+inline bool SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ IsLeaf() const
{
return !left;
}
@@ -272,11 +264,10 @@ inline bool SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::NumChildren() const
+inline size_t SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ NumChildren() const
{
if (left && right)
return 2;
@@ -293,12 +284,11 @@ inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline typename SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::ElemType
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+inline typename SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ ElemType
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
FurthestPointDistance() const
{
if (!IsLeaf())
@@ -318,12 +308,11 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline typename SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::ElemType
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+inline typename SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ ElemType
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
FurthestDescendantDistance() const
{
return furthestDescendantDistance;
@@ -333,12 +322,11 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline typename SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::ElemType
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+inline typename SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ ElemType
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
MinimumBoundDistance() const
{
return bound.MinWidth() / 2.0;
@@ -350,11 +338,10 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>&
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+inline SpillTree<MetricType, StatisticType, MatType, SplitType>&
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
Child(const size_t child) const
{
if (child == 0)
@@ -369,11 +356,10 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::NumPoints() const
+inline size_t SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ NumPoints() const
{
if (IsLeaf())
return count;
@@ -386,11 +372,10 @@ inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::NumDescendants() const
+inline size_t SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ NumDescendants() const
{
return count;
}
@@ -401,11 +386,10 @@ inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::Descendant(const size_t index) const
+inline size_t SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ Descendant(const size_t index) const
{
if (IsLeaf())
return (*pointsIndex)[index];
@@ -424,11 +408,10 @@ inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>::Point(const size_t index) const
+inline size_t SpillTree<MetricType, StatisticType, MatType, SplitType>::
+ Point(const size_t index) const
{
if (IsLeaf())
return (*pointsIndex)[index];
@@ -439,10 +422,9 @@ inline size_t SpillTree<MetricType, StatisticType, MatType, BoundType,
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-void SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+void SpillTree<MetricType, StatisticType, MatType, SplitType>::
SplitNode(std::vector<size_t>& points,
const size_t overlapIndex,
const size_t maxLeafSize,
@@ -516,10 +498,9 @@ void SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-bool SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+bool SpillTree<MetricType, StatisticType, MatType, SplitType>::
SplitPoints(const size_t splitDimension,
const double splitVal,
const double tau,
@@ -574,10 +555,9 @@ bool SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+SpillTree<MetricType, StatisticType, MatType, SplitType>::
SpillTree() :
left(NULL),
right(NULL),
@@ -599,11 +579,10 @@ SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
template<typename Archive>
-void SpillTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
+void SpillTree<MetricType, StatisticType, MatType, SplitType>::
Serialize(Archive& ar, const unsigned int /* version */)
{
using data::CreateNVP;
diff --git a/src/mlpack/core/tree/spill_tree/traits.hpp b/src/mlpack/core/tree/spill_tree/traits.hpp
index 36f67ab..2684003 100644
--- a/src/mlpack/core/tree/spill_tree/traits.hpp
+++ b/src/mlpack/core/tree/spill_tree/traits.hpp
@@ -22,11 +22,9 @@ namespace tree {
template<typename MetricType,
typename StatisticType,
typename MatType,
- template<typename BoundMetricType, typename...> class BoundType,
template<typename SplitBoundType, typename SplitMatType>
class SplitType>
-class TreeTraits<SpillTree<MetricType, StatisticType, MatType, BoundType,
- SplitType>>
+class TreeTraits<SpillTree<MetricType, StatisticType, MatType, SplitType>>
{
public:
/**
diff --git a/src/mlpack/core/tree/spill_tree/typedef.hpp b/src/mlpack/core/tree/spill_tree/typedef.hpp
index ef2e6f5..f3537cc 100644
--- a/src/mlpack/core/tree/spill_tree/typedef.hpp
+++ b/src/mlpack/core/tree/spill_tree/typedef.hpp
@@ -55,7 +55,6 @@ template<typename MetricType, typename StatisticType, typename MatType>
using SPTree = SpillTree<MetricType,
StatisticType,
MatType,
- bound::HRectBound,
MidpointSplit>;
/**
@@ -73,44 +72,8 @@ template<typename MetricType, typename StatisticType, typename MatType>
using MeanSPTree = SpillTree<MetricType,
StatisticType,
MatType,
- bound::HRectBound,
MeanSplit>;
-/**
- * A hybrid spill tree considering ball bounds. This is the same as the SPTree,
- * but the bounding shape of each node is a ball, not a hyper-rectangle.
- * This can make the ball tree advantageous in some higher-dimensional
- * situations and for some datasets.
- *
- * This template typedef satisfies the TreeType policy API.
- *
- * @see @ref trees, SpillTree, SPTree, MeanBallSPTree
- */
-template<typename MetricType, typename StatisticType, typename MatType>
-using BallSPTree = SpillTree<MetricType,
- StatisticType,
- MatType,
- bound::BallBound,
- MidpointSplit>;
-
-/**
- * A mean-split hybrid ball tree considering ball bounds. This is the same as
- * the BallSPTree, but this particular implementation will use the mean of the
- * data in the split dimension as the value on which to split, instead of the
- * midpoint. This can sometimes give better performance, but it is not always
- * clear which type of tree is best.
- *
- * This template typedef satisfies the TreeType policy API.
- *
- * @see @ref trees, SpillTree, BallSPTree, MeanSPTree
- */
-template<typename MetricType, typename StatisticType, typename MatType>
-using MeanBallSPTree = SpillTree<MetricType,
- StatisticType,
- MatType,
- bound::BallBound,
- MeanSplit>;
-
} // namespace tree
} // namespace mlpack
More information about the mlpack-git
mailing list