GraphPartition { public static Matrix getPermutedMatrix(Matrix A, int[] permutations) { PermutationMatrix P = new PermutationMatrix(permutations); Matrix P_r = P.mult(A, new DenseMatrix(A.numRows(), A.numColumns())); Matrix P_c = P_r.transBmult(P, new DenseMatrix(A.numRows(), A.numColumns())); return P_c; }  static LabeledMTJMatrix<X> getMentionMatrix(List<T> data,
                                            Function<T, X> funcX,
                                            Function<T, Y> funcY); static LabeledDenseMatrix<L> getSimilarityMatrix(
            LabeledMTJMatrix<L> labeledMatrix); static Matrix getPermutedMatrix(Matrix A, int[] permutations); static List<L> getPermutedLabels(List<L> originalLabels,
                                                                     int[] permutations);  }
@Test public void testGetPermutationMatrix() { Matrix M = new DenseMatrix(new double[][] { new double[] { 1, 5, 9, 13 }, new double[] { 2, 6, 10, 14 }, new double[] { 3, 7, 11, 15 }, new double[] { 4, 8, 12, 16 }, }); int[] permutations = new int[] { 3, 2, 1, 0 }; Matrix R = GraphPartition.getPermutedMatrix(M, permutations); Matrix R_e = new DenseMatrix(new double[][] { new double[] { 16, 12, 8, 4 }, new double[] { 15, 11, 7, 3 }, new double[] { 14, 10, 6, 2 }, new double[] { 13, 9, 5, 1 }, }); assertArrayEquals(Matrices.getArray(R_e), Matrices.getArray(R)); }