I have 2 matrices, the first of which is sparse with integer coefficients.
import sympy
A = sympy.eye(2)
A.row_op(1, lambda v, j: v + 2*A[0, j])
The second symbolism, and I perform an operation between them:
M = MatrixSymbol('M', 2, 1)
X = A * M + A.col(1)
Now I would like to get elementary equations:
X_{0,0} = A_{0,0}
X_{0,1} = 2*A_{0,0} + A_{0,1}
One way to do this is to specify a matrix in sympy, with each element being a separate character:
rows = []
for i in range(shape[0]):
col = []
for j in range(shape[1]):
col.append(Symbol('%s_{%s,%d}' % (name,i,j)))
rows.append(col)
M = sympy.Matrix(rows)
Is there a way to do this using the MatrixSymbolabove and then get the resulting elementary equations?
source
share