本文簡要介紹 python 語言中 scipy.sparse.linalg.minres
的用法。
用法:
scipy.sparse.linalg.minres(A, b, x0=None, *, shift=0.0, tol=1e-05, maxiter=None, M=None, callback=None, show=False, check=False)#
使用 MINimum RESidual 迭代求解 Ax=b
MINRES 最小化實對稱矩陣 A 的 norm(Ax - b)。與共軛梯度法不同,A 可以是不定的或奇異的。
如果 shift != 0 則該方法求解 (A - shift*I)x = b
- A: {稀疏矩陣,ndarray,LinearOperator}
線性係統的實對稱 N-by-N 矩陣 或者,
A
可以是一個線性算子,它可以使用例如scipy.sparse.linalg.LinearOperator
產生Ax
。- b: ndarray
線性係統的右手邊。具有形狀 (N,) 或 (N,1)。
- x: ndarray
融合解決方案。
- info: 整數
- 提供收斂信息:
0:成功退出 >0:未收斂到容差,迭代次數 <0:非法輸入或故障
- x0: ndarray
開始猜測解決方案。
- shift: 浮點數
應用於係統的值
(A - shift * I)x = b
。默認值為 0。- tol: 浮點數
容忍達到。當相對殘差低於 tol 時,算法終止。
- maxiter: 整數
最大迭代次數。即使沒有達到指定的容差,迭代也會在 maxiter 步後停止。
- M: {稀疏矩陣,ndarray,LinearOperator}
A 的預處理器。預處理器應該近似於 A 的逆。有效的預處理顯著提高了收斂速度,這意味著需要更少的迭代來達到給定的誤差容限。
- callback: 函數
每次迭代後調用的用戶提供的函數。它被稱為 callback(xk),其中 xk 是當前解向量。
- show: bool
如果
True
,在迭代期間打印出與解決方案相關的摘要和指標。默認為False
。- check: bool
如果
True
,運行額外的輸入驗證來檢查A和M(如果指定)是對稱的。默認為False
.
參數 ::
返回 ::
其他參數 ::
參考:
C. C. Paige 和 M. A. Saunders (1975),SIAM J. Numer。肛門。 12(4),第 617-629 頁。https://web.stanford.edu/group/SOL/software/minres/
https://web.stanford.edu/group/SOL/software/minres/minres-matlab.zip
稀疏不定線性方程組的解,:
該文件是以下 MATLAB 實現的翻譯::
例子:
>>> import numpy as np >>> from scipy.sparse import csc_matrix >>> from scipy.sparse.linalg import minres >>> A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float) >>> A = A + A.T >>> b = np.array([2, 4, -1], dtype=float) >>> x, exitCode = minres(A, b) >>> print(exitCode) # 0 indicates successful convergence 0 >>> np.allclose(A.dot(x), b) True
相關用法
- Python SciPy linalg.matmul_toeplitz用法及代碼示例
- Python SciPy linalg.matrix_balance用法及代碼示例
- Python SciPy linalg.matrix_power用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
- Python SciPy linalg.solve_circulant用法及代碼示例
- Python SciPy linalg.polar用法及代碼示例
- Python SciPy linalg.clarkson_woodruff_transform用法及代碼示例
- Python SciPy linalg.rsf2csf用法及代碼示例
- Python SciPy linalg.hessenberg用法及代碼示例
- Python SciPy linalg.tril用法及代碼示例
- Python SciPy linalg.triu用法及代碼示例
- Python SciPy linalg.svd用法及代碼示例
- Python SciPy linalg.ishermitian用法及代碼示例
- Python SciPy linalg.invhilbert用法及代碼示例
- Python SciPy linalg.factorized用法及代碼示例
- Python SciPy linalg.lu_factor用法及代碼示例
- Python SciPy linalg.SuperLU用法及代碼示例
- Python SciPy linalg.lsqr用法及代碼示例
- Python SciPy linalg.cho_factor用法及代碼示例
- Python SciPy linalg.fractional_matrix_power用法及代碼示例
- Python SciPy linalg.eig_banded用法及代碼示例
- Python SciPy linalg.tanhm用法及代碼示例
- Python SciPy linalg.orthogonal_procrustes用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.sparse.linalg.minres。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。