|
|
◆ gcr_r()
| void gcr_r |
( |
int |
n, |
|
|
const double |
b[], |
|
|
double |
x[], |
|
|
int |
m, |
|
|
int |
maxiter, |
|
|
int * |
iter, |
|
|
double * |
res, |
|
|
int |
lwork, |
|
|
double |
work[], |
|
|
int * |
info, |
|
|
double |
xx[], |
|
|
double |
yy[], |
|
|
int * |
irev |
|
) |
| |
Solution of linear system Ax = b using generalized conjugate residual (GCR) method (Reverse communication version)
- Purpose
- This routine solves the linear system Ax = b using the generalized conjugate residual (GCR) iterative 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] | m | Restart parameter. (0 < m <= n) |
| [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 >= (2*m + 2)*n + m) |
| [out] | work[] | Array work[lwork]
Work array. |
| [out] | info | = 0: Successful exit
< 0: The (-info)-th argument is invalid.
= 11: Maximum number of iterations exceeded.
= 12: Breakdown occurred. |
| [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, 3, 4: matvec operation. User should set A*xx in yy[]. Do not alter any other variables.
= 21, 22: 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. |
|