<p>I think I finished the refactoring. KFNTest, KNNTest, RangeSearchTest, AllkRANNTest and RectangleTreeTest are passed. But there are some minor issues:</p>
<ol>
<li>The std::move constructor is weird:</li>
</ol>
<pre><code> MatType dataset(std::move(data));
stat = StatisticType(*this);
// For now, just insert the points in order.
RectangleTree* root = this;
for (size_t i = firstDataIndex; i < dataset.n_cols; i++)
root->InsertPoint(dataset.col(i),i);
</code></pre>
<p>Oh... I forgot to add a space between , and i. I just noticed that.<br>
2. This code is slow (range_search_rules_impl.hpp):</p>
<pre><code> if (tree::TreeTraits<TreeType>::HasDataset)
{
for (size_t i = 0; i < queryNode.NumDescendants(); ++i)
AddResult(queryNode.Descendant(i), referenceNode);
}
else
{
for (size_t i = 0; i < queryNode.NumDescendants(); ++i)
AddResult(queryNode.Descendant(i), queryNode.DescendantPoint(i),
referenceNode);
}
</code></pre>
<p>Why don't we use an iterator instead of <code>queryNode.Descendant(i)</code>? The iterator should be faster.<br>
3. It seems the <code>arma::Mat::Col</code> and the <code>arma::Mat::unsafe_col</code> functions return a temporary object.<br>
Is there any way to avoid copying in this code:</p>
<pre><code>arma::Col<ElemType> DescendantPoint(const size_t index) const;
</code></pre>
<p>If we use an iterator we can avoid that:</p>
<pre><code> for (TreeType::const_iterator it = queryNode.begin(); it != queryNode.end(); ++it)
AddResult(it.index(), it.node().Dataset().col(it.point()), referenceNode);
</code></pre>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/664#issuecomment-225416921">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFL6bfPs8yu2XOBvtyMDZ0v3ov1HOks5qK8OigaJpZM4IrlzT">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFOiNpdgv0KyA1PYWwT17K0IKZ037ks5qK8OigaJpZM4IrlzT.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/mlpack/mlpack/pull/664#issuecomment-225416921"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>