'Return a submatrix by specifying a list of rows and columns.
Negative indices can be given. All indices must be in the range
-n <= i < n where n is the number of rows or columns.
Examples
>>> from sympy import Matrix
>>> m = Matrix(4, 3, range(12))
>>> m
Matrix([
[0,  1,  2],
[3,  4,  5],
[6,  7,  8],
[9, 10, 11]])
>>> m.extract([0, 1, 3], [0, 1])
Matrix([
[0,  1],
[3,  4],
[9, 10]])
Rows or columns can be repeated:
>>> m.extract([0, 0, 1], [-1])
Matrix([
[2],
[2],
[5]])
Every other row can be taken by using range to provide the indices:
>>> m.extract(range(0, m.rows, 2), [-1])
Matrix([
[2],
[8]])
RowsList or colsList can also be a list of booleans, in which case
the rows or columns corresponding to the True values will be selected:
>>> m.extract([0, 1, 2, 3], [True, False, True])
Matrix([
[0,  2],
[3,  5],
[6,  8],
[9, 11]])'

def extract(self, rowsList, colsList):

    if ((not is_sequence(rowsList)) or (not is_sequence(colsList))):
        raise TypeError('rowsList    and    colsList    must    be    iterable')
    if (rowsList and all((isinstance(i, bool) for i in rowsList))):
        rowsList = [index for (index, item) in enumerate(rowsList) if item]
    if (colsList and all((isinstance(i, bool) for i in colsList))):
        colsList = [index for (index, item) in enumerate(colsList) if item]
    rowsList = [a2idx(k, self.rows) for k in rowsList]
    colsList = [a2idx(k, self.cols) for k in colsList]
    return self._eval_extract(rowsList, colsList)
