UNPKG

1.64 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function lusolve
4
5Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector.
6
7
8## Syntax
9
10```js
11math.lusolve(A, b) // returns column vector with the solution to the linear system A * x = b
12math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A)
13```
14
15### Parameters
16
17Parameter | Type | Description
18--------- | ---- | -----------
19`A` | Matrix &#124; Array &#124; Object | Invertible Matrix or the Matrix LU decomposition
20`b` | Matrix &#124; Array | Column Vector
21`order` | number | The Symbolic Ordering and Analysis order, see slu for details. Matrix must be a SparseMatrix
22`threshold` | Number | Partial pivoting threshold (1 for partial pivoting), see slu for details. Matrix must be a SparseMatrix.
23
24### Returns
25
26Type | Description
27---- | -----------
28DenseMatrix &#124; Array | Column vector with the solution to the linear system A * x = b
29
30
31## Examples
32
33```js
34const m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]
35
36const x = math.lusolve(m, [-1, -1, -1, -1]) // x = [[-1], [-0.5], [-1/3], [-0.25]]
37
38const f = math.lup(m)
39const x1 = math.lusolve(f, [-1, -1, -1, -1]) // x1 = [[-1], [-0.5], [-1/3], [-0.25]]
40const x2 = math.lusolve(f, [1, 2, 1, -1]) // x2 = [[1], [1], [1/3], [-0.25]]
41
42const a = [[-2, 3], [2, 1]]
43const b = [11, 9]
44const x = math.lusolve(a, b) // [[2], [5]]
45```
46
47
48## See also
49
50[lup](lup.md),
51[slu](slu.md),
52[lsolve](lsolve.md),
53[usolve](usolve.md)