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

11 parcel::krylov::pcg

11.1 pcg (class)

Description Preconditioned conjugate gradient method. Solves a linear system Ax=bAx = b whose coefficient matrix is symmetric positive definite.

Synopsis

template< class Tspmv = parcel_double, class Tprecon = parcel_double,
          class Taxpy = parcel_double, class Tdot    = parcel_double >
class pcg : public krylov_param;

Notes There are no class-specific member functions (only the common member functions). Updates of the solution vector are batched over the number of iterations given by the environment variable PARCEL_PSTEP (default 1; 4 when built with -DPARCEL_PCG_NO_XHIST=0). With the default 1, a single search direction is kept. With PARCEL_PSTEP=4, a history of 4 search directions is kept (memory of 3 vectors), and the solver becomes slightly faster because the solution is read and written less often (“Choosing Between Memory and Speed” in the User Guide).

See Also Convergence check and breakdown, The “Linear Solvers” chapter, pbicgstab

11.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 >
void solver(parcel::matrix<Tmat> &Mat, parcel::vector<Tvecx> &x0, parcel::vector<Tvecb> &b0);

Arguments

Name In/Out Type Description Default
Mat In parcel::matrix<Tmat> & Coefficient matrix registered with set_crsMat() none
x0 In/Out parcel::vector<Tvecx> & On input, the initial guess; on output, the solution vector. Its length is the number of locally owned rows none
b0 In parcel::vector<Tvecb> & Right-hand side vector. Its length is the number of locally owned rows none

Requirements Satisfy the common requirements (an in-order queue, a registered matrix, and the queues and lengths of the vectors). AA and the preconditioner are symmetric positive definite (not checked). If b=0b = 0, the solver sets x0 to 0 without iterating and returns with CONVERGED_RTOL (iteration count 0).

Return Value None. The results are obtained from x0 and from the functions that query the convergence status.

MPI Collective. All ranks must call it with the same settings.

See Also Template arguments of solver(), is_converged()

Example

parcel::krylov::pcg<> cg;
cg.solver(A, x, b);   // all precisions that cannot be deduced are parcel_double
cg.solver<parcel_double, parcel_double, parcel_double,
          parcel_double, parcel_double, parcel_double>(A, x, b);