I need to create the function [L,U] = lr(A)
which will compute the LU decomp of matrix A without pivoting or the use of inv
,lu
,etc to solve the linear equation.
Just trying to work out the pseudo-code for now and understand it. Any ideas on how to get started?
"Numerical Methods in Engineering with Python 3" by Kiusalaas is a great resource. Below is the code for Doolittle's decomposition method from the book.
# [L][U] = LUdecomp([A])
def LUdecomp(a):
n = len(a)
for k in range(0,n-1):
for i in range(k+1,n):
if a[i,k] != 0.0:
lam = a [i,k]/a[k,k]
a[i,k+1:n] = a[i,k+1:n] - lam*a[k,k+1:n]
a[i,k] = lam
return a