Decomposition

There are there decompositions provided by numpy.linalg and in this section, we will cover two that are the most commonly used: singular value decomposition (svd) and QR factorization. Let's start by computing the eigenvalues and eigenvectors first. Before we get started, if you are not familiar with eigenvalues and eigenvectors, you may review them at https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors. Let's start:

In [41]: x = np.random.randint(0, 10, 9).reshape(3,3) 
In [42]: x 
Out[42]: 
array([[ 1,  5,  0] 
       [ 7,  4,  0] 
       [ 2,  9,  8]]) 
In [42]: w, v = np.linalg.eig(x) 
In [43]: w 
Out[43]: array([ 8.,  8.6033,  -3.6033]) 
In [44]: v 
Out[44]: 
array([[ 0.,  0.0384,  0.6834] 
       [ 0.,  0.0583, -0.6292] 
       [ 1.,  0.9976,  0.3702]] 
) 

In the previous ...

Get NumPy Essentials 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.