At Mark 22: | lwork was removed from the interface |
None.
Open in the MATLAB editor: f11gf_example
function f11gf_example fprintf('f11gf example results\n\n'); % Sparse matrix A n = int64(7); nz = int64(16); a = zeros(1000,1); irow = zeros(1000,1,'int64'); icol = irow; a(1:16) = [4 1 5 2 2 3 -1 1 4 1 -2 3 2 -1 -2 5]; irow(1:16) = [1 2 2 3 4 4 5 5 5 6 6 6 7 7 7 7]; icol(1:16) = [1 1 2 3 2 4 1 4 5 2 5 6 1 2 3 7]; % Incomplete Cholesky factorization, zero fill lfill = int64(0); dtol = 0; mic = 'N'; dscale = 0; ipiv = zeros(n, 1, 'int64'); [a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ... f11ja( ... nz, a, irow, icol, lfill, dtol, mic, dscale, ipiv); % Solver setup method = 'CG'; precon = 'P'; tol = 1e-6; maxitn = int64(20); anorm = 0; sigmax = 0; maxits = int64(7); monit = int64(2); [lwreq, work, ifail] = ... f11gd(method, precon, n, tol, maxitn, anorm, sigmax, ... maxits, monit, 'sigcmp', 'S', 'norm_p', '1'); % Solver inputs irevcm = int64(0); u = zeros(n,1); v = [15; 18; -8; 21; 11; 10; 29]; wgt = zeros(n,1); % Reverse communication loop while (irevcm ~= 4) [irevcm, u, v, work, ifail] = f11ge( ... irevcm, u, v, wgt, work); if (irevcm == 1) % v = Au [v, ifail] = f11xe( ... a, irow, icol, 'N', u, 'nz', nz); elseif (irevcm == 2) % preconditioner [v, ifail] = f11jb( ... a, irow, icol, ipiv, istr, 'N', u); elseif (irevcm == 3) [itn, stplhs, stprhs, anorm, sigmax, its, sigerr, ifail] = ... f11gf(work); fprintf('\nMonitoring at iteration number %d\n',itn); fprintf('residual norm: %14.4e\n\n', stplhs); fprintf(' Solution Vector Residual Vector\n'); fprintf('%16.4f %16.4e\n', [u'; v']); end end % Get information about the computation [itn, stplhs, stprhs, anorm, sigmax, its, sigerr, ifail] = f11gf(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 Residual Vector\n'); fprintf('%16.4f %12.2e\n', [u'; v']);
f11gf example results Monitoring at iteration number 2 residual norm: 1.9938e+00 Solution Vector Residual Vector 0.9632 -2.2960e-01 1.9934 2.2254e-01 3.0583 9.5827e-02 4.1453 -2.5155e-01 4.8289 -1.7160e-01 5.6630 6.7533e-01 7.1062 -3.4737e-01 Monitoring at iteration number 4 residual norm: 6.6574e-03 Solution Vector Residual Vector 0.9994 -1.0551e-03 2.0011 -2.4675e-03 3.0008 -1.7116e-05 3.9996 4.4929e-05 4.9991 2.1359e-03 5.9993 -8.7482e-04 7.0007 6.2045e-05 Number of iterations for convergence: 5 Residual norm: 2.0428e-14 Right-hand side of termination criteria: 3.9200e-04 i-norm of matrix a: 1.0000e+01 Solution Vector Residual Vector 1.0000 0.00e+00 2.0000 0.00e+00 3.0000 -2.66e-15 4.0000 -3.55e-15 5.0000 -5.33e-15 6.0000 1.78e-15 7.0000 7.11e-15