## Fix Python – How to get element-wise matrix multiplication (Hadamard product) in numpy?

I have two matrices

a = np.matrix([[1,2], [3,4]])

b = np.matrix([[5,6], [7,8]])

and I want to get the element-wise product, [[1*5,2*6], [3*7,4*8]], equaling

[[5,12], [21,32]]

I have tried

print(np.dot(a,b))

and

print(a*b)

but both give the result

[[19 22], [43 50]]

which is the matrix product, not the element-wise product. How can I get the ….