我想使用numpy.linalg.solve来解决线性代数方程,但我收到一条错误消息,说"数组的最后2个维度必须是正方形".非常感谢!! 这是我的代码:
import numpy as np
from numpy. linalg import solve
A = np.array([[3,-1,-1,0,0,0], [-1,4,-1,-1,0,0], [0,0,-1,-1,4,-1], [0,0,0,-1,-1,3]],float)
w = np.array([5,5,0,0],float)
v = solve(A,w)
print(v)
Run Code Online (Sandbox Code Playgroud)