sloisel/numeric — pull request #5 by yuzeh (2012-07-27 08:41:58+00:00)
Title: LU decomposition (Solving Ax = b for square A)

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.