# KSPCGSetType
Sets the variant of the conjugate gradient method to use for solving a linear system with a complex coefficient matrix. This option is irrelevant when solving a real system. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPCGSetType(KSP ksp, KSPCGType type)
```
Logically Collective on ksp


## Input Parameters

- ***ksp -*** the iterative context
- ***type -*** the variant of CG to use, one of


```none
      KSP_CG_HERMITIAN - complex, Hermitian matrix (default)
      KSP_CG_SYMMETRIC - complex, symmetric matrix
```





## Options Database Keys

- ***-ksp_cg_hermitian -*** Indicates Hermitian matrix
- ***-ksp_cg_symmetric -*** Indicates symmetric matrix



## Note
By default, the matrix is assumed to be complex, Hermitian.


## See Also
 [](chapter_ksp), `KSP`, `KSPCG`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cgtype.c.html#KSPCGSetType">src/ksp/ksp/impls/cg/cgtype.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cg.c.html#KSPCGSetType_CG">KSPCGSetType_CG in src/ksp/ksp/impls/cg/cg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/impls/cg/cgne/cgne.c.html#KSPCGSetType_CGNE">KSPCGSetType_CGNE in src/ksp/ksp/impls/cg/cgne/cgne.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/impls/cg/cgtype.c)


[Index of all KSP routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
