private void recomputeSeperation(double[][] means,double[][] cdist,int[][] cnum,LongStatistic diststat){
  final int k=means.length;
  for (int i=1; i < k; i++) {
    DoubleVector mi=DoubleVector.wrap(means[i]);
    for (int j=0; j < i; j++) {
      cdist[i][j]=cdist[j][i]=distanceFunction.distance(mi,DoubleVector.wrap(means[j]));
    }
  }
  double[] buf=new double[k - 1];
  for (int i=0; i < k; i++) {
    System.arraycopy(cdist[i],0,buf,0,i);
    System.arraycopy(cdist[i],i + 1,buf,i,k - i - 1);
    for (int j=0; j < buf.length; j++) {
      cnum[i][j]=j < i ? j : (j + 1);
    }
    DoubleIntegerArrayQuickSort.sort(buf,cnum[i],k - 1);
  }
  if (diststat != null) {
    diststat.increment((k * (k - 1)) >> 1);
  }
}

private void recomputeSeperation ( double [ ] [ ] means , double [ ] [ ] cdist , int [ ] [ ] cnum , LongStatistic diststat ) { final int k = means . length ; for ( int i = 1 ; i < k ; i ++ ) { DoubleVector mi = DoubleVector . wrap ( means [ i ] ) ; for ( int j = 0 ; j < i ; j ++ ) { cdist [ i ] [ j ] = cdist [ j ] [ i ] = distanceFunction . distance ( mi , DoubleVector . wrap ( means [ j ] ) ) ; } } double [ ] buf = new double [ k - 1 ] ; for ( int i = 0 ; i < k ; i ++ ) { System . arraycopy ( cdist [ i ] , 0 , buf , 0 , i ) ; System . arraycopy ( cdist [ i ] , i + 1 , buf , i , k - i - 1 ) ; for ( int j = 0 ; j < buf . length ; j ++ ) { cnum [ i ] [ j ] = j < i ? j : ( j + 1 ) ; } DoubleIntegerArrayQuickSort . sort ( buf , cnum [ i ] , k - 1 ) ; } if ( diststat != null ) { diststat . increment ( ( k * ( k - 1 ) ) > > 1 ) ; } }
recompute the separation of cluster means .
