Matrix Multiplication Hadamard Product

The Hadamard product differs from the dot product in that, it is an element-wise multiplication without the summation.

Conceptually, given matrices $A$ and $B$ such that

$$ A = \begin{pmatrix} 2 & 3 \\ 1 & 5 \end{pmatrix}, B = \begin{pmatrix} 1 & 0 \\ 2 & 5 \end{pmatrix}$$

Then the Hadamard product $C = A\circ B $ is:

$$ C = \begin {pmatrix} 2*1 & 3*0 \\ 1*2 & 5*5 \end{pmatrix} = \begin{pmatrix} 2 & 0 \\ 2 & 25 \end{pmatrix}$$

Implementation in Python

import numpy as np
A = np.array([2,3,1,5]).reshape(2,2)
B = np.array([1,0,2,5]).reshape(2,2)

A * B
array([[ 2, 0], [ 2, 25]])