lusolve.md (1688B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function lusolve 4 5 Solves 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 11 math.lusolve(A, b) // returns column vector with the solution to the linear system A * x = b 12 math.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 17 Parameter | Type | Description 18 --------- | ---- | ----------- 19 `A` | Matrix | Array | Object | Invertible Matrix or the Matrix LU decomposition 20 `b` | Matrix | 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 26 Type | Description 27 ---- | ----------- 28 DenseMatrix | Array | Column vector with the solution to the linear system A * x = b 29 30 31 ### Throws 32 33 Type | Description 34 ---- | ----------- 35 36 37 ## Examples 38 39 ```js 40 const m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]] 41 42 const x = math.lusolve(m, [-1, -1, -1, -1]) // x = [[-1], [-0.5], [-1/3], [-0.25]] 43 44 const f = math.lup(m) 45 const x1 = math.lusolve(f, [-1, -1, -1, -1]) // x1 = [[-1], [-0.5], [-1/3], [-0.25]] 46 const x2 = math.lusolve(f, [1, 2, 1, -1]) // x2 = [[1], [1], [1/3], [-0.25]] 47 48 const a = [[-2, 3], [2, 1]] 49 const b = [11, 9] 50 const x = math.lusolve(a, b) // [[2], [5]] 51 ``` 52 53 54 ## See also 55 56 [lup](lup.md), 57 [slu](slu.md), 58 [lsolve](lsolve.md), 59 [usolve](usolve.md)