def blockcut(expr, rowsizes, colsizes):
 rowbounds = bounds(rowsizes)
 colbounds = bounds(colsizes)
 return BlockMatrix([[MatrixSlice(expr, rowbound, colbound) for colbound in colbounds] for rowbound in rowbounds])

def blockcut ( expr , rowsizes , colsizes ) : rowbounds = bounds ( rowsizes ) colbounds = bounds ( colsizes ) return BlockMatrix ( [ [ MatrixSlice ( expr , rowbound , colbound ) for colbound in colbounds ] for rowbound in rowbounds ] )
cut a matrix expression into blocks .