<p>Infact, dual-tree or pelleg-moore(same as x-means) are really fast enough!!!<br>
The implement of naive-kmean now is not suitable for parallel using omp, it's “textbook style”, but also good for small dataset :)<br>
<strong>I changed the details of NaiveKMeans::Iterate method directly to use arma::kmeans</strong></p>

<div class="highlight highlight-source-c++"><pre><span class="pl-k">template</span>&lt;<span class="pl-k">typename</span> MetricType, <span class="pl-k">typename</span> MatType&gt;
<span class="pl-k">double</span> NaiveKMeans&lt;MetricType, MatType&gt;::Iterate(<span class="pl-k">const</span> arma::mat&amp; centroids, arma::mat&amp; newCentroids, arma::Col&lt;<span class="pl-c1">size_t</span>&gt;&amp; counts) {
    counts.<span class="pl-c1">zeros</span>(centroids.<span class="pl-smi">n_cols</span>); <span class="pl-c">// never used, in fact</span>
    newCentroids = centroids;

    <span class="pl-c1">arma::kmeans</span>(newCentroids, dataset, centroids.<span class="pl-smi">n_cols</span>, arma::keep_existing, <span class="pl-c1">10</span>, <span class="pl-c1">false</span>);
    <span class="pl-c1">Log::Assert</span>(newCentroids.<span class="pl-smi">n_cols</span> == centroids.<span class="pl-smi">n_cols</span>);

    <span class="pl-c">// Now normalize the centroid.</span>
    distanceCalculations += centroids.<span class="pl-smi">n_cols</span> * dataset.<span class="pl-smi">n_cols</span>;

    <span class="pl-c">// Calculate cluster distortion for this iteration.</span>
    <span class="pl-k">double</span> cNorm = <span class="pl-c1">0.0</span>;
    <span class="pl-k">for</span> (<span class="pl-c1">size_t</span> i = <span class="pl-c1">0</span>; i &lt; centroids.<span class="pl-smi">n_cols</span>; ++i) {
        cNorm += <span class="pl-c1">std::pow</span>(metric.<span class="pl-c1">Evaluate</span>(centroids.<span class="pl-c1">col</span>(i), newCentroids.<span class="pl-c1">col</span>(i)), <span class="pl-c1">2.0</span>);
    }
    distanceCalculations += centroids.<span class="pl-smi">n_cols</span>;

    <span class="pl-k">return</span> <span class="pl-c1">std::sqrt</span>(cNorm);
}</pre></div>

<p>Now it's as faster as armadillo's<br>
But this should not be a correct, good or final solution <em>_</em></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/issues/514#issuecomment-228989205">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFNEO3CyMHxalTtjtVrXjN5tgodTgks5qQN9sgaJpZM4HRP0A">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFHD8U-_1tpLsOs_bI9cz12ru-oDNks5qQN9sgaJpZM4HRP0A.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/514#issuecomment-228989205"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>