Restarted GMRES solver for sparse linear systems

MGMRES is a C++ library which applies the restarted Generalized Minimum Residual (GMRES) algorithm to solve a sparse linear system, using compressed row (CR) or sparse triplet (ST) format, by Lili Ju.

One matrix format used is the ST or "sparse triplet" format, which sets NZ_NUM to the number of nonzeros, and stores the K-th nonzero matrix entry as:

Another matrix format used is the CR or "sparse compressed row" format, which is similar to the sparse triplet format except that it the vector of row indices is compressed to a vector of length N+1 which points to the beginning of the set of entries for each row.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


MGMRES is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

CC, a data directory which contains examples of the Compressed Column (CC) sparse matrix file format;

CG_RC, a C++ library which implements the conjugate gradient method for solving a positive definite sparse linear system A*x=b, using reverse communication.

CR, a data directory which contains examples of the Compressed Row (CR) sparse matrix file format;

CSPARSE, a C library which implements iterative methods for solving linear systems.

FEM2D_POISSON_SPARSE, a C++ program which solves the steady Poisson equation on a 2D triangulated region. The program uses a copy of MGMRES to solve the linear system.

HBSMC, a dataset directory which contains a collection of large sparse matrices stored in the Harwell-Boeing format.

LINPACK, a C++ library which carries out direct methods for solving linear systems.

MM, a data directory which contains a description and examples of the Matrix Market format for storing matrices.

ST, a data directory which contains a description and examples of the ST format for storing sparse matrices, which are used by the C and C++ versions of MGMRES.

SUPERLU, C++ programs which illustrate how a C++ program can call the SUPERLU library, (which is written in C), which applies a fast direct solution method to solve sparse linear systems, by James Demmel, John Gilbert, and Xiaoye Li.

TEST_MAT, a C++ library which defines test matrices.


Original C version by Lili Ju, Mathematics Department, University of South Carolina; C++ version by John Burkardt.


  1. Richard Barrett, Michael Berry, Tony Chan, James Demmel, June Donato, Jack Dongarra, Victor Eijkhout, Roidan Pozo, Charles Romine, Henk van der Vorst,
    Templates for the Solution of Linear Systems:
    Building Blocks for Iterative Methods,
    SIAM, 1994,
    ISBN: 0898714710,
    LC: QA297.8.T45.
  2. Tim Kelley,
    Iterative Methods for Linear and Nonlinear Equations,
    SIAM, 2004,
    ISBN: 0898713528,
    LC: QA297.8.K45.
  3. Yousef Saad,
    Iterative Methods for Sparse Linear Systems,
    Second Edition,
    SIAM, 20003,
    ISBN: 0898715342,
    LC: QA188.S17.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C++ source codes.

Last revised on 20 December 2011.