// Initialize the centroids with some document vectors
U = new DenseDoubleMatrix2D(A.rows(), k);
U.assign(A.viewPart(0, 0, A.rows(), k));
int [] minIndices = new int [D.columns()];
double [] minValues = new double [D.columns()];
for (iterationsCompleted = 0; iterationsCompleted < maxIterations; iterationsCompleted++)
{
// Calculate cosine distances
U.zMult(A, D, 1, 0, true, false);