– | the corresponding approximate eigenvectors; |
– | an orthonormal basis for the associated approximate invariant subspace; |
– | both. |
None.
Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.
Open in the MATLAB editor: nag_sparseig_real_proc_example
function nag_sparseig_real_proc_example n = 100; nev = 4; ncv = 20; h = 1/(double(n)+1); rho = 10; md = repmat(4*h, double(n), 1); me = repmat(h, double(n-1), 1); irevcm = int64(0); resid = zeros(n,1); v = zeros(n, ncv); x = zeros(n, 1); mx = zeros(n); dd = 2/h; dl = -1/h - rho/2; du = -1/h + rho/2; y = zeros(n,1); [icomm, comm, ifail] = nag_sparseig_real_init(int64(n), int64(nev), int64(ncv)); [icomm, comm, ifail] = nag_sparseig_real_option('REGULAR INVERSE', icomm, comm); [icomm, comm, ifail] = nag_sparseig_real_option('GENERALIZED', icomm, comm); % Construct m and factorise [md, me, info] = nag_lapack_dpttrf(md, me); while (irevcm ~= 5) [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ... nag_sparseig_real_iter(irevcm, resid, v, x, mx, comm, icomm); if (irevcm == -1 || irevcm == 1) y(1) = dd*x(1) + du*x(2); for i = 2:n-1 y(i) = dl*x(i-1) + dd*x(i) + du*x(i+1); end y(n) = dl*x(n-1) + dd*x(n); [x, info] = nag_lapack_dpttrs(md, me, y); elseif (irevcm == 2) y(1) = 4*x(1) + x(2); for i=2:n-1 y(i) = x(i-1) + 4*x(i) + x(i+1); end y(n) = x(n-1) + 4*x(n); x = h*y; elseif (irevcm == 4) [niter, nconv, ritzr, ritzi, rzest] = nag_sparseig_real_monit(icomm, comm); if (niter == 1) fprintf('\n'); end fprintf('Iteration %2d No. converged = %d Norm of estimates = %16.8e\n', niter, nconv, norm(rzest)); end end [nconv, dr, di, z, v, comm, icomm, ifail] = ... nag_sparseig_real_proc(0, 0, resid, v, comm, icomm); nconv, dr, di, ifail
Iteration 1 No. converged = 0 Norm of estimates = 5.56325675e+03 Iteration 2 No. converged = 0 Norm of estimates = 5.44836588e+03 Iteration 3 No. converged = 0 Norm of estimates = 5.30320774e+03 Iteration 4 No. converged = 0 Norm of estimates = 6.24234186e+03 Iteration 5 No. converged = 0 Norm of estimates = 7.15674705e+03 Iteration 6 No. converged = 0 Norm of estimates = 5.45460864e+03 Iteration 7 No. converged = 0 Norm of estimates = 6.43147571e+03 Iteration 8 No. converged = 0 Norm of estimates = 5.11241161e+03 Iteration 9 No. converged = 0 Norm of estimates = 7.19327824e+03 Iteration 10 No. converged = 1 Norm of estimates = 5.77945489e+03 Iteration 11 No. converged = 2 Norm of estimates = 4.73125738e+03 Iteration 12 No. converged = 3 Norm of estimates = 5.00078500e+03 nconv = 4 dr = 1.0e+04 * 2.0383 2.0339 2.0265 2.0163 di = 0 0 0 0 ifail = 0
Open in the MATLAB editor: f12ac_example
function f12ac_example n = 100; nev = 4; ncv = 20; h = 1/(double(n)+1); rho = 10; md = repmat(4*h, double(n), 1); me = repmat(h, double(n-1), 1); irevcm = int64(0); resid = zeros(n,1); v = zeros(n, ncv); x = zeros(n, 1); mx = zeros(n); dd = 2/h; dl = -1/h - rho/2; du = -1/h + rho/2; y = zeros(n,1); [icomm, comm, ifail] = f12aa(int64(n), int64(nev), int64(ncv)); [icomm, comm, ifail] = f12ad('REGULAR INVERSE', icomm, comm); [icomm, comm, ifail] = f12ad('GENERALIZED', icomm, comm); % Construct m and factorise [md, me, info] = f07jd(md, me); while (irevcm ~= 5) [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ... f12ab(irevcm, resid, v, x, mx, comm, icomm); if (irevcm == -1 || irevcm == 1) y(1) = dd*x(1) + du*x(2); for i = 2:n-1 y(i) = dl*x(i-1) + dd*x(i) + du*x(i+1); end y(n) = dl*x(n-1) + dd*x(n); [x, info] = f07je(md, me, y); elseif (irevcm == 2) y(1) = 4*x(1) + x(2); for i=2:n-1 y(i) = x(i-1) + 4*x(i) + x(i+1); end y(n) = x(n-1) + 4*x(n); x = h*y; elseif (irevcm == 4) [niter, nconv, ritzr, ritzi, rzest] = f12ae(icomm, comm); if (niter == 1) fprintf('\n'); end fprintf('Iteration %2d No. converged = %d Norm of estimates = %16.8e\n', ... niter, nconv, norm(rzest)); end end [nconv, dr, di, z, v, comm, icomm, ifail] = f12ac(0, 0, resid, v, comm, icomm); nconv, dr, di, ifail
Iteration 1 No. converged = 0 Norm of estimates = 5.56325675e+03 Iteration 2 No. converged = 0 Norm of estimates = 5.44836588e+03 Iteration 3 No. converged = 0 Norm of estimates = 5.30320774e+03 Iteration 4 No. converged = 0 Norm of estimates = 6.24234186e+03 Iteration 5 No. converged = 0 Norm of estimates = 7.15674705e+03 Iteration 6 No. converged = 0 Norm of estimates = 5.45460864e+03 Iteration 7 No. converged = 0 Norm of estimates = 6.43147571e+03 Iteration 8 No. converged = 0 Norm of estimates = 5.11241161e+03 Iteration 9 No. converged = 0 Norm of estimates = 7.19327824e+03 Iteration 10 No. converged = 1 Norm of estimates = 5.77945489e+03 Iteration 11 No. converged = 2 Norm of estimates = 4.73125738e+03 Iteration 12 No. converged = 3 Norm of estimates = 5.00078500e+03 nconv = 4 dr = 1.0e+04 * 2.0383 2.0339 2.0265 2.0163 di = 0 0 0 0 ifail = 0