|
◆ z_cg_r()
void z_cg_r |
( |
int |
n, |
|
|
const doublecomplex |
b[], |
|
|
doublecomplex |
x[], |
|
|
int |
maxiter, |
|
|
int * |
iter, |
|
|
double * |
res, |
|
|
int |
lwork, |
|
|
doublecomplex |
work[], |
|
|
int * |
info, |
|
|
doublecomplex |
xx[], |
|
|
doublecomplex |
yy[], |
|
|
int * |
irev |
|
) |
| |
Solution of linear system Ax = b using conjugate gradient (CG) method (Hermitian positive definite matrices) (Reverse communication version)
- Purpose
- This routine solves the linear system Ax = b with Hermitian positive definite coefficient matrix using the conjugate gradient (CG) method with preconditioning.
- Parameters
-
[in] | n | Dimension of the matrix. (n >= 0) (if n = 0, returns without computation) |
[in] | b[] | Array b[lb] (lb >= n)
Right hand side vector b. |
[in,out] | x[] | Array x[lx] (lx >= n)
[in] Initial guess of solution.
[out] Obtained approximate solution. |
[in] | maxiter | Maximum number of iterations. (maxiter > 0) |
[out] | iter | Final number of iterations. |
[out] | res | Final residual norm norm(b - A*x). |
[in] | lwork | Size of array work[]. (lwork >= 3*n) |
[out] | work[] | Array work[lwork]
Work array. |
[out] | info | = 0: Successful exit.
< 0: The (-info)-th argument is invalid.
= 1: (Warning) Matrix A is not positive definite (computation continued).
= 2: (Warning) Preconditioner matrix M is not positive definite (computation continued).
= 11: Maximum number of iterations exceeded.
= 12: Matrix A is singular. |
[in,out] | xx[] | Array xx[] for matvec and psolve operations. |
[in,out] | yy[] | Array yy[] for matvec and psolve operations. |
[in,out] | irev | Control variable for reverse communication.
[in] Before first call, irev should be initialized to zero. On succeeding calls, irev should not be altered (except if converged).
[out] If irev is not zero, complete the following process and call this routine again.
= 0: Computation finished. See return code in info.
= 1, 2: matvec operation. User should set A*xx in yy[]. Do not alter any other variables.
= 21: psolve operation. User should set solution of M*xx = yy in xx[]. Do not alter any other variables.
= 91, 92: Returned on every iteration for the convergence test. Set irev = 99 if converged. Do not alter irev otherwise. The latest values in x[], iter and res can be used to decide the convergence. Further, these values may be used to output the intermediate results. |
|