DenseDoubleMatrix mat2 = new DenseDoubleMatrix(new double[][] {
{ 7, 8, 9 }, { 10, 11, 12 } });
DoubleVector foldMatrices = DenseMatrixFolder.foldMatrices(mat1, mat2);
assertEquals(12, foldMatrices.getLength());
assertEquals(0.0d, referenceFold.subtract(foldMatrices).sum(), 1e-5);
DoubleMatrix[] unfoldMatrices = DenseMatrixFolder.unfoldMatrices(
foldMatrices, new int[][] { { 2, 3 }, { 2, 3 } });
assertEquals(0.0d, unfoldMatrices[0].subtract(mat1).sum(), 1e-5);