def get_block(matrix, i, j, row_range, col_range):
    """
    Extract a submatrix of a matrix

    Parameters:
    -----------
    matrix the big matrix:
    matrix = [ M11, M12, ..., M1m;
               M21, M22, ..., M2m;
               ... ;
               Mn1, Mn2, ..., Mnm]
    i: row block index
    j: column block index
    row_range: row range
    col_range: columns range
    """
    return matrix[row_range[i]:row_range[i+1],
                  col_range[j]: col_range[j+1]].copy()