multiply
1、 数组对应元素相乘
from numpy import *
import numpy as np
A = np.array([[1, 2, 3], [4, 5, 6]])
E = np.array([[10, 20, 30], [40, 50, 60]])
D = np.multiply(A,E)
print(type(D))
print(D,’\n’)
B = np.array([[1, 2], [3, 4], [5, 6]])
F = np.array([10, 20])
H = np.multiply(B,F)
print(type(H))
print(H,’\n’)
2、 矩阵对应元素相乘
from numpy import *
import numpy as np
A = np.mat(np.array([[1, 2, 3], [4, 5, 6]]))
E = np.mat(np.array([[10, 20, 30], [40, 50, 60]]))
D = np.multiply(A,E)
print(type(D))
print(D,’\n’)
B = np.mat(np.array([[1, 2], [3, 4], [5, 6]]))
F = np.mat(np.array([10, 20]))
H = np.multiply(B,F)
print(type(H))
print(H,’\n’)