CompatibilityMatrix { int[][] fix() { int[][] m = new int[nRows][mCols]; for (int i = 0; i < nRows; i++) System.arraycopy(data, (i * mCols), m[i], 0, mCols); return m; } CompatibilityMatrix(int nRows, int mCols);   }
@Test public void fix() throws Exception { CompatibilityMatrix m = new CompatibilityMatrix(5, 5); m.set(0, 1); m.set(0, 2); m.set(0, 4); m.set(1, 0); m.set(1, 3); m.set(2, 4); assertThat(m.fix(), is(new int[][]{{0, 1, 1, 0, 1}, {1, 0, 0, 1, 0}, {0, 0, 0, 0, 1}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},})); }