# 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 the element-wise product (aka Hadamard product) using built-in functions?

## Shop

Best Python online courses for 2022

\$FREE

Best laptop for Excel

\$

Best laptop for Solidworks

\$399+

Best laptop for Roblox

\$399+

Best computer for crypto mining

\$499+

Best laptop for Sims 4

\$

Best laptop for Zoom

\$499

Best laptop for Minecraft

\$590

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries