Skip to content

[BUG] GMRES: number of iteration is only increased if callback is provided #8815

@georgh

Description

@georgh

GMRES behaves different if you provide a callback or not. This shouldn't be the case, callback is only for debug purpose.
Reson for the difference is

if resid_ready and callback is not None:
                callback(presid / bnrm2)
                resid_ready = False
                iter_num = iter_num+1

(See https://github.com/scipy/scipy/blob/master/scipy/sparse/linalg/isolve/iterative.py#L566-L569)
iter_num is only increased if callback is not None.
If you do not provide a callback, the parameter maxiter has no effect and GMRES will only stop if it converges or breaks down (which may take a lot more then maxiter iterations).

If I find the time I might create a pr, but I failed to build scipy on my system - might take some time until I get that right. If you have the time please do it :)

Note: callback does report the norm of the residual not the vector, as noted at #7623.
Documentation should be changed accordingly.

Scipy/Numpy/Python version information:

Observed with 1.0.1 and 1.1 but error is in the Code in master, as linked above

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.sparse.linalg

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions