function test1( A, b, shift, M ) % test1( A, b, shift, M ); % test1 uses minres.m to solve (A - shift*I)x = b. % A is assumed to be a dense or sparse matrix. % M must be positive definite (or []). % % Examples: % n = 10; % [A,b] = diagA(n); % generates A = sparse diag(1:n), b = ones(n,1); % % test1( A,b,0,[] ) % solves Ax = b. % test1( A,b,2,[] ) % solves (A-2I)x = b. % % M = A; % for i=2:4, M(i,i) = 1; end % test1( A,b,0,M ) % solves Ax = b with good preconditioner M. % test1( A,b,2,M ) % solves (A-2I)x = b with good preconditioner M. % 17 Oct 2003: First version for testing minres. % ------------------------------------------------------------------ true = 1; false = 0; [n,n] = size(A); [m,m] = size(M); iw = []; rw = []; precon = m==n; show = true; check = true; itnlim = n*5; rtol = 1.0e-12; [ x, istop, itn, rnorm, Arnorm, Anorm, Acond, ynorm ] = ... minres( n, b, A, M, iw, rw, ... precon, shift, show, check, itnlim, rtol ); % print the solution and some clue about whether it is ok. disp(' '); disp( 'Solution:' ) for j = 1:n fprintf( '%22.14e', x(j) ) end disp(' ') % End of test1.