cg


cg, an Octave code which implements a simple version of the conjugate gradient (CG) method for solving a system of linear equations of the form A*x=b, suitable for situations in which the matrix A is positive definite (only real, positive eigenvalues) and symmetric.

Licensing:

The computer code and data files made available on this web page are distributed under the MIT license

Languages:

cg is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

cg_test

bicg, an Octave code which implements the biconjugate gradient method (BICG), which estimates the solution of a large sparse nonsymmetric linear system.

cg_rc, an Octave code which implements the conjugate gradient method for solving a positive definite sparse linear system A*x=b, using reverse communication.

cg_squared, an Octave code which implements the conjugate gradient squared (CGS) method for solving a nonsymmetric sparse linear system A*x=b.

cgne, an Octave code which implements the conjugate gradient method (CG) for the normal equations, that is, a method for solving a system of linear equations of the form A*x=b, where the matrix A is not symmetric positive definite (SPD). In this case, it is attempted to set up and solve the normal equations A'*A*x=A'*b.

gmres, an Octave code which applies the Generalized Minimum Residual (GMRES) method to solve a nonsymmetric sparse linear system.

sor, an Octave code which implements a simple version of the successive over-relaxation (SOR) method for the iteration solution of a linear system of equations.

wathen_matrix, an Octave code which compares storage schemes (full, banded, sparse triplet, sparse) and solution strategies (A\x, Linpack, conjugate gradient) for linear systems involving the Wathen matrix, which can arise when solving a problem using the finite element method (FEM).

Reference:

  1. Frank Beckman,
    The Solution of Linear Equations by the Conjugate Gradient Method,
    in Mathematical Methods for Digital Computers,
    edited by John Ralston, Herbert Wilf,
    Wiley, 1967,
    ISBN: 0471706892,
    LC: QA76.5.R3.
  2. Jonathan Shewchuk,
    An introduction to the conjugate gradient method without the agonizing pain, Edition 1.25, August 1994.

Source Code:


Last revised on 12 December 2018.