[mlpack-svn] r13925 - 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 Nov 23 17:03:16 EST 2012


Author: rcurtin
Date: 2012-11-23 17:03:15 -0500 (Fri, 23 Nov 2012)
New Revision: 13925

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:
Manual tree constructor


Modified: mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp	2012-11-23 21:39:05 UTC (rev 13924)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree.hpp	2012-11-23 22:03:15 UTC (rev 13925)
@@ -144,6 +144,27 @@
             MetricType& metric = NULL);
 
   /**
+   * Manually construct a cover tree node; no tree assembly is done in this
+   * constructor, and children must be added manually (use Children()).  This
+   * constructor is useful when the tree is being "imported" into the CoverTree
+   * class after being created in some other manner.
+   *
+   * @param dataset Reference to the dataset this node is a part of.
+   * @param base Base that was used for tree building.
+   * @param pointIndex Index of the point in the dataset which this node refers
+   *      to.
+   * @param scale Scale of this node's level in the tree.
+   * @param parentDistance Distance to parent node point.
+   * @param furthestDescendantDistance Distance to furthest descendant point.
+   */
+  CoverTree(const arma::mat& dataset,
+            const double base,
+            const size_t pointIndex,
+            const int scale,
+            const double parentDistance,
+            const double furthestDescendantDistance);
+
+  /**
    * 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-11-23 21:39:05 UTC (rev 13924)
+++ mlpack/trunk/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp	2012-11-23 22:03:15 UTC (rev 13925)
@@ -411,7 +411,26 @@
   Log::Assert(furthestDescendantDistance <= pow(base, scale + 1));
 }
 
+// Manually create a cover tree node.
 template<typename MetricType, typename RootPointPolicy, typename StatisticType>
+CoverTree<MetricType, RootPointPolicy, StatisticType>::CoverTree(
+    const arma::mat& dataset,
+    const double base,
+    const size_t pointIndex,
+    const int scale,
+    const double parentDistance,
+    const double furthestDescendantDistance) :
+    dataset(dataset),
+    point(pointIndex),
+    scale(scale),
+    base(base),
+    parentDistance(parentDistance),
+    furthestDescendantDistance(furthestDescendantDistance)
+{
+  // Nothing to do.
+}
+
+template<typename MetricType, typename RootPointPolicy, typename StatisticType>
 CoverTree<MetricType, RootPointPolicy, StatisticType>::~CoverTree()
 {
   // Delete each child.




More information about the mlpack-svn mailing list