Conversation
| for j = max(1, k-mem+1) : k | ||
| jpos = mod(j-1, mem+1) + 1; | ||
| kk = 2+k-j; | ||
| kk = 2+k-j; |
There was a problem hiding this comment.
There might be something else going on here or at line 211 below. At the very first pass through the main loop, k=1, j=1 in this loop, so that kk = 2. We write to H(1,2) and on line 211, we write to H(2,1). We never write anything in H(1,1)?!
|
I perform the following experiment: |
|
The fixes of indexing seem ok. I've not checked yet the inaccuracy in the very last iteration. |
|
I repeated your experiment several times with larger values of n and m, setting the restart parameter equal to n+m, so that the solution computed at the last iteration should be exact (but it is not because of the roundoff error). The difference between the residual norms computed by cpgmres and Matlab gmres seems to increase as the residual norm decreases (you clearly see it in the last iteration), although the solutions computed by the two gmres versions are very close (the relative error is close to the unit roundoff). By looking into the gmres implementation provided by Matlab, I found that it uses Householder transformations in the generation of the Krylov basis, in order to reduce the numerical error. Quoting the abstract of H.F. Walker, Implementation of the GMRES Method Using Householder Transformations, SIAM J. Sci. Comp. 9 (1), 1988: "numerical experiments suggest that it [the implementation based on Householder transformations] is more stable, especially as the limits of residual reduction are reached. This could explain what we observed in the experiments. Furthermore, I suspect there are other improvements that can be applied to our codes to reduce the roundoff error. However, I suggest you to proceed with the revision of the other codes I uploaded on GitHub and make the experiments we discussed about when we met in Bordeaux, so that we can finalize a version of the paper that can be (hopefully) submitted. We can (and certainly will) make further modifications later, taking also into account the comments we will receive from the reviewers. Please, let me know if you are still interested in this work. |
Introduce
rotposandjrotposindices used to index intocands. Previously, it was possible thatkposorjpos = mem + 1butcandshave lengthmem. Matlab probably silently expandedcands. One of my students noticed this while implementing standard DQGMRES for another project.