13 parcel::krylov::pgmres
13.1 pgmres (class)
Description Preconditioned generalized minimal residual method (right preconditioning, with restarts). Solves for a nonsymmetric matrix.
Synopsis
template< class Tspmv = parcel_double, class Tprecon = parcel_double,
class Taxpy = parcel_double, class Tdot = parcel_double >
class pgmres : public krylov_param;See Also Convergence check and breakdown, set_restart(), set_qr_algo()
13.2 solver()
Description Solves .
Synopsis
template< class Tmat, class Tvecx, class Tvecb, class Tvec = parcel_double,
class Tprecon_mat = parcel_double, class Tprecon_vec = parcel_double,
class TGS = parcel_double, class THessenberg = parcel_double >
void solver(parcel::matrix<Tmat> &Mat, parcel::vector<Tvecx> &x0, parcel::vector<Tvecb> &b0,
parcel::precon_matrix<Tmat,Tvec,Tprecon_mat,Tprecon_vec,Tprecon> *external_precon = nullptr);Arguments
| Name | In/Out | Type | Description | Default |
|---|---|---|---|---|
TGS |
In (template) | PARCEL data type | Precision of the Gram-Schmidt orthogonalization | parcel_double |
THessenberg |
In (template) | PARCEL data type | Precision of the Hessenberg matrix | parcel_double |
Mat, x0, b0 |
Same as solver() of pcg |
none | ||
external_precon |
In | precon_matrix * |
A preconditioner matrix that has already been built. Used when an eigenvalue solver calls this solver repeatedly internally. Users should omit it. If passed, do not destroy or modify the matrix used to build it until you finish using it (the Jacobi preconditioner refers to the structure and values of that matrix) | nullptr (built internally) |
Requirements Satisfy the common requirements (an in-order queue, a registered matrix, and the queues and lengths of the vectors). get_max_iteration() (not checked). If , the solver returns as pcg does ( in the preconditioned-space output mode).
Return Value None.
MPI Collective. All ranks must call it with the same settings.
Example
parcel::krylov::pgmres<> gm;
gm.solver(A, x, b);13.3 set_restart() / get_restart()
Description Sets or gets the restart length .
Synopsis
void set_restart(PARCEL_INT gmres_m);
PARCEL_INT get_restart() const;Arguments
| Name | In/Out | Type | Description | Default |
|---|---|---|---|---|
gmres_m |
In | PARCEL_INT |
Restart length . Storage for basis vectors is allocated | 30 |
Requirements 1 or greater. 0 or less throws std::invalid_argument.
MPI Local operation. Give the same value on all ranks.
Example
gm.set_restart(8);13.4 set_qr_algo() / get_qr_algo()
Description Sets or gets the orthogonalization method used in the Arnoldi process.
Synopsis
void set_qr_algo(PARCEL_INT qrdecomposition_algo);
PARCEL_INT get_qr_algo() const;Arguments
| Name | In/Out | Type | Description | Default |
|---|---|---|---|---|
qrdecomposition_algo |
In | PARCEL_INT |
parcel::qr::QR_CGS (0, classical Gram-Schmidt) or QR_MGS (1, modified Gram-Schmidt) |
QR_MGS |
Requirements QR_CGS or QR_MGS. Any other value (including QR_CHOLESKYQR) throws std::invalid_argument.
MPI Local operation. Give the same value on all ranks.
See Also The “QR Factorization” chapter
Example
gm.set_qr_algo(parcel::qr::QR_MGS);13.5 set_precon_space_output() / get_precon_space_output()
Description Sets or gets the mode that returns the internal variable of right preconditioning (the solution of ) as is. Used internally by the mode of the eigenvalue solvers.
Synopsis
void set_precon_space_output(bool f);
bool get_precon_space_output() const;Arguments
| Name | In/Out | Type | Description | Default |
|---|---|---|---|---|
f |
In | bool |
If true, is returned in x0 without the final multiplication by . The initial value of x0 is also interpreted as |
false |
MPI Local operation. Give the same value on all ranks.
Notes If true, the solution update does not multiply by : ( is the solution of the least-squares problem), and the internal variable of the right preconditioning is returned in x0. The initial value of x0 is also interpreted as , and the residual at the start of a restart is . If is also given with set_shift(), is solved ( in the Arnoldi process, and the residual is ). If true, get_true_residual() returns .
13.6 set_shift() / get_shift()
Description When set_precon_space_output(true) is set, sets or gets the shift with which is solved.
Synopsis
void set_shift(double sigma);
double get_shift() const;Arguments
| Name | In/Out | Type | Description | Default |
|---|---|---|---|---|
sigma |
In | double |
Shift | 0 |
MPI Local operation. Give the same value on all ranks.
Notes Not used with set_precon_space_output(false). This is a different function from ks_arnoldi::set_shift().