sloisel / numeric

Numerical analysis in Javascript
http://www.numericjs.com/
Other
1.42k stars 177 forks source link

Linear solve (Ax = b) support? #4

Closed yuzeh closed 12 years ago

yuzeh commented 12 years ago

I noticed that numeric currently doesn't have a general linear solver (kind of like MATLAB's backslash operator). There is a cLU function, but it seems like that only takes matrices with up to 3 rows.

Is there any plan on supporting this? If there is, I've implemented a non-optimized version of LU factorization with pivoting for square matrices, which is a step in that direction.

sloisel commented 12 years ago

The function numeric.inv() allows you to invert an arbitrary dense matrix.

http://www.numericjs.com/workshop.php?link=810fe2a5ff8596413ee49adc9e9758a5dd055c59a745840d4aa7725e1204c73b

The functions numeric.cLU() and numeric.ccsLUP(), etc... are for more advanced usage with sparse matrices that are stored in suitable compressed matrix storage formats -- please see the documentation for details.

yuzeh commented 12 years ago

The conventional wisdom is that solving Ax = b is faster than doing inv(A) * b. I just timed my implementation of LU decomposition and I'll submit a pull request soon.