minres
最小剩余方法
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)
[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,...)
描述
x = minres(A,b)
attempts to find a minimum norm residual solutionx
到线性方程的系统斧头=b
。这n
-经过-n
系数矩阵A
must be symmetric but need not be positive definite. It should be large and sparse. The column vectorb
must have lengthn
。You can specifyA
as a function handle,好玩儿
,这样afun(x)
returns斧头
。
Parameterizing Functionsexplains how to provide additional parameters to the function好玩儿
, as well as the preconditioner functionmfun
described below, if necessary.
如果minres
converges, a message to that effect is displayed. Ifminres
fails to converge after the maximum number of iterations or halts for any reason, a warning message is printed displaying the relative residualnorm(b-a*x)/norm(b)
和the iteration number at which the method stopped or failed.
minres(a,b,tol)
指定该方法的耐受性。如果托尔
is[]
, thenminres
uses the default,1e-6
。
minres(A,b,tol,maxit)
指定最大迭代次数。如果最大
is[]
, thenminres
uses the default,min(n,20)
。
minres(a,b,tol,maxit,m)
和minres(a,b,tol,maxit,m1,m2)
使用对称阳性明确的预处理M
或者M = M1*M2
和effectively solve the systeminv(sqrt(M))*A*inv(sqrt(M))*y = inv(sqrt(M))*b
fory
和then returnX = Inv(SQRT(M))*y
。如果M
is[]
thenminres
applies no preconditioner.M
可以是函数句柄mfun
,这样mfun(x)
returnsM\x
。
minres(a,b,tol,maxit,m1,m2,x0)
specifies the initial guess. Ifx0
is[]
, thenminres
uses the default, an all-zero vector.
[x,flag] = minres(A,b,...)
also returns a convergence flag.
旗帜 |
收敛 |
---|---|
|
|
|
|
|
Preconditioner |
|
|
|
One of the scalar quantities calculated during |
Whenever旗帜
不是0
, 解决方案x
returned is that with minimal norm residual computed over all the iterations. No messages are displayed if the旗帜
指定输出。
[x,flag,relres] = minres(a,b,...)
还返回相对残差norm(b-a*x)/norm(b)
。如果旗帜
is0
,relres <= tol
。
[x,flag,relres,iter] = minres(A,b,...)
also returns the iteration number at whichx
被计算在哪里0 <= iter <= maxit
。
[x,flag,relres,iter,resvec] = minres(a,b,...)
also returns a vector of estimates of theminres
residual norms at each iteration, includingnorm(b-A*x0)
。
[x,flag,relres,iter,resvec,resveccg] = minres(A,b,...)
also returns a vector of estimates of the Conjugate Gradients residual norms at each iteration.
例子
Using minres with a Matrix Input
n = 100;on =一个(n,1);a = spdiags([-2*on 4*on -2*on],-1:1,n,n);b = sum(a,2);TOL = 1E-10;最大值= 50;m1 = spdiags(4*on,0,n,n);x = minres(a,b,tol,maxit,m1);在迭代49中收敛到具有相对残留4.7E-014的溶液
Using minres with a Function Handle
此示例替换矩阵A
in the previous example with a handle to a matrix-vector product function好玩儿
。该示例包含在文件中run_minres
那
Calls
minres
with the function handle@afun
as its first argument.Contains
好玩儿
as a nested function, so that all variables inrun_minres
可用于好玩儿
。
这following shows the code forrun_minres
:
function x1 = run_minres 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; M = spdiags(4*on,0,n,n); x1 = minres(@afun,b,tol,maxit,M); function y = afun(x) 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); end end
When you enter
x1=run_minres;
MATLAB®软件显示消息
在迭代49中收敛到具有相对残留4.7E-014的溶液
Using minres instead of pcg
使用对称不确定的矩阵失败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
can handle the indefinite matrixA
。
x = minres(a,b,1e-6,40);在迭代39中收敛到具有相对残留1.3E-007的溶液
参考
[1] Barrett, R., M. Berry, T. F. Chan, et al.,Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods,暹罗,费城,1994年。
[2] Paige,C。C.和M. A. Saunders,“线性方程的稀疏不确定系统的解决方案”。Siam J. Numer。肛门。, Vol.12, 1975, pp. 617-629.