Following this similar question I tried to retrieve the symbols of an expression containing matrix symbolic elements, without success:
import sympy as sy
P = sy.Matrix(sy.MatrixSymbol('P', 5, 2))
expr = P[2,:]*sy.transpose(P[3,:]) # Matrix([[P[2, 0]*P[3, 0] + P[2, 1]*P[3, 1]]])
expr.free_symbols # returns `{P}`
expr.atoms(sy.Symbol) # returns an empty set
How can I obtain from expr
the sequence/set P[2,0],P[2,1],P[3,0],P[3,1]
?