cyclic_reduction, a C++ code which applies cyclic reduction to solve a tridiagonal system of linear equations A*x=b.
The matrix is assumed to be diagonally dominant - that is, for every row, we require that the magnitude of the diagonal entry be at least as great as the sum of the magnitudes of the two off-diagonal elements. This is (just barely) true for the "-1, 2, -1" matrix, for instance.
Other methods for solving tridiagonal linear systems include:
Cyclic reduction is a form of Gauss elimination. It proceeds by first eliminating half of the variables simultaneously, then half of the remainder, and so on. This amounts to more work, but the work in each elimination step can be done in parallel. Thus, unlike the Gauss and Thomas algorithms, cyclic reduction offers a procedure for the direct solution of a tridiagonal linear system that can take advantage of parallelism.
Cyclic reduction can also be adapted to the block tridiagonal linear systems that arise when Poisson's equation is discretized over a 2D region.
The computer code and data files described and made available on this web page are distributed under the MIT license
cyclic_reduction is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.
LINPACK_D, a C++ code which factors and solves systems of linear equations in a variety of formats and arithmetic types.
MGMRES, a C++ code which applies the restarted GMRES algorithm to solve a sparse linear system.
TEST_MAT, a C++ code which defines test matrices, some of which have known determinants, eigenvalues and eigenvectors, inverses and so on.