static int[][] toIntMatrix(MatVar mv, boolean transpose) {
        int[] dims = mv.getDim();
        int[][] out = new int[dims[transpose ? 1 : 0]][];
        for (int i = 0; i < dims[transpose ? 1 : 0]; i++) {
            int[] ints = new int[dims[transpose ? 0 : 1]];
            for (int j = 0; j < dims[transpose ? 0 : 1]; j++) {
                ints[j] = mv.getInt(transpose ? j : i, transpose ? i : j);
            }
            out[i] = ints;
        }
        return out;
    }