// found. This is required for computing the optimal cost of a single
// cluster solution.
DoubleVector singleCentroid = new DenseVector(dataPoints.columns());
for (int i = 0; i < numDataPoints; ++i)
VectorMath.add(singleCentroid, dataPoints.getRowVector(i));
singleCentroid = new ScaledDoubleVector(
singleCentroid, 1/((double)numDataPoints));
// Compute the optimal cost of the single cluster case.
double optimalSingleCost = 0;
double[] distances = new double[numDataPoints];