Function lusolve

Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.

Syntax

lusolve(A, b)     // returns column vector with the solution to the linear system A * x = b
lusolve(lup, b)   // returns column vector with the solution to the linear system A * x = b, lup = lup(A)

Parameters

Parameter Type Description
A Matrix | Array | Object Invertible Matrix or the Matrix LU decomposition
b Matrix | Array Column Vector
order number The Symbolic Ordering and Analysis order, see slu for details. Matrix must be a SparseMatrix
threshold Number Partial pivoting threshold (1 for partial pivoting), see slu for details. Matrix must be a SparseMatrix.

Returns

Type Description
DenseMatrix | Array Column vector with the solution to the linear system A * x = b

Examples

var m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]];

var x = lusolve(m, [-1, -1, -1, -1]);        // x = [[-1], [-0.5], [-1/3], [-0.25]]

var f = lup(m);
var x1 = lusolve(f, [-1, -1, -1, -1]);       // x1 = [[-1], [-0.5], [-1/3], [-0.25]]
var x2 = lusolve(f, [1, 2, 1, -1]);          // x2 = [[1], [1], [1/3], [-0.25]]

var a = [[-2, 3], [2, 1]];
var b = [11, 9];
var x = lusolve(a, b);  // [[-5.5], [20]]

See also

lup, slu, lsolve, usolve