static Matrix> matrixToMNGrid(Matrix m, int cols, int rows) { if (m == null) null; // make reasonable cols = clamp(cols, 1, m.getWidth()); rows = clamp(rows, 1, m.getHeight()); LL rects = gridOfRects3(m.getWidth(), m.getHeight(), cols, rows); LL> matrices = mapLevelTwo(r -> new SubMatrix(m, r), rects); ret listOfListsToMatrix(matrices); }