2026a
# spaugment
构造最小二乘增广方程组
函数库: TyMath
# 语法
S = spaugment(A,c)
S = spaugment(A)
# 说明
S = spaugment(A,c) 创建对称不定稀疏方阵 S = [c*I A; A' 0]。矩阵 S 与最小二乘问题有关:
min norm(b - A*x)
by
r = b - A*x
S * [r/c; x] = [b; 0]
获取残差缩放因子 c 的最优值,往往涉及计算成本非常昂贵的调用: minimum(svd(A)) 和 norm(r)。
S = spaugment(A)(不带 c 的指定值)使用 maximum(abs, A)/1000。
# 示例
构造最小二乘增广方程组
using TyMath
spaugment(magic(3))
ans = 6×6 SparseMatrixCSC{Float64, Int64} with 21 stored entries:
0.009 ⋅ ⋅ 8.0 1.0 6.0
⋅ 0.009 ⋅ 3.0 5.0 7.0
⋅ ⋅ 0.009 4.0 9.0 2.0
8.0 3.0 4.0 ⋅ ⋅ ⋅
1.0 5.0 9.0 ⋅ ⋅ ⋅
6.0 7.0 2.0 ⋅ ⋅ ⋅
spaugment(magic(3),4)
ans = 6×6 SparseMatrixCSC{Float64, Int64} with 21 stored entries:
4.0 ⋅ ⋅ 8.0 1.0 6.0
⋅ 4.0 ⋅ 3.0 5.0 7.0
⋅ ⋅ 4.0 4.0 9.0 2.0
8.0 3.0 4.0 ⋅ ⋅ ⋅
1.0 5.0 9.0 ⋅ ⋅ ⋅
6.0 7.0 2.0 ⋅ ⋅ ⋅