Vector and matrix mathematics 

In the previous chapter, you practiced introductory operations with vectors and matrices. In this section, you will practice more advanced vector and matrix operations that are heavily used in linear algebra. Let's remember the dot product perspective on matrix manipulation and how it can be done with different methods when you have 2-D arrays. The following code block shows alternative ways of performing dot product calculation:

In [1]: import numpy as np         a = np.arange(12).reshape(3,2)         b = np.arange(15).reshape(2,5)         print(a)         print(b)Out[1]: [[ 0 1]  [ 2 3]  [ 4 5]] [[ 0 1 2 3 4]  [ 5 6 7 8 9] In [2]: np.dot(a,b)Out[2]: array([[ 5,  6,  7,  8,  9],                [15, 20, 25, 30, 35],                [25, 34, 43, 52, 61]]) In [3]: np.matmul(a,b) ...

Get Mastering Numerical Computing with NumPy now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.