[mlpack-svn] r14030 - in mlpack/trunk/src/mlpack/core/tree: . binary_space_tree cover_tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Dec 20 17:39:52 EST 2012
Author: trironk3
Date: 2012-12-20 17:39:52 -0500 (Thu, 20 Dec 2012)
New Revision: 14030
Modified:
mlpack/trunk/src/mlpack/core/tree/ballbound.hpp
mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp
mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp
mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
mlpack/trunk/src/mlpack/core/tree/statistic.hpp
Log:
Working on implementing the ToString functionality for the tree folder - getting a seg fault with the cover tree class.
Modified: mlpack/trunk/src/mlpack/core/tree/ballbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/ballbound.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/ballbound.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -122,6 +122,12 @@
*/
template<typename MatType>
const BallBound& operator|=(const MatType& data);
+
+ /**
+ * Returns a string representation of an object.
+ */
+ std::string ToString() const;
+
};
}; // namespace bound
Modified: mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -12,6 +12,8 @@
// In case it hasn't been included already.
#include "ballbound.hpp"
+#include <string>
+
namespace mlpack {
namespace bound {
@@ -189,6 +191,16 @@
return *this;
}
+template<typename VecType>
+std::string BallBound<VecType>::ToString() const
+{
+ std::ostringstream convert;
+ convert << "BallBound [" << this << "]" << std::endl;
+ convert << "Radius: " << radius << std::endl;
+ convert << "Center: " << std::endl << center;
+ return convert.str();
+}
+
}; // namespace bound
}; // namespace mlpack
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -397,6 +397,10 @@
*/
size_t GetSplitIndex(MatType& data, int splitDim, double splitVal,
std::vector<size_t>& oldFromNew);
+
+/*
+ std::string ToString() const;
+*/
};
}; // namespace tree
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -672,6 +672,14 @@
return left;
}
+/*
+std::string BinarySpaceTree::ToString() const
+{
+ std::ostringstream convert;
+ convert << "BinarySpaceTree [" << this << "]" << std::endl;
+ return convert.str();
+}
+*/
}; // namespace tree
}; // namespace mlpack
Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -363,6 +363,8 @@
const double bound,
const size_t nearSetSize,
const size_t pointSetSize);
+ public:
+ std::string ToString() const;
};
}; // namespace tree
Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -10,6 +10,9 @@
// In case it hasn't already been included.
#include "cover_tree.hpp"
+#include <mlpack/core/util/string_util.hpp>
+#include <string>
+
namespace mlpack {
namespace tree {
@@ -817,6 +820,32 @@
return (left - nearSetSize);
}
+
+template<typename MetricType, typename RootPointPolicy, typename StatisticType>
+std::string CoverTree<MetricType, RootPointPolicy, StatisticType>::ToString() const
+{
+ std::ostringstream convert;
+ convert << "CoverTree [" << this << "]" << std::endl;
+ convert << "dataset: " << &dataset << std::endl;
+ convert << "point: " << point << std::endl;
+ convert << "scale: " << scale << std::endl;
+ convert << "base: " << base << std::endl;
+// convert << "StatisticType: " << stat << std::endl;
+ convert << "parent distance : " << parentDistance << std::endl;
+ convert << "furthest child distance: " << furthestDescendantDistance;
+ convert << std::endl;
+ convert << "children:";
+
+ if (IsLeaf() == false)
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ convert << std::endl << mlpack::util::Indent(children.at(i)->ToString());
+ }
+ }
+ std::cout << "returning " << this << std::endl;
+ return convert.str();
+}
}; // namespace tree
}; // namespace mlpack
Modified: mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -92,6 +92,12 @@
rightStat.parentStat = this;
}
+ /**
+ * Returns a string representation of an object.
+ */
+ std::string ToString() const;
+
+
//! The data points this object contains
const arma::mat* dataset;
//! The initial item in the dataset, so we don't have to make a copy
Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -131,6 +131,11 @@
*/
bool Contains(const arma::vec& point) const;
+ /**
+ * Returns a string representation of an object.
+ */
+ std::string ToString() const;
+
private:
math::Range *bounds;
size_t dim;
Modified: mlpack/trunk/src/mlpack/core/tree/statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/statistic.hpp 2012-12-20 22:38:57 UTC (rev 14029)
+++ mlpack/trunk/src/mlpack/core/tree/statistic.hpp 2012-12-20 22:39:52 UTC (rev 14030)
@@ -52,6 +52,13 @@
const EmptyStatistic& /* leftStat */,
const EmptyStatistic& /* rightStat */)
{ }
+ public:
+ std::string ToString() const
+ {
+ std::stringstream convert;
+ convert << "EmptyStatistic [" << this << "]" << std::endl;
+ return convert.str();
+ }
};
}; // namespace tree
More information about the mlpack-svn
mailing list