<p>Maybe it is clearer this way:</p>

<p>"We should reset the stats in the query tree every time we reuse it to do KNN."</p>

<p>Why? Because we could be searching in a different reference dataset, or with a different value of k. Both of these situations mean different values for the bounds.</p>

<p>We have 3 Search() methods in NeighborSearch class:</p>

<ul>
<li>When doing monochromatic search the query tree is properly resetted because 
the query tree is the same than the reference tree. So, everyhing is ok.</li>
</ul>

<pre><code>void Search(const size_t k,
              arma::Mat&lt;size_t&gt;&amp; neighbors,
              arma::mat&amp; distances);
</code></pre>

<ul>
<li>When we search with different query and reference sets:

<ul>
<li>If we create a query tree inside, we have no problem, because new tree implies proper stats:</li>
</ul>
</li>
</ul>

<pre><code>void Search(const MatType&amp; querySet,
              const size_t k,
              arma::Mat&lt;size_t&gt;&amp; neighbors,
              arma::mat&amp; distances);
</code></pre>

<ul>
<li>If we receive a query tree, we don't know the state of stats there... This is the special case I am talking about:</li>
</ul>

<pre><code>void Search(Tree* queryTree,
              const size_t k,
              arma::Mat&lt;size_t&gt;&amp; neighbors,
              arma::mat&amp; distances);
</code></pre>

<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/issues/672#issuecomment-223600958">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFHdbTTwjpATEN7D7BeR-_dgGQ_G1ks5qID_RgaJpZM4Itiy7">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFDKy5cNffEAtznSxmudTKKGwicuDks5qID_RgaJpZM4Itiy7.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/issues/672#issuecomment-223600958"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>