The Euclidean distance is used only for comparison with other Euclidean
distances. Since it is invariant that (sqrt(x) < sqrt(y)) === (x < y)
for all non-negative x,y it is a waste of effort calculating the sqrt.
#include <gsl/gsl_permutation.h>
#include <gsl/gsl_sort_vector.h>
#include <gsl/gsl_statistics.h>
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
}
}
- return sqrt (mindist);
+ return mindist;
}
dist += pow2 (gsl_matrix_get (kmeans->centers, which, j) - val->f);
}
- return sqrt (dist);
+ return dist;
}
/* Return the minimum distance of the group WHICH and all other groups */
}
}
- return sqrt (mindist);
+ return mindist;
}
dist += pow2 (gsl_matrix_get (kmeans->centers, i, j) - val->f);
}
- dist = sqrt (dist);
if (dist < mindist0)
{