Multiply out block matrices in sympy

Viewed 24
n = Symbol('n', integer=True)
f = Symbol('f', integer=True)
A = MatrixSymbol('A', f, n)
B = MatrixSymbol('B', f, f)
C = MatrixSymbol('C', n, f)
D = MatrixSymbol('D', f, f)
expr = (BlockMatrix([[A, B]]) @ BlockMatrix([[C], [D]]))

I can't seem to figure out what function to use to simplify expr into A@C+B@D.

I tried using block_collapse, but that didn't do anything.

1 Answers
Related