PARCEL SYCL v1.2 / API Reference User Guide API Reference Search Download 日本語

13 parcel::krylov::pgmres

13.1 pgmres (class)

Description Preconditioned generalized minimal residual method (right preconditioning, with restarts). Solves Ax=bAx = b 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 Ax=bAx = b.

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() ≥m\geq m (not checked). If b=0b = 0, the solver returns x=0x = 0 as pcg does (z=0z = 0 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 mm.

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 mm. Storage for m+1m+1 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 zz of right preconditioning (the solution of (AK−1)z=b(AK^{-1})z = b) as is. Used internally by the AK−1AK^{-1} 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, zz is returned in x0 without the final multiplication by K−1K^{-1}. The initial value of x0 is also interpreted as z0z_0 false

MPI Local operation. Give the same value on all ranks.

Notes If true, the solution update does not multiply by K−1K^{-1}: x(j+1)=x(j)+∑kykvkx^{(j+1)} = x^{(j)} + \sum_{k} y_{k}v_{k} (yy is the solution of the least-squares problem), and the internal variable zz of the right preconditioning is returned in x0. The initial value of x0 is also interpreted as zz, and the residual at the start of a restart is r=b−AK−1zr = b - AK^{-1}z. If σ\sigma is also given with set_shift(), (AK−1−σI)z=b(AK^{-1} - \sigma I)z = b is solved (w=AK−1vi−σviw = AK^{-1}v_{i} - \sigma v_{i} in the Arnoldi process, and the residual is r=b−AK−1z+σzr = b - AK^{-1}z + \sigma z). If true, get_true_residual() returns ∥b−AK−1z+σz∥/∥b∥\|b - AK^{-1}z + \sigma z\|/\|b\|.

13.6 set_shift() / get_shift()

Description When set_precon_space_output(true) is set, sets or gets the shift σ\sigma with which (AK−1−σI)z=b(AK^{-1} - \sigma I)z = b is solved.

Synopsis

void   set_shift(double sigma);
double get_shift() const;

Arguments

Name In/Out Type Description Default
sigma In double Shift σ\sigma 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().