参考
https://stackoverflow.com/questions/28578302/how-to-multiply-two-vector-and-get-a-matrix
https://blog.csdn.net/Mr_kanger/article/details/124036124
#个人测试
import numpy as np
A=np.array([1,2,4,7])
B=np.array([6,1,3])
#方法一
np.outer(B,A)
Out[15]:
array([[ 6, 12, 24, 42],
[ 1, 2, 4, 7],
[ 3, 6, 12, 21]])
#方法二
B.reshape(len(B),1)@A.reshape(1,len(A))
Out[16]:
array([[ 6, 12, 24, 42],
[ 1, 2, 4, 7],
[ 3, 6, 12, 21]])
#方法三
np.array([B]).T*np.array([A])
Out[17]:
array([[ 6, 12, 24, 42],
[ 1, 2, 4, 7],
[ 3, 6, 12, 21]])
C=np.array([[2,4,6],[1,5,3]])
np.multiply(B,C)
Out[24]:
array([[12, 4, 18],
[ 6, 5, 9]])
B*C
Out[25]:
array([[12, 4, 18],
[ 6, 5, 9]])
B*B
Out[26]: array([36, 1, 9])