:orphan:
# KSPRegister
Adds a method, `KSPType`, to the Krylov subspace solver package. 
## Synopsis
```
#include "petscksp.h" 
PetscErrorCode KSPRegister(const char sname[], PetscErrorCode (*function)(KSP))
```
Not Collective


## Input Parameters

- ***sname -*** name of a new user-defined solver
- ***function -*** routine to create method





## Note
`KSPRegister()` may be called multiple times to add several user-defined solvers.


## Sample usage
```none
   KSPRegister("my_solver", MySolverCreate);
```


Then, your solver can be chosen with the procedural interface via
```none
` KSPSetType`(ksp, "my_solver")
```
or at runtime via the option
```none
-ksp_type my_solver
```


## See Also
 [](ch_ksp), `KSP`, `KSPType`, `KSPSetType`, `KSPRegisterAll()`

## Level
advanced

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


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


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