Method | Requirements |
RGMRES | lwork = 120 + n(m + 3) + m(m + 5) + 1${\mathbf{lwork}}=120+\mathit{n}(m+3)+m(m+5)+1$, where m$m$ is the dimension of the basis |
CGS | lwork = 120 + 7n${\mathbf{lwork}}=120+7\mathit{n}$ |
Bi-CGSTAB(ℓ$\ell $) | lwork = 120 + (2n + ℓ)(ℓ + 2) + p${\mathbf{lwork}}=120+(2\mathit{n}+\ell )(\ell +2)+p$, where ℓ$\ell $ is the order of the method |
TFQMR | lwork = 120 + 10n${\mathbf{lwork}}=120+10\mathit{n}$, |
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_sparse_complex_gen_basic_solver_example
function nag_sparse_complex_gen_basic_solver_example method = 'TFQMR '; precon = 'P'; n = 8; m = int64(1); tol = 1e-08; maxitn = int64(20); anorm = 0; sigmax = 0; monit = int64(2); lwork = int64(6000); nz=24; a=complex(zeros(10000,1)); a(1:24)=[ 2 + 1.i, -1 + 1.i, 1 - 3.i, 4 + 7.i, -3 + 0.i, 2 + 4.i, -7 - 5.i, 2 + 1.i, 3 + 2.i, -4 + 2.i, 0 + 1.i, 5 - 3.i, -1 + 2.i, 8 + 6.i, -3 - 4.i, -6 - 2.i, 5 - 2.i, 2 + 0.i, 0 - 5.i, -1 + 5.i, 6 + 2.i, -1 + 4.i, 2 + 0.i, 3 + 3.i]; irow=zeros(10000,1,'int64'); irow(1:24) = [int64(1),1,1,2,2,2,3,3,4,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8]; icol=zeros(10000,1,'int64'); icol(1:24) = [int64(1),4,8,1,2,5,3,6,1,3,4,7,2,5,7,1,3,6,3,5,7,2,6,8]; ipivp = zeros(n,1,'int64'); ipivq = zeros(n,1,'int64'); irevcm = int64(0); lfill = int64(0); dtol = 0; milu = 'N'; wgt = zeros(8,1); u = complex(zeros(8,1)); v = [ 7 + 11.i; 1 + 24.i; -13 - 18.i; -10 + 3.i; 23 + 14.i; 17 - 7.i; 15 - 3.i; -3 + 20.i]; [a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ... nag_sparse_complex_gen_precon_ilu(int64(nz), a, irow, icol, lfill, ... dtol, milu, ipivp, ipivq); [lwreq, work, ifail] = ... nag_sparse_complex_gen_basic_setup(method, precon, int64(n), m, tol, ... maxitn, anorm, sigmax, monit, lwork, 'norm_p', '1'); while (irevcm ~= 4) [irevcm, u, v, work, ifail] = ... nag_sparse_complex_gen_basic_solver(irevcm, u, v, wgt, work); if (irevcm == -1) [v, ifail] = ... nag_sparse_complex_gen_matvec('T', a(1:nz), irow(1:nz), icol(1:nz), ... 'N', u); elseif (irevcm == 1) [v, ifail] = ... nag_sparse_complex_gen_matvec('N', a(1:nz), irow(1:nz), icol(1:nz), ... 'N', u); elseif (irevcm == 2) [v, ifail] = ... nag_sparse_complex_gen_precon_ilu_solve('N', a, irow, icol, ipivp, ... ipivq, istr, idiag, 'N', u); elseif (irevcm == 3) [itn, stplhs, stprhs, anorm, sigmax, work, ifail] = ... nag_sparse_complex_gen_basic_diag(work); fprintf('\nMonitoring at iteration number %d\nresidual norm: %14.4e\n', ... itn, stplhs); fprintf('\n Solution Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(u(i)), imag(u(i))); end fprintf('\n Residual Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(v(i)), imag(v(i))); end end end % Get information about the computation [itn, stplhs, stprhs, anorm, sigmax, work, ifail] = ... nag_sparse_complex_gen_basic_diag(work); fprintf('\nNumber of iterations for convergence: %d\n', itn); fprintf('Residual norm: %14.4e\n', stplhs); fprintf('Right-hand side of termination criteria: %14.4e\n', stprhs); fprintf('i-norm of matrix a: %14.4e\n', anorm); fprintf('\n Solution Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(u(i)), imag(u(i))); end fprintf('\n Residual Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(v(i)), imag(v(i))); end
Monitoring at iteration number 2 residual norm: 8.2345e+01 Solution Vector +6.9055e-01 + +1.4236e+00I +7.3931e-02 + -1.1880e+00I +1.4778e+00 + +4.7846e-01I +5.6572e+00 + -3.0786e+00I +1.4243e+00 + -1.1246e+00I +1.0374e-01 + +1.9740e+00I +4.4985e-01 + -1.2715e+00I +2.5704e+00 + +1.7578e+00I Residual Vector +1.7772e+00 + +4.6797e+00I +1.0774e+00 + +6.4600e+00I -3.2812e+00 + -1.1314e+01I -3.8698e+00 + -1.6438e+00I +8.9912e+00 + +1.1100e+01I +9.7428e+00 + -4.6218e-01I +3.1668e+00 + +2.8721e+00I -1.0323e+01 + +1.5837e+00I Number of iterations for convergence: 4 Residual norm: 2.7448e-11 Right-hand side of termination criteria: 8.9100e-06 i-norm of matrix a: 2.7000e+01 Solution Vector +1.0000e+00 + +1.0000e+00I +2.0000e+00 + -1.0000e+00I +3.0000e+00 + +1.0000e+00I +4.0000e+00 + -1.0000e+00I +3.0000e+00 + -1.0000e+00I +2.0000e+00 + +1.0000e+00I +1.0000e+00 + -1.0000e+00I -8.1379e-13 + +3.0000e+00I Residual Vector -6.1817e-13 + -1.9504e-12I +1.7746e-12 + -4.7180e-12I +1.3003e-12 + +1.9043e-12I +1.6733e-12 + -8.1535e-13I -2.3448e-12 + -1.4975e-12I -1.7870e-12 + +6.5459e-13I -7.8337e-13 + +1.1635e-12I +1.9051e-12 + +2.5580e-12I
Open in the MATLAB editor: f11bs_example
function f11bs_example method = 'TFQMR '; precon = 'P'; n = 8; m = int64(1); tol = 1e-08; maxitn = int64(20); anorm = 0; sigmax = 0; monit = int64(2); lwork = int64(6000); nz=24; a=complex(zeros(10000,1)); a(1:24)=[ 2 + 1.i, -1 + 1.i, 1 - 3.i, 4 + 7.i, -3 + 0.i, 2 + 4.i, -7 - 5.i, 2 + 1.i, 3 + 2.i, -4 + 2.i, 0 + 1.i, 5 - 3.i, -1 + 2.i, 8 + 6.i, -3 - 4.i, -6 - 2.i, 5 - 2.i, 2 + 0.i, 0 - 5.i, -1 + 5.i, 6 + 2.i, -1 + 4.i, 2 + 0.i, 3 + 3.i]; irow=zeros(10000,1,'int64'); irow(1:24) = [int64(1),1,1,2,2,2,3,3,4,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8]; icol=zeros(10000,1,'int64'); icol(1:24) = [int64(1),4,8,1,2,5,3,6,1,3,4,7,2,5,7,1,3,6,3,5,7,2,6,8]; ipivp = zeros(n,1,'int64'); ipivq = zeros(n,1,'int64'); irevcm = int64(0); lfill = int64(0); dtol = 0; milu = 'N'; wgt = zeros(8,1); u = complex(zeros(8,1)); v = [ 7 + 11.i; 1 + 24.i; -13 - 18.i; -10 + 3.i; 23 + 14.i; 17 - 7.i; 15 - 3.i; -3 + 20.i]; [a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ... f11dn(int64(nz), a, irow, icol, lfill, dtol, milu, ipivp, ipivq); [lwreq, work, ifail] = ... f11br(method, precon, int64(n), m, tol, maxitn, anorm, sigmax, monit, lwork, 'norm_p', '1'); while (irevcm ~= 4) [irevcm, u, v, work, ifail] = f11bs(irevcm, u, v, wgt, work); if (irevcm == -1) [v, ifail] = f11xn('T', a(1:nz), irow(1:nz), icol(1:nz), 'N', u); elseif (irevcm == 1) [v, ifail] = f11xn('N', a(1:nz), irow(1:nz), icol(1:nz), 'N', u); elseif (irevcm == 2) [v, ifail] = f11dp('N', a, irow, icol, ipivp, ipivq, istr, idiag, 'N', u); elseif (irevcm == 3) [itn, stplhs, stprhs, anorm, sigmax, work, ifail] = f11bt(work); fprintf('\nMonitoring at iteration number %d\nresidual norm: %14.4e\n', itn, stplhs); fprintf('\n Solution Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(u(i)), imag(u(i))); end fprintf('\n Residual Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(v(i)), imag(v(i))); end end end % Get information about the computation [itn, stplhs, stprhs, anorm, sigmax, work, ifail] = f11bt(work); fprintf('\nNumber of iterations for convergence: %d\n', itn); fprintf('Residual norm: %14.4e\n', stplhs); fprintf('Right-hand side of termination criteria: %14.4e\n', stprhs); fprintf('i-norm of matrix a: %14.4e\n', anorm); fprintf('\n Solution Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(u(i)), imag(u(i))); end fprintf('\n Residual Vector\n'); for i = 1:n fprintf('%+16.4e + %+16.4eI\n', real(v(i)), imag(v(i))); end
Monitoring at iteration number 2 residual norm: 8.2345e+01 Solution Vector +6.9055e-01 + +1.4236e+00I +7.3931e-02 + -1.1880e+00I +1.4778e+00 + +4.7846e-01I +5.6572e+00 + -3.0786e+00I +1.4243e+00 + -1.1246e+00I +1.0374e-01 + +1.9740e+00I +4.4985e-01 + -1.2715e+00I +2.5704e+00 + +1.7578e+00I Residual Vector +1.7772e+00 + +4.6797e+00I +1.0774e+00 + +6.4600e+00I -3.2812e+00 + -1.1314e+01I -3.8698e+00 + -1.6438e+00I +8.9912e+00 + +1.1100e+01I +9.7428e+00 + -4.6218e-01I +3.1668e+00 + +2.8721e+00I -1.0323e+01 + +1.5837e+00I Number of iterations for convergence: 4 Residual norm: 2.5802e-11 Right-hand side of termination criteria: 8.9100e-06 i-norm of matrix a: 2.7000e+01 Solution Vector +1.0000e+00 + +1.0000e+00I +2.0000e+00 + -1.0000e+00I +3.0000e+00 + +1.0000e+00I +4.0000e+00 + -1.0000e+00I +3.0000e+00 + -1.0000e+00I +2.0000e+00 + +1.0000e+00I +1.0000e+00 + -1.0000e+00I -5.4061e-13 + +3.0000e+00I Residual Vector -4.3165e-13 + -1.9966e-12I +1.7355e-12 + -4.6327e-12I +6.8212e-13 + +2.2240e-12I +1.4957e-12 + -5.4090e-13I -1.8190e-12 + -2.1512e-12I -1.9149e-12 + +1.3678e-13I -1.0107e-12 + +1.1386e-12I +1.2381e-12 + +2.6539e-12I