Skip to Content
Mastering Numerical Computing with NumPy
book

Mastering Numerical Computing with NumPy

by Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu
June 2018
Intermediate to advanced
248 pages
5h 27m
English
Packt Publishing
Content preview from Mastering Numerical Computing with NumPy

Lower-upper decomposition

Similar to Cholesky decomposition, LU decomposition decomposes a matrix (M) into lower (L) and upper (U) triangular matrices. This also helps us to simplify computationally intensive algebra. It can be summed up in the following formula:

M=LU

The following is an illustration of LU decomposition:

Let's see how it's implemented using numpy:

from numpy import arrayfrom scipy.linalg import luM = np.random.randint(low=0, high=20, size=25).reshape(5,5)print(M)# Output[[18 12 14 15  2] [ 4  2 12 18  3] [ 9 19  5 16  8] [15 19  6 16 11] [ 1 19  2 18 17]]P, L, U = lu(M)print("P:n {}n".format(P))print("L:n {}n".format(L))print("U:n ...
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

Numerical Computing with Python

Numerical Computing with Python

Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim
Scientific Computing with Python - Second Edition

Scientific Computing with Python - Second Edition

Claus Führer, Claus Fuhrer, Jan Erik Solem, Olivier Verdier
SciPy and NumPy

SciPy and NumPy

Eli Bressert

Publisher Resources

ISBN: 9781788993357Supplemental Content