Skip to Content
NumPy Essentials
book

NumPy Essentials

by Jaidev Deshpande, Leo (Liang-Huan) Chin, Tanmay Dutta, Shane Holloway
April 2016
Beginner
156 pages
3h 23m
English
Packt Publishing
Content preview from NumPy Essentials

Linear algebra in NumPy

Before we get into linear algebra class in NumPy, there are five vector products we will cover at the beginning of this section. Let's review them one by one, starting with the numpy.dot() product:

In [26]: x = np.array([[1, 2], [3, 4]]) 
In [27]: y = np.array([[10, 20], [30, 40]]) 
In [28]: np.dot(x, y) 
Out[28]: 
array([[ 70, 100], 
       [150, 220]]) 

The numpy.dot() function performs matrix multiplication, and the detailed calculation is shown here:

Linear algebra in NumPy

 numpy.vdot() handles multi-dimensional arrays differently than numpy.dot(). It does not perform a matrix product, but flattens input arguments to one-dimensional vectors first:

In [29]: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SciPy and NumPy

SciPy and NumPy

Eli Bressert
Python Distilled

Python Distilled

David M. Beazley

Publisher Resources

ISBN: 9781784393670Supplemental Content