<p>In <a href="https://github.com/mlpack/mlpack/pull/708#discussion_r71806108">src/mlpack/core/tree/vantage_point_tree/vantage_point_split_impl.hpp</a>:</p>
<pre style='color:#555'>&gt; +{
&gt; +  std::vector&lt;SortStruct&lt;ElemType&gt;&gt; sorted(samples.n_rows);
&gt; +
&gt; +  for (size_t i = 0; i &lt; samples.n_rows; i++)
&gt; +  {
&gt; +    sorted[i].point = samples[i];
&gt; +    sorted[i].dist = bound.Metric().Evaluate(data.col(vantagePoint),
&gt; +        data.col(samples[i]));
&gt; +  }
&gt; +
&gt; +  //  Sort samples according to the distance to the vantage point
&gt; +  std::sort(sorted.begin(), sorted.end(), StructComp&lt;ElemType&gt;);
&gt; +
&gt; +  //  Get the midian value
&gt; +  mu = bound.Metric().Evaluate(data.col(vantagePoint),
&gt; +      data.col(sorted[sorted.size() / 2].point));
</pre>
<p>Could you instead use Armadillo's <code>median()</code> function here?  You don't need the index of the median, just the median value itself, so I think Armadillo could work fine, and I think it would be less code (and possibly faster too).</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#r71806108">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFCP3GAe7ynWuPph8-c6-kca6jAs0ks5qYAGHgaJpZM4I_COp">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFA_33S_GEpfZQxvySv3sO7y4IeNfks5qYAGHgaJpZM4I_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#r71806108"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>