Date: 2026-06-01T23:13:24+00:00

Actual source code: cgimpl.h

      1: /*
      2:     Private Krylov Context Structure (KSP) for Conjugate Gradient

      4:     This one is very simple. It contains a flag indicating the symmetry
      5:    structure of the matrix and work space for (optionally) computing
      6:    eigenvalues.
      7: */

      9: #pragma once

     11: /*
     12:         Defines the basic KSP object
     13: */
     14: #include <petsc/private/kspimpl.h>

     16: PETSC_INTERN PetscErrorCode KSPDestroy_CG(KSP);
     17: PETSC_INTERN PetscErrorCode KSPReset_CG(KSP);
     18: PETSC_INTERN PetscErrorCode KSPView_CG(KSP, PetscViewer);
     19: PETSC_INTERN PetscErrorCode KSPSetFromOptions_CG(KSP, PetscOptionItems);
     20: PETSC_INTERN PetscErrorCode KSPCGSetType_CG(KSP, KSPCGType);

     22: /*
     23:     This struct is shared by several KSP implementations
     24: */

     26: typedef struct {
     27:   KSPCGType type; /* type of system (symmetric or Hermitian) */

     29:   // The following arrays are of size ksp->maxit
     30:   PetscScalar *e, *d;
     31:   PetscReal   *ee, *dd; /* work space for Lanczos algorithm */

     33:   /* Trust region support */
     34:   PetscReal radius;
     35:   PetscReal obj;
     36:   PetscReal obj_min;

     38:   PetscBool singlereduction; /* use variant of CG that combines both inner products */
     39: } KSP_CG;