I have a question about Matlab and restarted gmres. I would like to use gmres.m
provided here. This code seems to be a popular for the scientific computation newcomer. I also want to modify this code for my particular case.
But I have a question about recording the number of matrix-vector products and the
2-norm of each residual vector. If you use the built-in function gmres.m
(e.g., gmres(30)
) to solve a linear system, one obtains
iter = [17,20], % the total number of matrix-vector products is (17 - 1)*30 + 12 (= 492).
iter = [17,20], % the total number of matrix-vector products is (17 - 1)*30 + 12 (= 492).
and resvec
, a 493-by-1$493\times1$ vector.
Moreover, in the gmres.m
function these two outputs are not available. As you know, we always call the gmres.m in MATLAB, as in the following style:
[x, flag, relres, iter, resvec] = gmres(A, b, restart, tol, maxit);
[x, flag, relres, iter, resvec] = gmres(A, b, restart, tol, maxit);
Then, I want to use these outputs to plot the convergence histories, i.e.,
X-axis: the number of matrix-vector products,
Y-axis: 2-norm of relative residual, i.e., norm(b - Ax_m)/norm(b);norm(b - Ax_m)/norm(b);
So, how can I record this two outputs reasonably in the modified gmres.m
? Despite my many attempts to deal with this problem, I still fail to manage it. It makes me very confused, especially for recording resvec
. Can anyone provide suggestions aboutfor handling this problem.?