Documentation

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系数矩阵Amust be symmetric but need not be positive definite. It should be large and sparse. The column vectorbmust have lengthn。You can specifyAas a function handle,好玩儿,这样afun(x)returns斧头

Parameterizing Functionsexplains how to provide additional parameters to the function好玩儿, as well as the preconditioner functionmfundescribed below, if necessary.

如果minresconverges, a message to that effect is displayed. Ifminresfails 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[], thenminresuses the default,1e-6

minres(A,b,tol,maxit)指定最大迭代次数。如果最大is[], thenminresuses 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))*bfory和then returnX = Inv(SQRT(M))*y。如果Mis[]thenminresapplies no preconditioner.M可以是函数句柄mfun,这样mfun(x)returnsM\x

minres(a,b,tol,maxit,m1,m2,x0)specifies the initial guess. Ifx0is[], thenminresuses the default, an all-zero vector.

[x,flag] = minres(A,b,...)also returns a convergence flag.

旗帜

收敛

0

minresconverged to the desired tolerance托尔之内最大iterations.

1

minres迭代最大times but did not converge.

2

PreconditionerMwas ill-conditioned.

3

minresstagnated. (Two consecutive iterates were the same.)

4

One of the scalar quantities calculated duringminresbecame too small or too large to continue computing.

Whenever旗帜不是0, 解决方案xreturned 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 theminresresidual 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

此示例替换矩阵Ain the previous example with a handle to a matrix-vector product function好玩儿。该示例包含在文件中run_minres

  • Callsminreswith the function handle@afunas 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

然而,minrescan 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.

Extended Capabilities

在R2006a之前引入