This is an implementation of the conjugate gradient method for
RealLinearOperator. It follows closely the template by Barrett et al. (1994) (figure 2.5). The linear system at
hand is A · x = b, and the residual is r = b - A · x.
A default stopping criterion is implemented. The iterations stop when || r || ≤ δ || b ||, where b is the right-hand side vector, r the current estimate of the residual, and δ a user-specified tolerance. It should be noted that r is the so-called updated residual, which might differ from the true residual due to rounding-off errors (see e.g. Strakos and Tichy, 2002).
In the present context, an iteration should be understood as one evaluation of the matrix-vector product A · x. The initialization phase therefore counts as one iteration.
Besides standard DimensionMismatchException, this class might throw
NonPositiveDefiniteOperatorException if the linear operator or
the preconditioner are not positive definite. In this case, the
ExceptionContext provides some more information
"operator" points to the offending linear operator, say L,"vector" points to the offending vector, say x, such that
xT · L · x < 0.| Modifier and Type | Field and Description |
|---|---|
| private boolean | check
|
| private final double | delta
The value of δ, for the default stopping criterion. |
| public static final String | OPERATOR
Key for the exception context. |
| public static final String | VECTOR
Key for the exception context. |
| Access | Constructor and Description |
|---|---|
| public | ConjugateGradient(final int
the maximum number of iterations maxIterations, final double the δ parameter for the default stopping criterion delta, final boolean true if positive definiteness of both matrix and
preconditioner should be checkedCreates a new instance of this class, with default stopping criterion. |
| public | ConjugateGradient(final IterationManager
the custom iteration manager manager, final double the δ parameter for the default stopping criterion delta, final boolean true if positive definiteness of both matrix and
preconditioner should be checkedCreates a new instance of this class, with default stopping criterion and custom iteration manager. |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | Returns: true if the tests are to be performedReturns |
| public RealVector | solveInPlace(final RealLinearOperator
the linear operator A of the system a, final RealLinearOperator the preconditioner, M (can be m, final RealVector null)the right-hand side vector b, final RealVector the initial guess of the solution x0)Implements abstract org. Returns an estimate of the solution to the linear system A · x = b. |
| check | back to summary |
|---|---|
| private boolean check
| |
| delta | back to summary |
|---|---|
| private final double delta The value of δ, for the default stopping criterion. | |
| OPERATOR | back to summary |
|---|---|
| public static final String OPERATOR Key for the exception context. | |
| VECTOR | back to summary |
|---|---|
| public static final String VECTOR Key for the exception context. | |
| ConjugateGradient | back to summary |
|---|---|
| public ConjugateGradient(final int maxIterations, final double delta, final boolean check) Creates a new instance of this class, with default stopping criterion.
| |
| ConjugateGradient | back to summary |
|---|---|
| public ConjugateGradient(final IterationManager manager, final double delta, final boolean check) throws NullArgumentException Creates a new instance of this class, with default stopping criterion and custom iteration manager.
| |
| getCheck | back to summary |
|---|---|
| public final boolean getCheck() Returns
| |
| solveInPlace | back to summary |
|---|---|
| public RealVector solveInPlace(final RealLinearOperator a, final RealLinearOperator m, final RealVector b, final RealVector x0) throws NullArgumentException, NonPositiveDefiniteOperatorException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException Implements abstract org. Doc from org. Returns an estimate of the solution to the linear system A · x = b. The solution is computed in-place (initial guess is modified).
| |