@Test
public void buildCentroidsMatrixTest() {

    List<FastDistanceVectorData> samples = new ArrayList<>();
    List<Vector> vectorList = new ArrayList<>();
    for (int i = 0; i < length; i++) {
        vectorList.add(DenseVector.ones(vectorSize).scale(i));
    }
    vectorList.forEach(vec -> samples.add(distance.prepareVectorData(Tuple2.of(vec, null))));
    FastDistanceMatrixData matrixData = KMeansUtil.buildCentroidsMatrix(samples, distance, vectorSize);
    DenseMatrix matrix = matrixData.getVectors();
    Assert.assertEquals(matrix.numCols(), length);
    Assert.assertEquals(matrix.numRows(), vectorSize);
    double[] label = matrixData.getLabel().getData();
    for (int i = 0; i < vectorList.size(); i++) {
        Assert.assertEquals(label[i], vectorList.get(i).normL2Square(), 0.001);
    }
}