2
我想用SymPy中的矩陣切片的值替換。明確地說,這將是像在SymPy中分配矩陣切片
import sympy as sym
A = sym.Matrix(4, 4, range(16))
A[0, :] = [-1, -2, -3, -4]
但這返回一個錯誤
ShapeError:
The Matrix `value` doesn't have the same dimensions as the in sub-
Matrix given by `key`.
在一個更有趣的例子,我想這樣做
A[0, 0::2] = [-1, -2]
A[0, 1::2] = [1, 2]
交替的奇數和偶數列。
問題:在SymPy中有這樣做的方法嗎?