Skip to content

Instantly share code, notes, and snippets.

@kersulis
Created December 7, 2015 22:39
Show Gist options
  • Save kersulis/2f333a319388e3fe67e7 to your computer and use it in GitHub Desktop.
Save kersulis/2f333a319388e3fe67e7 to your computer and use it in GitHub Desktop.
Naive LU decomposition.
"""
Naive LU decomposition (no pivoting) from
[Bindel's CS6210 class notes](http://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec09.pdf).
Beware A[1,1] = 0...
"""
function mylu(A)
m,n = size(A)
for j = 1:n-1
A[j+1:n,j] = A[j+1:n,j]/A[j,j]
A[j+1:n,j+1:n] = A[j+1:n,j+1:n] - A[j+1:n,j]*A[j,j+1:n]
end
return A
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment