# numpy matrix vector multiplication

| | | | | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

When I multiply two numpy arrays of sizes (n x n)*(n x 1), I get a matrix of size (n x n). Following normal matrix multiplication rules, a (n x 1) vector is expected, but I simply cannot find any information about how this is done in Python"s Numpy module.

The thing is that I don"t want to implement it manually to preserve the speed of the program.

Example code is shown below:

``````a = np.array([[ 5, 1 ,3], [ 1, 1 ,1], [ 1, 2 ,1]])
b = np.array([1, 2, 3])

print a*b
>>
[[5 2 9]
[1 2 3]
[1 4 3]]
``````

What i want is:

``````print a*b
>>
[16 6 8]
``````

👻 Read also: what is the best laptop for engineering students?

We hope this article has helped you to resolve the problem. Apart from numpy matrix vector multiplication, check other array Python module-related topics.

Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.

By the way, this material is also available in other languages:

Frank Porretti

New York | 2023-02-08

Simply put and clear. Thank you for sharing. numpy matrix vector multiplication and other issues with Arrays was always my weak point 😁. Will use it in my bachelor thesis

Dmitry Chamberlet

Warsaw | 2023-02-08

Thanks for explaining! I was stuck with numpy matrix vector multiplication for some hours, finally got it done 🤗. Will use it in my bachelor thesis

Walter Gonzalez

Moscow | 2023-02-08

Python functions is always a bit confusing 😭 numpy matrix vector multiplication is not the only problem I encountered. I am just not quite sure it is the best method

## Shop Learn programming in R: courses

\$FREE Best Python online courses for 2022

\$FREE Best laptop for Fortnite

\$399+ 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

\$

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