Hi, I've written some code that performs LU decomposition square matrices.
The added functions:
numeric.LU(A, fast=false): performs LU decomposition on a square matrix A. If fast=true, then this decomposition destructively modifies A.
numeric.solve(A, b, fast=false): solves Ax=b for x on square matrix A. If fast=true, then this decomposition destructively modifies A.
I added a unit test that tests the functionality of the solver. It shows the answers from doing solve(A, b) and dot(inv(A), b) are the same.
In addition, I added a benchmark (benchmark2.html) that compares performance of solve(A, b) and dot(inv(A), b). At high dimensions (n > 200), the solve operation is dominated by the matrix clone (which doesn't happen when you pass in fast=true). I also noticed that if you tried to compare the fast version to the slow version (at least in Chrome), V8's static branch prediction kicks in and messes the results. In Firefox, though, they are equally fast.
Wow with my performance tweaks this is hilariously faster than numeric.inv/numeric.dot. I did not see that coming (although I should have guessed from the operation counts).
Hi, I've written some code that performs LU decomposition square matrices.
The added functions:
numeric.LU(A, fast=false)
: performs LU decomposition on a square matrix A. Iffast=true
, then this decomposition destructively modifies A.numeric.solve(A, b, fast=false)
: solves Ax=b for x on square matrix A. Iffast=true
, then this decomposition destructively modifies A.I added a unit test that tests the functionality of the solver. It shows the answers from doing
solve(A, b)
anddot(inv(A), b)
are the same.In addition, I added a benchmark (benchmark2.html) that compares performance of
solve(A, b)
anddot(inv(A), b)
. At high dimensions (n > 200), thesolve
operation is dominated by the matrix clone (which doesn't happen when you pass infast=true
). I also noticed that if you tried to compare the fast version to the slow version (at least in Chrome), V8's static branch prediction kicks in and messes the results. In Firefox, though, they are equally fast.