矩阵运算,常见的矩阵,元素为具体数值,我用inv方法求可逆矩阵是可以的;现在遇到一个新的矩阵运算:矩阵的每一个元素是一个含义xy的方程式,这个时候我想对这个矩阵求可逆矩阵,我用inv方法,运行直接报错。代码报错如下:
代码:
L_X=np.mat(three_L_L)*((np.mat(three_S_S).I)-L_I).tolist()
其中np.mat(three_S_S)会得到一个矩阵,矩阵元素是方程式
矩阵如下:
[[(8*G + 9*K)/(20*G + 15*K) (-4*G + 3*K)/(20*G + 15*K) 0 0 0]
[(-4*G + 3*K)/(20*G + 15*K) (-4*G + 3*K)/(20*G + 15*K) 0 0 0]
[(-4*G + 3*K)/(20*G + 15*K) (8*G + 9*K)/(20*G + 15*K) 0 0 0]
[0 0 0 (12*G + 6*K)/(20*G + 15*K) 0 0]
[0 0 0 0 (12*G + 6*K)/(20*G + 15*K) 0]
[0 0 0 0 0 (12*G + 6*K)/(20*G + 15*K)]]
报错:
File "F:\yongcong\project\EpcPro\venv\lib\site-packages\numpy\matrixlib\defmatrix.py", line 925, in getI
return asmatrix(func(self))
File "F:\yongcong\project\EpcPro\venv\lib\site-packages\numpy\linalg\linalg.py", line 1724, in pinv
u, s, vt = svd(a, full_matrices=False)
File "F:\yongcong\project\EpcPro\venv\lib\site-packages\numpy\linalg\linalg.py", line 1444, in svd
u, s, vh = gufunc(a, signature=signature, extobj=extobj)
TypeError: No loop matching the specified signature and casting