@Test
public void testMap() {

    List<LabeledVector<Double>> xs = Arrays.asList(
        new LabeledVector<>(VectorUtils.of(1, 0), 0.),
        new LabeledVector<>(VectorUtils.of(0, 1), 0.),
        new LabeledVector<>(VectorUtils.of(1, 1), 0.)
    );
    double[][] pcxi = new double[][] {
        new double[] {0.1, 0.2},
        new double[] {0.4, 0.3},
        new double[] {0.5, 0.6}
    };
    GmmPartitionData data = new GmmPartitionData(xs, pcxi);
    Vector mean1 = VectorUtils.of(1, 1);
    Vector mean2 = VectorUtils.of(0, 1);
    List<CovarianceMatricesAggregator> result = CovarianceMatricesAggregator.map(data, new Vector[] {mean1, mean2});
    assertEquals(pcxi[0].length, result.size());
    CovarianceMatricesAggregator res1 = result.get(0);
    assertArrayEquals(mean1.asArray(), res1.mean().asArray(), 1e-4);
    assertArrayEquals(
        res1.weightedSum().getStorage().data(),
        fromArray(2, 0.4, 0., 0., 0.1).getStorage().data(),
        1e-4
    );
    assertEquals(3, res1.rowCount());
    CovarianceMatricesAggregator res2 = result.get(1);
    assertArrayEquals(mean2.asArray(), res2.mean().asArray(), 1e-4);
    assertArrayEquals(
        res2.weightedSum().getStorage().data(),
        fromArray(2, 0.8, -0.2, -0.2, 0.2).getStorage().data(),
        1e-4
    );
    assertEquals(3, res2.rowCount());
}