Hello, everyone, Recently, I have a confused question about write matlab codes of restarted gmres. Initially, I want to use the gmres.m (*) provided by the website. This codes seem to be popular for the newcomer of Scicomp. So, I also want to modified this codes for my particular case.
But I have a question about recording the number of matrix-vector products and 2-norm of each residual vector. (If you use the built-in function gmres.m), for example, you can use gmres(30) to solve a linear system and obtain
iter = [17,20], % the total number of matrix-vector products is (17 - 1)*30 + 12 (= 492).
resvec: a 493*1 vector.
Moreover, in the gmres.m (*), there are not these two outputs.
As you know, we always call the gmres.m in MATLAB, as following style:
[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);
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 the "resvec".
I hope that I can obtain some good suggestions about handling this problem. Thank you.
http://www.netlib.org/templates/matlab/gmres.m