A=np.array([[1,2,3],[4,5,6],[7,8,9]])
B=np.array([[3,1,5],[9,2,4],[6,8,7]])
X=np.array([4,3,1])
Y=np.array([7,0,2])
np.dot(A@X,B@Y)
Out[21]: 6446
np.dot(A@X,np.array([Y])@B.T)
Traceback (most recent call last):
File "<ipython-input-22-5de65b47e121>", line 1, in <module>
np.dot(A@X,np.array([Y])@B.T)
ValueError: shapes (3,) and (1,3) not aligned: 3 (dim 0) != 1 (dim 0)
np.dot(A@X,Y.T@B.T)
Out[23]: 6446
np.dot(A@X,Y.T@B)
Out[24]: 4269
np.dot(A@X,Y@B.T)
Out[25]: 6446
np.dot(X,Y@A@B.T)
Out[26]: 3006
np.dot(X,Y@A.T@B.T)
Out[27]: 3918
np.dot(X,Y@B.T@A.T)
Out[28]: 5098
np.dot(X,Y@B.T@A)
Out[29]: 6446
np.linalg.inv(A)
Out[30]:
array([[ 3.15251974e+15, -6.30503948e+15, 3.15251974e+15],
[-6.30503948e+15, 1.26100790e+16, -6.30503948e+15],
[ 3.15251974e+15, -6.30503948e+15, 3.15251974e+15]])
np.dot(X,(A@B@Y))
Out[31]: 5098
np.dot(X,(A@B@Y).T)
Out[32]: 5098
Y@B.T@A.T
Out[33]: array([ 341, 815, 1289])
(A@B@Y).T
Out[34]: array([ 341, 815, 1289])
np.dot(X,Y@B.T@A)
Out[35]: 6446
np.dot(X,(A@B@Y).T)
Out[36]: 5098
Z1=(A@B@Y).T
np.dot(X,Z1)
Out[38]: 5098
Z2=Y@B.T@A.T
np.dot(X,Z2)
Out[40]: 5098
np.dot(X,Y@B.T@A)
Out[41]: 6446
np.dot(X,Y@B.T@A.T)
Out[42]: 5098
A=np.array([[1,2,3],[9,9,699],[7,8,9]])
np.dot(A@X,Y.T@B.T)
Out[44]: 57921
np.dot(X,Y@B.T@A)
Out[45]: 57921
np.dot(Y.T,B.T@A@X)
Out[46]: 57921
AX.* (BY)‘=AX.* Y’B’=X.*(Y’B’A)=Y’B’AX
这里的 ’ 表示矩阵的转置