函数 lusolve #

求解线性方程组 A * x = b,其中 A 是一个 [n x n] 矩阵,b 是一个 [n] 列向量。

Syntax #

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

Parameters #

Parameter Type Description
A 矩阵 | 数组 | 对象 可逆矩阵或矩阵的 LU 分解
b 矩阵 | 数组 列向量
order number 符号排序和分析顺序,详情请参阅 slu。矩阵必须是 SparseMatrix。
threshold Number 部分主元阈值(1 表示部分主元),详情请参阅 slu。矩阵必须是 SparseMatrix。

Returns #

Type Description
DenseMatrix | Array 包含线性方程组 A * x = b 解的列向量

Throws #

Type | Description —- | ———–

Examples #

const m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]

const x = math.lusolve(m, [-1, -1, -1, -1])        // x = [[-1], [-0.5], [-1/3], [-0.25]]

const f = math.lup(m)
const x1 = math.lusolve(f, [-1, -1, -1, -1])       // x1 = [[-1], [-0.5], [-1/3], [-0.25]]
const x2 = math.lusolve(f, [1, 2, 1, -1])          // x2 = [[1], [1], [1/3], [-0.25]]

const a = [[-2, 3], [2, 1]]
const b = [11, 9]
const x = math.lusolve(a, b)  // [[2], [5]]

另请参阅 #

lup, slu, lsolve, usolve

Fork me on GitHub