title: thrust vector distance calculation
body: <p>Consider the following dataset and centroids. There are 7 individuals and two means each with 8 dimensions. They are stored row major order.</p>
  
  <pre><code>short dim = 8;
  float centroids[] = {
      0.223, 0.002, 0.223, 0.412, 0.334, 0.532, 0.244, 0.612, 
      0.742, 0.812, 0.817, 0.353, 0.325, 0.452, 0.837, 0.441
  };   
  float data[] = {
      0.314, 0.504, 0.030, 0.215, 0.647, 0.045, 0.443, 0.325,
      0.731, 0.354, 0.696, 0.604, 0.954, 0.673, 0.625, 0.744, 
      0.615, 0.936, 0.045, 0.779, 0.169, 0.589, 0.303, 0.869, 
      0.275, 0.406, 0.003, 0.763, 0.471, 0.748, 0.230, 0.769, 
      0.903, 0.489, 0.135, 0.599, 0.094, 0.088, 0.272, 0.719, 
      0.112, 0.448, 0.809, 0.157, 0.227, 0.978, 0.747, 0.530, 
      0.908, 0.121, 0.321, 0.911, 0.884, 0.792, 0.658, 0.114
  };
  </code></pre>
  
  <p>I want to calculate each euclidean distances. c1 - d1, c1 - d2 .... 
  On CPU I would do:</p>
  
  <pre><code>float dist = 0.0, dist_sqrt;
  for(int i = 0; i &lt; 2; i++)
      for(int j = 0; j &lt; 7; j++)
      { 
          float dist_sum = 0.0;
          for(int k = 0; k &lt; dim; k++)
          {
              dist = centroids[i * dim + k] - data[j * dim + k];
              dist_sum += dist * dist;
          }
          dist_sqrt = sqrt(dist_sum);
          // do something with the distance
          std::cout &lt;&lt; dist_sqrt &lt;&lt; std::endl;
  
      }
  </code></pre>
  
  <p>Is there any built in solution of vector distance calculation in THRUST?</p>