#NEWLINE# def blockcut( expr , rowsizes , colsizes ) : #NEWLINE# #INDENT# " Cut a matrix expression into Blocks\n\n    >>> from sympy import ImmutableMatrix, blockcut\n    >>> M = ImmutableMatrix(4, 4, range(16))\n    >>> B = blockcut(M, (1, 3), (1, 3))\n    >>> type(B).__name__\n    'BlockMatrix'\n    >>> ImmutableMatrix(B.blocks[0, 1])\n    Matrix([[1, 2, 3]])\n    " #NEWLINE# rowbounds = bounds ( rowbound ) #NEWLINE# colbounds = bounds ( colsizes ) #NEWLINE# return BlockMatrix ( [ [ MatrixSlice ( expr , rowbound , colbound ) for colbound in colbounds ] for rowbound in rowbounds ] )