<p>In <a href="https://github.com/mlpack/mlpack/pull/708#discussion_r71806503">src/mlpack/core/tree/vantage_point_tree/vantage_point_split_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; +template&lt;typename BoundType, typename MatType&gt;
&gt; +void VantagePointSplit&lt;BoundType, MatType&gt;::
&gt; +SelectVantagePoint(const BoundType&amp; bound, const MatType&amp; data,
&gt; +    const size_t begin, const size_t count, size_t&amp; vantagePoint, ElemType&amp; mu)
&gt; +{
&gt; +  arma::uvec vantagePointCandidates;
&gt; +
&gt; +  // Get no more than max(maxNumSamples, count) vantage point candidates
&gt; +  GetDistinctSamples(vantagePointCandidates, maxNumSamples, begin, count);
&gt; +
&gt; +  ElemType bestSpread = 0;
&gt; +
&gt; +  //  Evaluate eache candidate
&gt; +  for (size_t i = 0; i &lt; vantagePointCandidates.n_rows; i++)
&gt; +  {
&gt; +    arma::uvec samples;
</pre>
<p>(I am not sure if compiler optimizations will take care of this.)  If you declare this outside the loop, then every time you call <code>GetDistinctSamples()</code>, memory won't need to be allocated.</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/708/files/300882ac96e7a663e3e303ca0c45c14c6fafe1a6#r71806503">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFDr78f-yc4zwGo0Wa8k0hiB3iCATks5qYAJigaJpZM4I_COp">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFEdGunsOGWmFfg9Ry2T1hNvqDU19ks5qYAJigaJpZM4I_COp.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/708/files/300882ac96e7a663e3e303ca0c45c14c6fafe1a6#r71806503"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>