Detailed Description

Preconditioned cg method for symmetric positive definite matrices. This class is used first in step-3 and step-4, but is used in many other tutorial programs as well. Like all other solver classes, it can work on any kind of vector and matrix as long as they satisfy certain requirements (for the requirements on matrices and vectors in order to work with this class, see the documentation of the Solver base class). The type of the solution vector must be passed as template argument, and defaults to Vector<double>.

Note

This version of CG is taken from D. Braess's book "Finite Elements". It requires a symmetric preconditioner (i.e., for example, SOR is not a possible choice).

Eigenvalue computation

The cg-method performs an orthogonal projection of the original preconditioned linear system to another system of smaller dimension. Furthermore, the projected matrix T is tri-diagonal. Since the projection is orthogonal, the eigenvalues of T approximate those of the original preconditioned matrix PA. In fact, after n steps, where n is the dimension of the original system, the eigenvalues of both matrices are equal. But, even for small numbers of iteration steps, the condition number of T is a good estimate for the one of PA.

After m steps the matrix T_m can be written in terms of the coefficients alpha and beta as the tri-diagonal matrix with diagonal elements 1/alpha_0, 1/alpha_1 + beta_0/alpha_0, ..., 1/alpha_{m-1+beta_{m-2}/alpha_{m-2}} and off-diagonal elements sqrt(beta_0)/alpha_0, ..., sqrt(beta_{m-2)/alpha_{m-2}}. The eigenvalues of this matrix can be computed by postprocessing.

The coefficients, eigenvalues and condition number (computed as the ratio of the largest over smallest eigenvalue) can be obtained by connecting a function as a slot to the solver using one of the functions connect_coefficients_slot, connect_eigenvalues_slot and connect_condition_number_slot. These slots will then be called from the solver with the estimates as argument.

Observing the progress of linear solver iterations

The solve() function of this class uses the mechanism described in the Solver base class to determine convergence. This mechanism can also be used to observe the progress of the iteration.

Connect a slot to retrieve the CG coefficients. The slot will be called with alpha as the first argument and with beta as the second argument, where alpha and beta follow the notation in Y. Saad: "Iterative methods
for Sparse Linear Systems", section 6.7. Called once per iteration

Connect a slot to retrieve the estimated condition number. Called on each iteration if every_iteration=true, otherwise called once when iterations are ended (i.e., either because convergence has been achieved, or because divergence has been detected).

Connect a slot to retrieve the estimated eigenvalues. Called on each iteration if every_iteration=true, otherwise called once when iterations are ended (i.e., either because convergence has been achieved, or because divergence has been detected).