def block_matrix(blocks):
"""
Construct a matrix where the elements are specified by the block structure
by joining the blocks appropriately.
Parameters
----------
blocks : two level deep iterable of sympy Matrix objects
The block specification of the matrices used to construct the block
matrix.
Returns
-------
matrix : sympy Matrix
A matrix whose elements are the elements of the blocks with the
specified block structure.
"""
return sp.Matrix.col_join(
*tuple(
sp.Matrix.row_join(
*tuple(mat for mat in row)) for row in blocks
)
)
评论列表
文章目录