cg Interface

public interface cg

Description

Given a symmetric (positive definite) matrix , solves the linear system

using the Conjugate Gradient method.

References

  • Hestenes, M. R., and Stiefel, E. (1952). "Methods of Conjugate Gradients for Solving Linear Systems," Journal of Research of the National Bureau of Standards, 49(6), 409–436.

Syntax

    call cg(A, b, x, info [, rtol] [, atol] [, preconditioner] [, options])

Arguments

A : Linear operator derived from one of the abstract_sym_linop or abstract_hermitian_linop types provided by the AbstractLinops module. It is an intent(in) argument.

b : Right-hand side vector derived from one the abstract_vector types provided by the AbstractVectors module. It needs to have the same type and kind as A. It is an intent(in) argument.

x : On entry, initial guess for the solution. On exit, the solution computed by cg. It is a vector derived from one the abstract_vector types provided by the AbstractVectors module. It needs to have the same type and kind as A. It is an intent(inout) argument.

info : integer information flag.

rtol (optional) : real relative tolerance for the solver.

atol (optional) : real absolute tolerance for the solver.

preconditioner (optional) : Right preconditioner used to solve the system. It needs to be consistent with the abstract_preconditioner interface. It is an intent(in) argument.

options (optional) : Container for the gmres options given by the cg_opts type. It is an intent(in) argument.

Note

Although the interface to pass a preconditioner is exposed, it is not currently implemented.


Module Procedures

public subroutine cg_rsp(A, b, x, info, rtol, atol, preconditioner, options)

Arguments

Type IntentOptional Attributes Name
class(abstract_sym_linop_rsp), intent(in) :: A

Linear operator to be inverted.

class(abstract_vector_rsp), intent(in) :: b

Right-hand side vector.

class(abstract_vector_rsp), intent(inout) :: x

Solution vector.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: rtol

Relative solver tolerance

real(kind=sp), intent(in), optional :: atol

Absolute solver tolerance

class(abstract_precond_rsp), intent(in), optional :: preconditioner

Preconditioner (not yet supported).

type(cg_sp_opts), intent(in), optional :: options

Options for the conjugate gradient solver.

public subroutine cg_rdp(A, b, x, info, rtol, atol, preconditioner, options)

Arguments

Type IntentOptional Attributes Name
class(abstract_sym_linop_rdp), intent(in) :: A

Linear operator to be inverted.

class(abstract_vector_rdp), intent(in) :: b

Right-hand side vector.

class(abstract_vector_rdp), intent(inout) :: x

Solution vector.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: rtol

Relative solver tolerance

real(kind=dp), intent(in), optional :: atol

Absolute solver tolerance

class(abstract_precond_rdp), intent(in), optional :: preconditioner

Preconditioner (not yet supported).

type(cg_dp_opts), intent(in), optional :: options

Options for the conjugate gradient solver.

public subroutine cg_csp(A, b, x, info, rtol, atol, preconditioner, options)

Arguments

Type IntentOptional Attributes Name
class(abstract_hermitian_linop_csp), intent(in) :: A

Linear operator to be inverted.

class(abstract_vector_csp), intent(in) :: b

Right-hand side vector.

class(abstract_vector_csp), intent(inout) :: x

Solution vector.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: rtol

Relative solver tolerance

real(kind=sp), intent(in), optional :: atol

Absolute solver tolerance

class(abstract_precond_csp), intent(in), optional :: preconditioner

Preconditioner (not yet supported).

type(cg_sp_opts), intent(in), optional :: options

Options for the conjugate gradient solver.

public subroutine cg_cdp(A, b, x, info, rtol, atol, preconditioner, options)

Arguments

Type IntentOptional Attributes Name
class(abstract_hermitian_linop_cdp), intent(in) :: A

Linear operator to be inverted.

class(abstract_vector_cdp), intent(in) :: b

Right-hand side vector.

class(abstract_vector_cdp), intent(inout) :: x

Solution vector.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: rtol

Relative solver tolerance

real(kind=dp), intent(in), optional :: atol

Absolute solver tolerance

class(abstract_precond_cdp), intent(in), optional :: preconditioner

Preconditioner (not yet supported).

type(cg_dp_opts), intent(in), optional :: options

Options for the conjugate gradient solver.