# KSPSetPC
Sets the preconditioner to be used to calculate the application of the preconditioner on a vector. 
## Synopsis
```
#include "petscksp.h" 
#include "petscmat.h" 
PetscErrorCode KSPSetPC(KSP ksp, PC pc)
```
Collective on ksp


## Input Parameters

- ***ksp -*** iterative context obtained from `KSPCreate()`
- ***pc   -*** the preconditioner object (can be NULL)



## Notes
Use `KSPGetPC()` to retrieve the preconditioner context.




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

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/interface/itfunc.c.html#KSPSetPC">src/ksp/ksp/interface/itfunc.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex59.c.html">src/ksp/ksp/tutorials/ex59.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/ksp/interface/itfunc.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)  
