| MATLAB Function Reference | ![]() |
Syntax
x = minres(A,b) minres(A,b,tol) minres(A,b,tol,maxit) minres(A,b,tol.maxit,M) minres(A,b,tol,maxit,M1,M2) minres(A,b,tol,maxit,M1,M2,x0) minres(afun,b,tol,maxit,mifun,m2fun,x0,p1,p2,...) [x,flag] = minres(A,b,...) [x,flag,relres] = minres(A,b,...) [x,flag,relres,iter] = minres(A,b,...) [x,flag,relres,iter,resvec] = minres(A,b,...) [x,flag,relres,iter,resvec,resveccg] = minres(A,b,...)
Description
x = minres(A,b)
對線性方程組 A*x=b
找出一組最小基準剩餘(minimum norm residual)的解存入 x 中。 n*n 的係數矩陣 A 必須為對稱,但不可屬於正向定義矩陣(positive definite)。行向量 b 的長度為 n。 A 可為 afun 函式其 afun(x) 回傳 A*x。
若 minres 收歛,則會顯示該結果訊息。若 minres 經過了所限制最大數的重覆或是其他任何理由停止導致沒有收歛,則警告的訊息將顯示相關剩餘基準 norm(b-A*x)/norm(b) 及重覆的次數。
minres(A,b,tol)
定義此函式的誤差。若 tol 為 [], 則函式 minres 將使用預設值 1e-6。
minres(A,b,tol,maxit)
定義最大的重覆次數。若 maxit 為 [], 則函式 minres 將會使用預設值 min(n,20)。
minres(A,b,tol,maxit,M) 和 minres(A,b,tol,maxit,M1,M2)
使用對稱正向定義的先決條件 M 或 M = M1*M2 並且有效率地解式子 inv(sqrt(M))*A*inv(sqrt(M))*y = inv(sqrt(M))*b 中的 y, 其後回傳 x = inv(sqrt(M))*y。 若 M 為 [], 則函式 minres 沒有任何的先決條件。 M 也可為一函式其回傳 M\x。
minres(A,b,tol,maxit,M1,M2,x0)
定義起始的猜測。若 x0 為 [], 則 minres 使用預設值,即一個全為 0 的向量。
minres(afun,b,tol,maxit,m1fun,m2fun,x0,p1,p2,...)
將參數 p1,p2,... 傳送至函式 afun(x,p1,p2,...), m1fun(x,p1,p2,...), 及 m2fun(x,p1,p2,...)。
[x,flag] = minres(A,b,...)
傳回收歛的旗標。
| 旗標 | 收歛 |
0 |
minres 在預期的誤差 tol 及最大的重覆次數 maxit 中收歛。 |
1 |
minres 重覆了 maxit 次但並沒有收歛。 |
2 |
先決條件 M
為不完善的決定條件。 |
3 |
minres 沉滯。(兩個連續的重覆為相同的) |
4 |
當 flag 不為 0, x 將會是經過所有重覆後的最小基準剩餘。若有定義 flag 這項輸出參數,則將不會有任何訊息顯示。
[x,flag,relres] = minres(A,b,...)
亦傳回相關剩餘 norm(b-A*x)/norm(b)。 若 flag 為 0, relres <= tol。
[x,flag,relres,iter] = minres(A,b,...)
亦傳回計算 x 的該次重覆值,其 0 <= iter <= maxit。
[x,flag,relres,iter,resvec] = minres(A,b,...)
亦傳回每次重覆時 minres 的估計向量,包括 norm(b-A*x0)。
[x,flag,relres,iter,resvec,resveccg] = minres(A,b,...)
亦傳回每次重覆時的 Conjugate Gradients 剩餘基準的估計向量。
Examples
n = 100; on = ones(n,1); A = spdiags([-2*on 4*on -2*on],-1:1,n,n); b = sum(A,2); tol = 1e-10; maxit = 50; M1 = spdiags(4*on,0,n,n); x = minres(A,b,tol,maxit,M1,[],[]); minres converged at iteration 49 to a solution with relative residual 4.7e-014
使用矩陣向量乘法函式:
function y = afun(x,n) y = 4 * x; y(2:n) = y(2:n) - 2 * x(1:n-1); y(1:n-1) = y(1:n-1) - 2 * x(2:n);
如同此 minres的輸入:
x1 = minres(@afun,b,tol,maxit,M1,[],n);
使用不一定對稱的矩陣為函式 pcg 的輸入時,結果失敗了:
A = diag([20:-1:1, -1:-1:-20]);
b = sum(A,2); % The true solution is the vector of all ones.
x = pcg(A,b); % Errors out at the first iteration.
pcg stopped at iteration 1 without converging to the desired
tolerance 1e-006 because a scalar quantity became too small or too
large to continue computing.
The iterate returned (number 0) has relative residual 1
然而, minres 可以處理上述的矩陣 A:
x = minres(A,b,1e-6,40); minres converged at iteration 39 to a solution with relative residual 1.3e-007
See Also
bicg, bicgstab, cgs, cholinc, gmres, lsqr, pcg, qmr, symmlq
@ (function handle), / (slash),
References
[1] Barrett, R., M. Berry, T. F. Chan, et al., Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods, SIAM, Philadelphia, 1994.
[2] Paige, C. C. and M. A., "Solution of Sparse Indefinite Systems of Linear Equations." SIAM J. Numer. Anal., Vol.12, 1975, pp. 617-629.
| min | mislocked | ![]() |