/** Each cluster contains indices of {@link Kmeans#v_units}. */
private List<List<IntDoublePair>> getClusters()
{
List<List<IntDoublePair>> cluster = new ArrayList<List<IntDoublePair>>(K);
IntDoublePair max = new IntDoublePair(-1, -1);
int[] unit;
int i, k; double sim;
for (k=0; k<K; k++)
cluster.add(new ArrayList<IntDoublePair>());
System.out.print("Clustering: ");
for (i=0; i<N; i++)
{
unit = v_units.get(i);
max.set(-1, -1);
for (k=0; k<K; k++)
{
if ((sim = cosine(unit, k)) > max.d)
max.set(k, sim);
}
cluster.get(max.i).add(new IntDoublePair(i, max.d));
if (i%10000 == 0) System.out.print(".");
}
System.out.println();