<p>Unfortunately, the refactoring was not straightforward. I spent a lot of time thinking about that.<br>
The main problem is bound up with the way of storing neighbors. Their indices are stored in an armadillo object. So I should know the unique index of each point in the tree. In order to do that I introduce a new variable <code>numNonDatasetPoints</code>. The <code>numNonDatasetPoints</code> variable is equal to the number of non-dataset points contained in the node. Since the tree is traversed from the root I can easily map each point to <code>[0,NumDescendants()-1]</code> in such a way that each point from the dataset has the same number as in the dataset.</p>

<p>I think I did an error: I tried to write a code that should be compatible with other tree traversers. But now I see that it is better to modify all rules in this way:<br>
<code>BaseCase(size_t globalQueryIndex, size_t globalReferenceIndex, const VecType1&amp; queryPoint, const VecType2&amp; referencePoint)</code></p>

<pre><code>double Rescore(const size_t queryIndex, const VecType&amp; queryPoint,
                 TreeType&amp; referenceNode,
                 const double oldScore)
</code></pre>

<p>and so on.<br>
I think I should rewrite the code in that way.<br>
The code still has bugs and defects.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<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-224961430">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFIA18pBOlsO3ibTRSfiYXa9zd8_Aks5qKEhCgaJpZM4IrlzT">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFCQUSzsHiR99jXsh4Lu_b6vKQcI-ks5qKEhCgaJpZM4IrlzT.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-224961430"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>