class KMeansUpdateCentroids extends ComputeFunction {

    static int updateCentroids(FastDistanceMatrixData matrixData, int k, int vectorSize, double[] buffer,
                               FastDistance distance) {
        int index = 0;
        DenseMatrix matrix = matrixData.getVectors();
        double[] data = matrix.getData();
        Arrays.fill(data, 0.0);
        for (int clusterId = 0; clusterId < k; clusterId++) {
            int startIndex = clusterId * (vectorSize + 1);
            double weight = buffer[startIndex + vectorSize];
            if (weight == 0) {
                continue;
            }
            BLAS.axpy(vectorSize, 1.0 / weight, buffer, startIndex, data, index * vectorSize);
            index++;
        }
        distance.updateLabel(matrixData);
        return index;
    }

    public  KMeansUpdateCentroids(FastDistance distance);

}