cupyx.scipy.sparse.linalg.lsmr#
- cupyx.scipy.sparse.linalg.lsmr(A, b, x0=None, damp=0.0, atol=1e-06, btol=1e-06, conlim=100000000.0, maxiter=None)[source]#
用于最小二乘问题的迭代求解器。
lsmr 求解线性方程组
Ax = b
。如果系统不一致,则求解最小二乘问题min ||b - Ax||_2
。A 是维度为 m-by-n 的矩形矩阵,其中允许所有情况:m = n, m > n 或 m < n。B 是长度为 m 的向量。矩阵 A 可以是密集矩阵或稀疏矩阵(通常是稀疏矩阵)。- 参数:
A (ndarray, spmatrix 或 LinearOperator) – 线性系统的实数或复数矩阵。
A
必须是cupy.ndarray
,cupyx.scipy.sparse.spmatrix
或cupyx.scipy.sparse.linalg.LinearOperator
。b (cupy.ndarray) – 线性系统的右侧向量,形状为
(m,)
或(m, 1)
。x0 (cupy.ndarray) – 解的初始猜测。如果为 None,则使用零向量。
damp (float) –
正则化最小二乘的阻尼因子。lsmr 求解正则化最小二乘问题
min ||(b) - ( A )x|| ||(0) (damp*I) ||_2
其中 damp 是一个标量。如果 damp 为 None 或 0,则系统在没有正则化的情况下求解。
atol (float) – 停止容差。lsmr 继续迭代直到某个后向误差估计小于取决于 atol 和 btol 的某个值。
btol (float) – 停止容差。lsmr 继续迭代直到某个后向误差估计小于取决于 atol 和 btol 的某个值。
conlim (float) – 如果对
cond(A)
(即矩阵的条件数)的估计超过 conlim,lsmr 将终止。如果 conlim 为 None,默认值为 1e+8。maxiter (int) – 最大迭代次数。
- 返回值:
x (ndarray): 返回的最小二乘解。
istop (int): istop 提供停止的原因。
0 means x=0 is a solution. 1 means x is an approximate solution to A*x = B, according to atol and btol. 2 means x approximately solves the least-squares problem according to atol. 3 means COND(A) seems to be greater than CONLIM. 4 is the same as 1 with atol = btol = eps (machine precision) 5 is the same as 2 with atol = eps. 6 is the same as 3 with CONLIM = 1/eps. 7 means ITN reached maxiter before the other stopping conditions were satisfied.
itn (int): 使用的迭代次数。
normr (float):
norm(b-Ax)
normar (float):
norm(A^T (b - Ax))
norma (float):
norm(A)
conda (float): A 的条件数。
normx (float):
norm(x)
- 返回类型:
参考文献
D. C.-L. Fong and M. A. Saunders, “LSMR: An iterative algorithm for sparse least-squares problems”, SIAM J. Sci. Comput., vol. 33, pp. 2950-2971, 2011.