[mlpack-svn] r14044 - mlpack/trunk/src/mlpack/core/tree/cover_tree

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Dec 21 15:01:31 EST 2012


Author: rcurtin
Date: 2012-12-21 15:01:30 -0500 (Fri, 21 Dec 2012)
New Revision: 14044

Modified:
   mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp
   mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
Log:
Add copy constructor explicitly.


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 18:43:23 UTC (rev 14043)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp	2012-12-21 20:01:30 UTC (rev 14044)
@@ -165,6 +165,14 @@
             const double furthestDescendantDistance);
 
   /**
+   * Create a cover tree from another tree.  Be careful!  This may use a lot of
+   * memory and take a lot of time.
+   *
+   * @param other Cover tree to copy from.
+   */
+  CoverTree(const CoverTree& other);
+
+  /**
    * Delete this cover tree node and its children.
    */
   ~CoverTree();

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 18:43:23 UTC (rev 14043)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	2012-12-21 20:01:30 UTC (rev 14044)
@@ -434,6 +434,22 @@
 }
 
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
+CoverTree<MetricType, RootPointPolicy, StatisticType>::CoverTree(
+    const CoverTree& other) :
+    dataset(other.dataset),
+    point(other.point),
+    scale(other.scale),
+    base(other.base),
+    stat(other.stat),
+    parentDistance(other.parentDistance),
+    furthestDescendantDistance(other.furthestDescendantDistance)
+{
+  // Copy each child by hand.
+  for (size_t i = 0; i < other.NumChildren(); ++i)
+    children.push_back(new CoverTree(other.Child(i)));
+}
+
+template<typename MetricType, typename RootPointPolicy, typename StatisticType>
 CoverTree<MetricType, RootPointPolicy, StatisticType>::~CoverTree()
 {
   // Delete each child.




More information about the mlpack-svn mailing list