class KMeansUtil implements Serializable {

    public static FastDistanceMatrixData buildCentroidsMatrix(List<FastDistanceVectorData> vectors,
                                                              FastDistance distance,
                                                              int vectorSize) {
        DenseMatrix matrix = new DenseMatrix(vectorSize, vectors.size());
        for (int i = 0; i < vectors.size(); i++) {
            MatVecOp.appendVectorToMatrix(matrix, false, i, vectors.get(i).getVector());
        }
        FastDistanceMatrixData centroid = new FastDistanceMatrixData(matrix);
        distance.updateLabel(centroid);
        return centroid;
    }

}