– | the number of the current Arnoldi iteration; |
– | the number of converged eigenvalues at this point; |
– | the converged eigenvalues; |
– | the error bounds on the converged eigenvalues. |
None.
Open in the MATLAB editor: f12as_example
function f12as_example fprintf('f12as example results\n\n'); nx = int64(16); n = nx^2; nev = int64(4); ncv = int64(10); irevcm = int64(0); resid = complex(zeros(n,1)); v = complex(zeros(n,ncv)); x = complex(zeros(n,1)); mx = complex(zeros(n,1)); sigma = complex(5000); rho = complex(10); h = 1/double(n+1); s = rho/2; s1 = -1/h - s - sigma*h/6; s2 = 2/h - 4*sigma*h/6; s3 = -1/h + s - sigma*h/6; dl = complex(repmat(s1, n-1, 1)); dd = complex(repmat(s2, n, 1)); du = complex(repmat(s3, n-1, 1)); % Initialisation Step [icomm, comm, ifail] = f12an( ... n, nev, ncv); % Set the mode [icomm, comm, ifail] = f12ar( ... 'SHIFTED INVERSE', icomm, comm); % Set the problem type [icomm, comm, ifail] = f12ar( ... 'GENERALIZED', icomm, comm); [dl, dd, du, du2, ipiv, info] = f07cr( ... dl, dd, du); % Solve while (irevcm ~= 5) [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ... f12ap(... irevcm, resid, v, x, mx, comm, icomm); if (irevcm == -1) x = mv(x); [x, info] = f07cs(... 'N', dl, dd, du, du2, ipiv, x); elseif (irevcm == 1) [x, info] = f07cs(... 'N', dl, dd, du, du2, ipiv, mx); elseif (irevcm == 2) x = mv(x); elseif (irevcm == 4) [niter, nconv, ritz, rzest] = f12as(icomm, comm); fprintf('Iteration %d, No. converged = %d, ', niter, nconv); fprintf('norm of estimates = %12.2g\n', norm(rzest(1:nev),1)); end end % Post-process to compute eigenvalues/vectors [nconv, d, z, v, comm, icomm, ifail] = ... f12aq( ... sigma, resid, v, comm, icomm); fprintf('\n\nThe %d generalised Ritz values closest to %7.1f are:\n', ... nconv, sigma); for i=1:nconv fprintf(' %8.2f %+8.2fi\n',real(d(i)),imag(d(i))); end function [w] = mv(v) n = numel(v); w = complex(zeros(n,1)); h = 1/(n+1); w(1) = h*(4*v(1)+v(2))/6; for j=2:n-1 w(j)=h*(v(j-1)+4*v(j)+v(j+1))/6; end w(n) = h*(v(n-1)+4*v(n))/6;
f12as example results Iteration 1, No. converged = 0, norm of estimates = 7.9e-07 Iteration 2, No. converged = 1, norm of estimates = 1.7e-09 Iteration 3, No. converged = 2, norm of estimates = 3.4e-11 Iteration 4, No. converged = 2, norm of estimates = 6.2e-14 Iteration 5, No. converged = 2, norm of estimates = 8.5e-16 Iteration 6, No. converged = 3, norm of estimates = 8.2e-18 The 4 generalised Ritz values closest to 5000.0 are: 4829.85 -0.00i 5279.52 +0.00i 4400.63 +0.00i 5749.72 +0.00i