 /*----< euclid_dist_2() >----------------------------------------------------*/
 /* square of Euclid distance between two multi-dimensional points            */
 __host__ __device__ inline static
-float euclid_dist_2(int    numdims,  /* no. dimensions */
-                    float *coord1,   /* [numdims] */
-                    float *coord2)   /* [numdims] */
+float euclid_dist_2(int    numCoords,
+                    int    numObjs,
+                    float *objects,     // [numCoords][numObjs]
+                    int    objectId,
+                    float *center)      // [numCoords]
 {
     int i;
     float ans=0.0;
 
-    for (i=0; i<numdims; i++)
-        ans += (coord1[i]-coord2[i]) * (coord1[i]-coord2[i]);
+    for (i = 0; i < numCoords; i++) {
+        ans += (objects[numObjs * i + objectId] - center[i]) *
+               (objects[numObjs * i + objectId] - center[i]);
+    }
 
     return(ans);
 }

    checkCuda(cudaMalloc(&deviceIntermediates, numReductionThreads*sizeof(unsigned int)));
//  checkCuda(cudaMalloc(&deviceNewClusterSize, numClusters*sizeof(int)));

    checkCuda(cudaMemcpy(deviceObjects, objects[0],
              numObjs*numCoords*sizeof(float), cudaMemcpyHostToDevice));
    checkCuda(cudaMemcpy(deviceMembership, membership,
              numObjs*sizeof(int), cudaMemcpyHostToDevice));

    int     *newClusterSize; /* [numClusters]: no. objects assigned in each
                                new cluster */
    float    delta;          /* % of objects change their clusters */
    float  **dimObjects;
    float  **clusters;       /* out: [numClusters][numCoords] */
    float  **newClusters;    /* [numClusters][numCoords] */

