December 2017
Intermediate to advanced
386 pages
10h 42m
English
The function that is useful in factorizing a matrix into a lower and upper triangular matrix is available in scipy.linalg as the lu function.
In order to understand how LU factorization works, let us go through the following code snippets:
A = np.array([[2., 1., 1.], [1., 3., 2.], [1., 0., 0.]])
import scipy.linalg as linalg
P, L, U = scipy.linalg.lu(A)
print(L)[[ 1. 0. 0. ] [ 0.5 1. 0. ] [ 0.5 -0.2 1. ]]
[[ 2. 1. 1. ] [ 0. 2.5 1.5] [ 0. 0. -0.2]]
Note that, in the preceding outputs, L is a lower triangular matrix (all the elements in the ...
Read now
Unlock full access