[mlpack-svn] r14037 - 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
Fri Dec 21 11:59:53 EST 2012


Author: trironk3
Date: 2012-12-21 11:59:52 -0500 (Fri, 21 Dec 2012)
New Revision: 14037

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/hrectbound.hpp
   mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp
   mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
   mlpack/trunk/src/mlpack/core/tree/statistic.hpp
Log:
Implemented tree folder ToString methods. Anything involving a mrkd_statistic, binary_space_tree, and cover_tree are encountering segfaults with when they are being destructed, though.

Modified: mlpack/trunk/src/mlpack/core/tree/ballbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/ballbound.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/ballbound.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -124,7 +124,7 @@
   const BallBound& operator|=(const MatType& data);
 
   /**
-   * Returns a string representation of an object.
+   * Returns a string representation of this object.
    */
   std::string ToString() const;
 

Modified: mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/ballbound_impl.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -190,7 +190,9 @@
 
   return *this;
 }
-
+/**
+ * Returns a string representation of this object.
+ */
 template<typename VecType>
 std::string BallBound<VecType>::ToString() const
 {

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-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -397,10 +397,12 @@
    */
   size_t GetSplitIndex(MatType& data, int splitDim, double splitVal,
       std::vector<size_t>& oldFromNew);
+ public:
+  /**
+   * Returns a string representation of this object.
+   */
+  std::string ToString() const;
 
-/*
-  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-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -11,6 +11,7 @@
 
 #include <mlpack/core/util/cli.hpp>
 #include <mlpack/core/util/log.hpp>
+#include <mlpack/core/util/string_util.hpp>
 
 namespace mlpack {
 namespace tree {
@@ -672,14 +673,33 @@
   return left;
 }
 
-/*
-std::string BinarySpaceTree::ToString() const
+/**
+ * Returns a string representation of this object.
+ */
+template<typename BoundType, typename StatisticType, typename MatType>
+std::string BinarySpaceTree<BoundType, StatisticType, MatType>::ToString() const
 {
   std::ostringstream convert;
   convert << "BinarySpaceTree [" << this << "]" << std::endl;
+  convert << "begin: " << begin << std::endl;
+  convert << "count: " << count << std::endl;
+  convert << "bound: " << mlpack::util::Indent(bound.ToString());
+  convert << "statistic: " << stat.ToString();
+  convert << "leaf size: " << leafSize << std::endl;
+  convert << "splitDimension: " << splitDimension << std::endl;
+  if (left != NULL)
+  {
+    convert << "left:" << std::endl;
+    convert << mlpack::util::Indent(left->ToString());
+  }
+  if (right != NULL)
+  {
+    convert << "right:" << std::endl;
+    convert << mlpack::util::Indent(right->ToString());
+  }
   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-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -364,6 +364,9 @@
                      const size_t nearSetSize,
                      const size_t pointSetSize);
  public:
+  /**
+   * Returns a string representation of this object.
+   */
   std::string ToString() const;
 };
 

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-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -820,7 +820,9 @@
   return (left - nearSetSize);
 }
 
-
+/**
+ * Returns a string representation of this object.
+ */
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
 std::string CoverTree<MetricType, RootPointPolicy, StatisticType>::ToString() const
 {

Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -140,6 +140,11 @@
   template<typename VecType>
   bool Contains(const VecType& point) const;
 
+  /**
+   * Returns a string representation of this object.
+   */
+  std::string ToString() const;
+
  private:
   //! The dimensionality of the bound.
   size_t dim;

Modified: mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/hrectbound_impl.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -384,6 +384,19 @@
   return true;
 }
 
+/**
+ * Returns a string representation of this object.
+ */
+template<int Power, bool TakeRoot>
+std::string HRectBound<Power, TakeRoot>::ToString() const
+{
+  std::ostringstream convert;
+  convert << "HRectBound [" << this << "]" << std::endl;
+  convert << "dim: " << dim << std::endl;
+  convert << "bounds: " << bounds->ToString() << std::endl;
+  return convert.str();
+}
+
 }; // namespace bound
 }; // namespace mlpack
 

Modified: mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/mrkd_statistic.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -92,12 +92,34 @@
       rightStat.parentStat = this;
     }
 
-  /**
-   * Returns a string representation of an object.
-   */
-  std::string ToString() const;
+    /**
+     * Returns a string representation of this object.
+     */
+    std::string ToString() const
+    {
+      std::cout << "Started " << this << std::endl;
+      std::ostringstream convert;
+      convert << "MRKDStatistic [" << this << std::endl;
+      convert << "begin: " << begin << std::endl;
+      std::cout << "  after begin " << this << std::endl;
+      convert << "count: " << count << std::endl;
+      std::cout << "  after count " << this << std::endl;
+      convert << "sumOfSquaredNorms" << sumOfSquaredNorms << std::endl;
+      std::cout << "  after sum of squared norms" << this << std::endl;
+      std::cout << "Children " << this << std::endl;
+/*
+      if (leftStat != NULL)
+      {
+        convert << "leftStat:" << std::endl << mlpack::util::Indent(leftStat->ToString());
+      }
+      if (rightStat != NULL)
+      {
+        convert << "rightStat:" << std::endl << mlpack::util::Indent(rightStat->ToString());
+      }
+*/
+      std::cout << "Done " << this << std::endl;
+    }
 
-
     //! 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_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -565,6 +565,20 @@
   return true;
 }
 
+/**
+ * Returns a string representation of this object.
+ */
+template<int t_pow>
+std::string PeriodicHRectBound<t_pow>::ToString() const
+{
+  std::ostringstream convert;
+  convert << "PeriodicHRectBound [" << this << "]" << std::endl;
+  convert << "bounds: " << bounds->ToString() << std::endl;
+  convert << "dim: " << dim << std::endl;
+  convert << "box: " << box;
+  return convert.str();
+}
+
 }; // namespace bound
 }; // namespace mlpack
 

Modified: mlpack/trunk/src/mlpack/core/tree/statistic.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/statistic.hpp	2012-12-21 00:25:26 UTC (rev 14036)
+++ mlpack/trunk/src/mlpack/core/tree/statistic.hpp	2012-12-21 16:59:52 UTC (rev 14037)
@@ -53,6 +53,9 @@
                    const EmptyStatistic& /* rightStat */)
     { }
   public:
+    /**
+     * Returns a string representation of this object.
+     */
     std::string ToString() const
     {
       std::stringstream convert;




More information about the mlpack-svn mailing list