protected Matrix slice(final int r0, final int c0, final int r1, final int c1, final Matrix res) {
        map(new MatrixMapper() {
            @Override
            public void map(int row, int col, float value) {
                if (row >= r0 && row < r1 && col >= c0 && col < c1) {
                    res.set(row - r0, col - c0, value);
                }
            }

        });
        return res;
    }