[mlpack-git] master: Fix Copy constructor. Properly set pointer to dataset. (815391b)

gitdub at mlpack.org gitdub at mlpack.org
Thu Aug 18 12:19:00 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/0f4b25acd6aaa14294c044874ba6cc0751712baa...0a19d07bd39e6223991976474bc79671ba8aa0f0

>---------------------------------------------------------------

commit 815391bc56608312c02ea326d55cf4b1ba715e29
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Thu Aug 18 13:12:27 2016 -0300

    Fix Copy constructor. Properly set pointer to dataset.


>---------------------------------------------------------------

815391bc56608312c02ea326d55cf4b1ba715e29
 src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
index 4279d62..3054324 100644
--- a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
+++ b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp
@@ -499,7 +499,25 @@ CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
   {
     children.push_back(new CoverTree(other.Child(i)));
     children[i]->Parent() = this;
-    children[i]->dataset = this->dataset;
+  }
+
+  // Propagate matrix, but only if we are the root.
+  if (parent == NULL && localDataset)
+  {
+    std::queue<CoverTree*> queue;
+
+    for (size_t i = 0; i < NumChildren(); ++i)
+      queue.push(children[i]);
+
+    while (!queue.empty())
+    {
+      CoverTree* node = queue.front();
+      queue.pop();
+
+      node->dataset = dataset;
+      for (size_t i = 0; i < node->NumChildren(); ++i)
+        queue.push(node->children[i]);
+    }
   }
 }
 




More information about the mlpack-git mailing list