Iterative solvers
-----------------

AMGCL provides several iterative solvers, but it should be easy to use AMGCL
preconditioners with a user-provided solver as well. Each solver in AMGCL is a
class template. Its single template parameter specifies the backend to use.
This allows to preallocate necessary resources at class construction.
Obviously, the solver backend has to coincide with the preconditioner backend.

Each of the solvers in AMGCL provides two overloads for the ``operator()``:

.. cpp:function:: boost::tuple<size_t, scalar_type> operator()(const Matrix &A, const Precond &P, const Vec1 &rhs, Vec2 &&x) const

    Computes the solution for the given system matrix ``A`` and the right-hand
    side ``rhs``. Returns the number of iterations made and the achieved
    residual as a ``boost::tuple``. The solution vector ``x`` provides initial
    approximation on input and holds the computed solution on output.

    The system matrix may differ from the matrix used during initialization.
    This may be used for the solution of non-stationary problems with slowly
    changing coefficients. There is a strong chance that a preconditioner built
    for a time step will act as a reasonably good preconditioner for several
    subsequent time steps [DeSh12]_.

.. cpp:function:: boost::tuple<size_t, scalar_type> operator()(const Precond &P, const Vec1 &rhs, Vec2 &&x) const

    Computes the solution for the given right-hand side ``rhs``. The system
    matrix is the same that was used for the setup of the preconditioner ``P``.
    Returns the number of iterations made and the achieved residual as a
    ``boost::tuple``.  The solution vector ``x`` provides initial approximation
    on input and holds the computed solution on output.


Conjugate Gradient
#########################

``#include`` `\<amgcl/solver/cg.hpp>`_

.. doxygenclass:: amgcl::solver::cg
    :members:

BiConjugate Gradient Stabilized (BiCGSTAB)
##########################################

``#include`` `\<amgcl/solver/bicgstab.hpp>`_

.. doxygenclass:: amgcl::solver::bicgstab
    :members:

BiCGSTAB(L)
###########

``#include`` `\<amgcl/solver/bicgstabl.hpp>`_

.. doxygenclass:: amgcl::solver::bicgstabl
    :members:

GMRES
#####

``#include`` `\<amgcl/solver/gmres.hpp>`_

.. doxygenclass:: amgcl::solver::gmres
    :members:

LGMRES
#####

``#include`` `\<amgcl/solver/lgmres.hpp>`_

.. doxygenclass:: amgcl::solver::lgmres
    :members:

FGMRES
#####

``#include`` `\<amgcl/solver/fgmres.hpp>`_

.. doxygenclass:: amgcl::solver::fgmres
    :members:

.. _\<amgcl/solver/cg.hpp>:        https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/cg.hpp
.. _\<amgcl/solver/bicgstab.hpp>:  https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/bicgstab.hpp
.. _\<amgcl/solver/bicgstabl.hpp>: https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/bicgstabl.hpp
.. _\<amgcl/solver/gmres.hpp>:     https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/gmres.hpp
.. _\<amgcl/solver/lgmres.hpp>:    https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/lgmres.hpp
.. _\<amgcl/solver/fgmres.hpp>:    https://github.com/ddemidov/amgcl/blob/master/amgcl/solver/fgmres.hpp
