[mlpack-git] master: Minor style changes for R tree variants. (a93d022)
gitdub at mlpack.org
gitdub at mlpack.org
Fri Jun 10 10:01:12 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/29d43319f1a3ace534a95e966be9e903f06b07e1...c726b603bc23c7c304523e60eaba4d496ce48e47
>---------------------------------------------------------------
commit a93d0221ad4fbc1ede677777d6af7e10748a17bc
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Jun 10 07:00:33 2016 -0700
Minor style changes for R tree variants.
>---------------------------------------------------------------
a93d0221ad4fbc1ede677777d6af7e10748a17bc
.../core/tree/rectangle_tree/r_star_tree_split.hpp | 12 ++---
.../tree/rectangle_tree/r_star_tree_split_impl.hpp | 25 ++---------
.../core/tree/rectangle_tree/r_tree_split.hpp | 18 ++++----
.../core/tree/rectangle_tree/r_tree_split_impl.hpp | 51 +++++++++-------------
.../core/tree/rectangle_tree/rectangle_tree.hpp | 2 +-
.../tree/rectangle_tree/rectangle_tree_impl.hpp | 5 ++-
.../core/tree/rectangle_tree/x_tree_split.hpp | 9 ++--
.../core/tree/rectangle_tree/x_tree_split_impl.hpp | 24 +++++-----
8 files changed, 60 insertions(+), 86 deletions(-)
diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split.hpp
index d17abf6..e632690 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split.hpp
@@ -22,27 +22,27 @@ template <typename TreeType>
class RStarTreeSplit
{
public:
- //! Default constructor
- RStarTreeSplit();
+ //! Default constructor.
+ RStarTreeSplit() { }
//! Construct this with the specified node.
- RStarTreeSplit(const TreeType *node);
+ RStarTreeSplit(const TreeType* /* node */) { }
//! Create a copy of the other.split.
- RStarTreeSplit(const TreeType &other);
+ RStarTreeSplit(const TreeType& /* other */) { }
/**
* Split a leaf node using the algorithm described in "The R*-tree: An
* Efficient and Robust Access method for Points and Rectangles." If
* necessary, this split will propagate upwards through the tree.
*/
- void SplitLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ void SplitLeafNode(TreeType* tree, std::vector<bool>& relevels);
/**
* Split a non-leaf node using the "default" algorithm. If this is a root
* node, the tree increases in depth.
*/
- bool SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ bool SplitNonLeafNode(TreeType* tree, std::vector<bool>& relevels);
private:
/**
diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
index 44dbf95..cb02190 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
@@ -15,25 +15,6 @@
namespace mlpack {
namespace tree {
-template<typename TreeType>
-RStarTreeSplit<TreeType>::RStarTreeSplit()
-{
-
-}
-
-template<typename TreeType>
-RStarTreeSplit<TreeType>::RStarTreeSplit(const TreeType *)
-{
-
-}
-
-template<typename TreeType>
-RStarTreeSplit<TreeType>::RStarTreeSplit(const TreeType &)
-{
-
-}
-
-
/**
* We call GetPointSeeds to get the two points which will be the initial points
* in the new nodes We then call AssignPointDestNode to assign the remaining
@@ -288,7 +269,8 @@ void RStarTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& r
* higher up the tree because they were already updated if necessary.
*/
template<typename TreeType>
-bool RStarTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels)
+bool RStarTreeSplit<TreeType>::SplitNonLeafNode(TreeType* tree,
+ std::vector<bool>& relevels)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -691,7 +673,8 @@ bool RStarTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>
* numberOfChildren.
*/
template<typename TreeType>
-void RStarTreeSplit<TreeType>::InsertNodeIntoTree(TreeType* destTree, TreeType* srcNode)
+void RStarTreeSplit<TreeType>::InsertNodeIntoTree(TreeType* destTree,
+ TreeType* srcNode)
{
destTree->Bound() |= srcNode->Bound();
destTree->Children()[destTree->NumChildren()++] = srcNode;
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
index a77308a..389b2d2 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split.hpp
@@ -22,37 +22,37 @@ template<typename TreeType>
class RTreeSplit
{
public:
- //! Default constructor
- RTreeSplit();
+ //! Default constructor.
+ RTreeSplit() { }
//! Construct this with the specified node.
- RTreeSplit(const TreeType *node);
+ RTreeSplit(const TreeType* /* node */) { }
- //! Create a copy of the other.split.
- RTreeSplit(const TreeType &other);
+ //! Create a copy of the other split.
+ RTreeSplit(const TreeType& /* other */) { }
/**
* Split a leaf node using the "default" algorithm. If necessary, this split
* will propagate upwards through the tree.
*/
- void SplitLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ void SplitLeafNode(TreeType* tree, std::vector<bool>& relevels);
/**
* Split a non-leaf node using the "default" algorithm. If this is a root
* node, the tree increases in depth.
*/
- bool SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ bool SplitNonLeafNode(TreeType* tree, std::vector<bool>& relevels);
private:
/**
* Get the seeds for splitting a leaf node.
*/
- static void GetPointSeeds(const TreeType *tree,int& i, int& j);
+ static void GetPointSeeds(const TreeType* tree, int& i, int& j);
/**
* Get the seeds for splitting a non-leaf node.
*/
- static void GetBoundSeeds(const TreeType *tree,int& i, int& j);
+ static void GetBoundSeeds(const TreeType* tree, int& i, int& j);
/**
* Assign points to the two new nodes.
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
index 69bf041..26e4120 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
@@ -14,24 +14,6 @@
namespace mlpack {
namespace tree {
-template<typename TreeType>
-RTreeSplit<TreeType>::RTreeSplit()
-{
-
-}
-
-template<typename TreeType>
-RTreeSplit<TreeType>::RTreeSplit(const TreeType *)
-{
-
-}
-
-template<typename TreeType>
-RTreeSplit<TreeType>::RTreeSplit(const TreeType &)
-{
-
-}
-
/**
* We call GetPointSeeds to get the two points which will be the initial points
* in the new nodes We then call AssignPointDestNode to assign the remaining
@@ -39,7 +21,8 @@ RTreeSplit<TreeType>::RTreeSplit(const TreeType &)
* new nodes into the tree, spliting the parent if necessary.
*/
template<typename TreeType>
-void RTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& relevels)
+void RTreeSplit<TreeType>::SplitLeafNode(TreeType* tree,
+ std::vector<bool>& relevels)
{
// If we are splitting the root node, we need will do things differently so
// that the constructor and other methods don't confuse the end user by giving
@@ -103,7 +86,8 @@ void RTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& relev
* higher up the tree because they were already updated if necessary.
*/
template<typename TreeType>
-bool RTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels)
+bool RTreeSplit<TreeType>::SplitNonLeafNode(TreeType* tree,
+ std::vector<bool>& relevels)
{
// If we are splitting the root node, we need will do things differently so
// that the constructor and other methods don't confuse the end user by giving
@@ -175,7 +159,9 @@ bool RTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& re
* The indices of these points will be stored in iRet and jRet.
*/
template<typename TreeType>
-void RTreeSplit<TreeType>::GetPointSeeds(const TreeType *tree,int& iRet, int& jRet)
+void RTreeSplit<TreeType>::GetPointSeeds(const TreeType* tree,
+ int& iRet,
+ int& jRet)
{
// Here we want to find the pair of points that it is worst to place in the
// same node. Because we are just using points, we will simply choose the two
@@ -203,7 +189,9 @@ void RTreeSplit<TreeType>::GetPointSeeds(const TreeType *tree,int& iRet, int& jR
* indices of the bounds will be stored in iRet and jRet.
*/
template<typename TreeType>
-void RTreeSplit<TreeType>::GetBoundSeeds(const TreeType *tree,int& iRet, int& jRet)
+void RTreeSplit<TreeType>::GetBoundSeeds(const TreeType* tree,
+ int& iRet,
+ int& jRet)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -235,10 +223,10 @@ void RTreeSplit<TreeType>::GetBoundSeeds(const TreeType *tree,int& iRet, int& jR
template<typename TreeType>
void RTreeSplit<TreeType>::AssignPointDestNode(TreeType* oldTree,
- TreeType* treeOne,
- TreeType* treeTwo,
- const int intI,
- const int intJ)
+ TreeType* treeOne,
+ TreeType* treeTwo,
+ const int intI,
+ const int intJ)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -376,10 +364,10 @@ void RTreeSplit<TreeType>::AssignPointDestNode(TreeType* oldTree,
template<typename TreeType>
void RTreeSplit<TreeType>::AssignNodeDestNode(TreeType* oldTree,
- TreeType* treeOne,
- TreeType* treeTwo,
- const int intI,
- const int intJ)
+ TreeType* treeOne,
+ TreeType* treeTwo,
+ const int intI,
+ const int intJ)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -540,7 +528,8 @@ void RTreeSplit<TreeType>::AssignNodeDestNode(TreeType* oldTree,
* numberOfChildren.
*/
template<typename TreeType>
-void RTreeSplit<TreeType>::InsertNodeIntoTree(TreeType* destTree, TreeType* srcNode)
+void RTreeSplit<TreeType>::InsertNodeIntoTree(TreeType* destTree,
+ TreeType* srcNode)
{
destTree->Bound() |= srcNode->Bound();
destTree->Children()[destTree->NumChildren()++] = srcNode;
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
index 8432f44..490f33c 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp
@@ -154,7 +154,7 @@ class RectangleTree
* @param numMaxChildren The max number of child nodes (used in x-trees).
*/
explicit RectangleTree(RectangleTree* parentNode,
- const size_t numMaxChildren = 0);
+ const size_t numMaxChildren = 0);
/**
* Create a rectangle tree by copying the other tree. Be careful! This can
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index 5e35443..dc6d997 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -104,8 +104,9 @@ template<typename MetricType,
RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType>::
RectangleTree(
RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType>*
- parentNode,const size_t numMaxChildren) :
- maxNumChildren(numMaxChildren > 0 ? numMaxChildren : parentNode->MaxNumChildren()),
+ parentNode, const size_t numMaxChildren) :
+ maxNumChildren(numMaxChildren > 0 ? numMaxChildren :
+ parentNode->MaxNumChildren()),
minNumChildren(parentNode->MinNumChildren()),
numChildren(0),
children(maxNumChildren + 1),
diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split.hpp
index 7b120a9..7b4f868 100644
--- a/src/mlpack/core/tree/rectangle_tree/x_tree_split.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split.hpp
@@ -36,23 +36,23 @@ class XTreeSplit
XTreeSplit();
//! Construct this with the specified node.
- XTreeSplit(const TreeType *node);
+ XTreeSplit(const TreeType* node);
//! Create a copy of the other.split.
- XTreeSplit(const TreeType &other);
+ XTreeSplit(const TreeType& other);
/**
* Split a leaf node using the algorithm described in "The R*-tree: An
* Efficient and Robust Access method for Points and Rectangles." If
* necessary, this split will propagate upwards through the tree.
*/
- void SplitLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ void SplitLeafNode(TreeType* tree, std::vector<bool>& relevels);
/**
* Split a non-leaf node using the "default" algorithm. If this is a root
* node, the tree increases in depth.
*/
- bool SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels);
+ bool SplitNonLeafNode(TreeType* tree, std::vector<bool>& relevels);
/**
* The X tree requires that the tree records it's "split history". To make
@@ -119,7 +119,6 @@ class XTreeSplit
//! Modify the split history of the node assosiated with this object.
SplitHistoryStruct& SplitHistory() { return splitHistory; }
-
/**
* Serialize the split.
*/
diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
index 0b43454..d3e48ed 100644
--- a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
@@ -23,10 +23,10 @@ XTreeSplit<TreeType>::XTreeSplit() :
}
template<typename TreeType>
-XTreeSplit<TreeType>::XTreeSplit(const TreeType *node) :
+XTreeSplit<TreeType>::XTreeSplit(const TreeType*node) :
normalNodeMaxNumChildren(node->Parent() ?
- node->Parent()->Split().NormalNodeMaxNumChildren() :
- node->MaxNumChildren()),
+ node->Parent()->Split().NormalNodeMaxNumChildren() :
+ node->MaxNumChildren()),
splitHistory(node->Bound().Dim())
{
@@ -40,7 +40,6 @@ XTreeSplit<TreeType>::XTreeSplit(const TreeType &other) :
}
-
/**
* We call GetPointSeeds to get the two points which will be the initial points
* in the new nodes We then call AssignPointDestNode to assign the remaining
@@ -48,7 +47,8 @@ XTreeSplit<TreeType>::XTreeSplit(const TreeType &other) :
* new nodes into the tree, spliting the parent if necessary.
*/
template<typename TreeType>
-void XTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& relevels)
+void XTreeSplit<TreeType>::SplitLeafNode(TreeType* tree,
+ std::vector<bool>& relevels)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -245,8 +245,8 @@ void XTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& relev
std::sort(sorted.begin(), sorted.end(), structComp<ElemType>);
- TreeType* treeOne = new TreeType(tree->Parent(),NormalNodeMaxNumChildren());
- TreeType* treeTwo = new TreeType(tree->Parent(),NormalNodeMaxNumChildren());
+ TreeType* treeOne = new TreeType(tree->Parent(), NormalNodeMaxNumChildren());
+ TreeType* treeTwo = new TreeType(tree->Parent(), NormalNodeMaxNumChildren());
// The leaf nodes should never have any overlap introduced by the above method
// since a split axis is chosen and then points are assigned based on their
@@ -319,7 +319,8 @@ void XTreeSplit<TreeType>::SplitLeafNode(TreeType *tree,std::vector<bool>& relev
* higher up the tree because they were already updated if necessary.
*/
template<typename TreeType>
-bool XTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& relevels)
+bool XTreeSplit<TreeType>::SplitNonLeafNode(TreeType* tree,
+ std::vector<bool>& relevels)
{
// Convenience typedef.
typedef typename TreeType::ElemType ElemType;
@@ -684,8 +685,8 @@ bool XTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& re
std::sort(sorted.begin(), sorted.end(), structComp<ElemType>);
- TreeType* treeOne = new TreeType(tree->Parent(),tree->MaxNumChildren());
- TreeType* treeTwo = new TreeType(tree->Parent(),tree->MaxNumChildren());
+ TreeType* treeOne = new TreeType(tree->Parent(), tree->MaxNumChildren());
+ TreeType* treeTwo = new TreeType(tree->Parent(), tree->MaxNumChildren());
// Now as per the X-tree paper, we ensure that this split was good enough.
bool useMinOverlapSplit = false;
@@ -770,7 +771,8 @@ bool XTreeSplit<TreeType>::SplitNonLeafNode(TreeType *tree,std::vector<bool>& re
(tree->Parent()->NumChildren() == 1))
{
// We make the root a supernode instead.
- tree->Parent()->MaxNumChildren() = tree->MaxNumChildren() + NormalNodeMaxNumChildren();
+ tree->Parent()->MaxNumChildren() = tree->MaxNumChildren() +
+ NormalNodeMaxNumChildren();
tree->Parent()->Children().resize(tree->Parent()->MaxNumChildren() + 1);
tree->Parent()->NumChildren() = tree->NumChildren();
for (size_t i = 0; i < tree->NumChildren(); i++)
More information about the mlpack-git
mailing list