title: Get nearest centroid using Thrust library? (K-Means)
body: <p>I already finished computing the distances and stored in a thrust vector, for instance, I have 2 centroids and 5 datapoints and the way I computed the distances was that for each centroid I computed the distances with the 5 datapoints first and stored in the array and later with the other centroid in a 1d array in distances, just like this:</p>
  
  <pre><code>for (int i = 0; i &lt; centroids.size(); ++i)
  {
      computeDistance(Data, distances, centroids[i], nDataPoints, nDimensions);
  }
  </code></pre>
  
  <p>Resulting in a vector 1d, for instance:</p>
  
  <pre><code>DistancesValues = {10, 15, 20, 12, 10, 5, 17, 22, 8, 7}
  
  DatapointsIndex = {1, 2,  3,   4,  5,  1,  2,  3, 4, 5}
  </code></pre>
  
  <p>Where the first 5 values represent centroid 1 and other 5 values centroid 2.</p>
  
  <p>What I would like to know if there is a thrust function in which I can store the count in another array of the minimum values for each centroid?</p>
  
  <p>Comparing the values of each index, Result should  be:</p>
  
  <pre><code>Counts = {2, 3}
  </code></pre>
  
  <p>where:  </p>
  
  <pre><code>CountOfCentroid 1 = 2       
  CountOfCentroid 2 = 3
  </code></pre>