qr-solve[WIP]
This module solves sparse linear systems, by finding the QR-decomposition, and then using it to solve the system. It is basically a Javascript port of Quern.
Install
npm install qr-solve
Example
var qrSolve = /*Below we specify the sparse matrix: 1.7 0 0 0 0 0 0 0 0.13 00 1.0 0 0 0.02 0 0 0 0 0.010 0 1.5 0 0 0 0 0 0 00 0 0 1.1 0 0 0 0 0 00 0.02 0 0 2.6 0 0.16 0.09 0.52 0.530 0 0 0 0 1.2 0 0 0 00 0 0 0 0.16 0 1.3 0 0 0.560 0 0 0 0.09 0 0 1.6 0.11 00.13 0 0 0 0.52 0 0 0.11 1.4 00 0.01 0 0 0.53 0 0.56 0 0 3.1 */var A = 0 0 +170 0 8 +013 1 1 +100 1 4 +002 1 9 +001 2 2 +150 3 3 +110 4 1 +002 4 4 +260 4 6 +016 4 7 +009 4 8 +052 4 9 +053 5 5 +120 6 4 +016 6 6 +130 6 9 +056 7 4 +009 7 7 +160 7 8 +011 8 0 +013 8 4 +052 8 7 +011 8 8 +140 9 1 +001 9 4 +053 9 6 +056 9 9 +310 var b = 0287 022 045 044 2486 072 155 1424 1621 3759 var m = 10var n = 10 var solve = qrSolve // first decompose. var solution = n // in here we put the solutionconsole // then solve!
API
require("qr-solve").prepare(A, m, n)
Decomposes A
into its QR-decomposition. A function is returned that
can be used to solve the equation Ax = b
, for some given value of
b
.
A
a list of the matrix coefficients of the sparse matrixA
. These MUST be given in the order of increasing rows and columns numbers.m
the number of rows in the matrixA
n
the number of columns in the matrixA
Returns A function that takes a first argument b
, and a second
argument x
. The function
put the solution to the equation Ax = b
in the array x
.
NOTE the module does no sanity checking on the input arguments. It is assumed that the user knows what he/she is doing!